Commit ac16d5bb authored by Fernando Silva Coira's avatar Fernando Silva Coira
Browse files

Initial commit

parents
cmake-build-debug/
.idea/
cmake_minimum_required(VERSION 2.8.4)
project(k2-raster)
set(PROJECT_VENDOR "Fernando Silva")
set(CMAKE_PROJECT_NAME "k2-raster")
set(PROJECT_CONTACT "fernando.silva@udc.es")
set(CMAKE_INSTALL_PREFIX /home/fsilva/software)
set(CMAKE_COMPILER_IS_GNUCXX)
# Set output folder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include_directories(./include/)
include_directories(./libs/RePair/)
set(SOURCES
src/k2raster/k2-raster.cpp
src/k2raster/plain/k2-raster-plain.cpp
src/k2raster/plain/k2-raster-plain-DAC.cpp
src/k2raster/plain/k2-raster-plain-VByte.cpp
src/k2raster/compresessLeaves/k2-raster-CompressLeaves.cpp
src/k2raster/compresessLeaves/k2-raster-CompressLeavesH.cpp
src/k2raster/k2-raster-entropy.cpp
src/k2raster/k2-raster-opt.cpp
src/rtree/GetObjectsQueryBasic.cpp
src/rtree/SpatialJoin/QueryStrategy/GetRoot.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategy.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyLeaves.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyQueue.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyQueueV2.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyTree.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyTreeV2.cpp
src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyTreeV3.cpp
src/rtree/SpatialJoin/Visitor/GetObjectsVisitorCells.cpp
src/rtree/Statistic/GetObjectsQueryTopK.cpp
src/rtree/Statistic/GetObjectsQueryMaxMBR.cpp
src/rtree/Statistic/GetObjectsQueryMaxTopK.cpp
src/rtree/Statistic/GetObjectsQueryMinTopK.cpp
src/algebra/algebra.cpp
src/k2raster/util/QNode.cpp
src/k2raster/util/InfoMinSubMatrix.cpp
libs/RePair/Coder/arrayg.cpp
libs/RePair/Coder/basics.cpp
libs/RePair/Coder/hash.cpp
libs/RePair/Coder/heap.cpp
libs/RePair/Coder/records.cpp
libs/RePair/Coder/dictionary.cpp
libs/RePair/Coder/IRePair.cpp
libs/RePair/Coder/CRePair.cpp
libs/RePair/RePair.cpp
libs/RePair/rp-utils/LogSequence.cpp
libs/RePair/rp-utils/DAC_VLS.cpp)
# Flags
set(CMAKE_CXX_FLAGS " -Wall -m64")
set(CMAKE_CXX_FLAGS_RELEASE " -std=c++0x -Wall -O9")
set(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -O9 ")
#set(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -g3 -DDEBUG")
#set(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -pg ")
# set default compilation and show details for debug build
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_VERBOSE_MAKEFILE ON)
endif (NOT CMAKE_BUILD_TYPE)
# Create the library
add_library(k2raster STATIC ${SOURCES})
install(TARGETS k2raster DESTINATION lib)
install(DIRECTORY "includes" DESTINATION includes/libk2raster)
#Add libraries
# Add libcds
set(LIBCDS_DIR "./libs/libcds2/")
include_directories(${LIBCDS_DIR})
include_directories(${LIBCDS_DIR}includes/)
add_subdirectory(${LIBCDS_DIR})
#Add libUtils
set(LIBUTILS_DIR "./libs/libUtils/")
include_directories(${LIBUTILS_DIR})
include_directories(${LIBUTILS_DIR}include/)
add_subdirectory(${LIBUTILS_DIR})
# Add libEncoders
#set(LIBENCODERS_DIR "./libs/libEncoders")
#include_directories(${LIBENCODERS_DIR})
#include_directories(${LIBENCODERS_DIR}include/)
#LINK_DIRECTORIES(./libs/libEncoders/lib)
# Add VByte
set(LIBVBYTE_DIR "./libs/libVByte/")
include_directories(${LIBVBYTE_DIR})
include_directories(${LIBVBYTE_DIR}include/)
add_subdirectory(${LIBVBYTE_DIR})
# Add libspatialindex
set(LIBSPTATIALINDEX_DIR "./libs/spatialindex/")
include_directories(${LIBSPTATIALINDEX_DIR})
include_directories(${LIBSPTATIALINDEX_DIR}include/)
include_directories(${LIBSPTATIALINDEX_DIR}include/spatialindex)
add_subdirectory(${LIBSPTATIALINDEX_DIR})
# Executables
add_executable(Encodek2Raster ./src/encodek2Raster.cpp)
add_executable(Infok2Raster ./src/infok2Raster.cpp)
add_executable(GetCellValuek2Raster ./src/testGetCellValue.cpp)
add_executable(GetCellsRangeValuek2Raster ./src/testGetCellsRangeValue.cpp)
add_executable(GetValuesWindowk2Raster ./src/testGetValuesWindow.cpp)
add_executable(CheckValuesk2Raster ./src/testCheckValues.cpp)
add_executable(GetCellValueFilesk2Raster ./src/testGetCellValueFiles.cpp)
add_executable(GetCellsRangeValueFilesk2Raster ./src/testGetCellsRangeValueFiles.cpp)
add_executable(GetValuesWindowFilesk2Raster ./src/testGetValuesWindowFiles.cpp)
# Executables RTree
#add_executable(JoinRTreek2Raster ./src/jointRTree.cpp)
add_executable(JoinTreek2Raster src/exec/SpatialJoin/jointRTree.cpp)
# Executables Algebra
add_executable(AlgebraOperation ./src/exec/algebra/algebraOperation.cpp)
add_executable(AlgebraOperationInMemory ./src/exec/algebra/algebraOperationInMemory.cpp)
# Executables Statistic
add_executable(GetMaxMBR ./src/exec/Statistics/statisticRTreeMaxMBR.cpp)
add_executable(GetMaxTopK ./src/exec/Statistics/statisticRTreeMaxTopK.cpp)
add_executable(GetMinTopK ./src/exec/Statistics/statisticRTreeMinTopK.cpp)
# Tools
add_executable(CreateValueQueries ./tools/createValueQueries.cpp)
add_executable(CreateValueQueriesPercentage ./tools/createValueQueriesPercentage.cpp)
add_executable(TransformRaster ./tools/transformRaster.cpp)
# TEST
add_executable(TestEncodek2Raster ./test/k2raster/testEncode.cpp)
add_executable(TestGetCellValue ./test/k2raster/testGetCellValue.cpp)
add_executable(TestGetCellsRangeValue ./test/k2raster/testGetCellsRangeValue.cpp)
add_executable(TestDecompress ./test/k2raster/testDecompress.cpp)
# PROBAS
add_executable(ProbarRePair ./src/exec/Probas/probar-repair.cpp)
target_link_libraries(ProbarRePair LINK_PUBLIC k2raster cds utils vbyte)
# Target libraries
target_link_libraries(Encodek2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(Infok2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetCellValuek2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetCellsRangeValuek2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetValuesWindowk2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(CheckValuesk2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetCellValueFilesk2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetCellsRangeValueFilesk2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(GetValuesWindowFilesk2Raster LINK_PUBLIC k2raster cds utils vbyte)
# Target libraries RTree
#target_link_libraries(JoinRTreek2Raster LINK_PUBLIC k2raster cds utils vbyte spatialindex)
target_link_libraries(JoinTreek2Raster LINK_PUBLIC k2raster cds utils vbyte spatialindex)
# Target libraries Algebra
target_link_libraries(AlgebraOperation LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(AlgebraOperationInMemory LINK_PUBLIC k2raster cds utils vbyte)
# Target libraries Statistic
target_link_libraries(GetMaxMBR LINK_PUBLIC k2raster cds utils vbyte spatialindex)
target_link_libraries(GetMaxTopK LINK_PUBLIC k2raster cds utils vbyte spatialindex)
target_link_libraries(GetMinTopK LINK_PUBLIC k2raster cds utils vbyte spatialindex)
# Target libraries Tools
target_link_libraries(CreateValueQueries LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(CreateValueQueriesPercentage LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(TransformRaster LINK_PUBLIC k2raster cds utils vbyte)
# Target libraries TEST
target_link_libraries(TestEncodek2Raster LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(TestGetCellValue LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(TestGetCellsRangeValue LINK_PUBLIC k2raster cds utils vbyte)
target_link_libraries(TestDecompress LINK_PUBLIC k2raster cds utils vbyte)
\ No newline at end of file
This diff is collapsed.
k<sup>2</sup>-raster - A compacta data strucutre for raster data
=========================
We present the k2-raster, a new technique for representing raster datasets that uses compressed space and offers indexing capabilities, thus, improving query times over the raster data.
Let M be a raster matrix of size n×n, being n a power of k, containing values v ≥ 0 for each cell M<sub>i</sub><sub>j</sub>.
The k<sup>2</sup>-raster recursively partitions the matrix M into k<sup>2</sup> submatrices, analogous to the original k<sup>2</sup>-tree,
and builds a tree representing this recursive subdivision.
In addition, the representation is coupled with an efficient representation of the maximum and minimum values of each submatrix,
which are needed for the representation of the raster data, but also provide the indexing functionality.
## Compilation ##
To compile the code you need to execute the following commands:
```bash
cd k2-raster
mkdir build
cd build
cmake ..
make DEBUG=FALSE
```
Executables files are stored in
* ./build/bin/
Library files are stored in
* ./build/lib/
## Encode data ##
To compress a raster, you have to run the command:
```bash
./Encodek2Raster <dataFile> <rows> <cols> <k2rasterFile> <check> [type] [k1 k2 levelK1 [plainLevels]] [minFreqVoc]
```
Where:
* **\<dataFile>** input file (list of intergers of 32 bits)
* **\<rows>** number of rows
* **\<cols>** number of columns
* **\<treapFile>** path of the file where store the k<sup>2</sup>-raster
* **\<check>** A 1 if after constructing the structure performs a check, cell by cell, of the values. Compare the original value with the value returned by the structure. Or a 0 otherwise
* **\<type>** type of k<sup>2</sup>-raster which want to use to encode
* **\<k1>** k for the first levels. It partitions a matrix into k1 equal-size submatrices.
* **\<k2>** k for the rest of the levels. It partitions a matrix into k1 equal-size submatrices
* **\<levelk1>** number of levels we use the partition k1
* **\<plainLevels>** number of levels represented as plain values (no used with type 2 and 8)
* **\<minFreqVoc>** (only for type 7) minimum frequency of a word in the vocabulary.
#### k<sup>2</sup>-raster types ####
* **Type 1**: -- NOT USED --
* [**Type 2**](src/k2raster/k2-raster.cpp): Standard k2-raster. Version used on [__*SSDBM16*__](http://doi.org/10.1145/2949689.2949710)
* [**Type 3**](src/k2raster/plain/k2-raster-plain.cpp): Stored the lastest \<plainLevels> as plain values (array of integers of 32 bits)
* [**Type 4**](src/k2raster/plain/k2-raster-plain-DAC.cpp): Stored the lastest \<plainLevels> using a DAC encode.
* [**Type 5**](src/k2raster/plain/k2-raster-plain-VByte.cpp): Stored the lastest \<plainLevels> using VByte encode.
* [**Type 6**](src/k2raster/compresessLeaves/k2-raster-CompressLeaves.cpp): Creates a vocabulary to represent all submatrices defined by \<plainLevels>
* [**Type 7**](src/k2raster/compresessLeaves/k2-raster-CompressLeavesH.cpp): Creates a vocabulary to represent all sumbatrices defined by \<plainLevels> than have a frequency greater than \<minFreVoc>. The rest of submatrices are stores as plain values (array of interges of 32 bits)
* [**Type 8**](src/k2raster/k2-raster-opt.cpp): Optimization of **Type 2**. It executes the function *next()* instead of *access()* when we want to obtain a values from a DAC.
* [**Type 9**](src/k2raster/k2-raster-entropy.cpp): It uses a heuristic function to decide if a submatrix is stored in the vocabulary or in plain. The heuristic function determines which of the two options uses less space.
#### Example ####
For example, a 5x5 raster data (5 rows and 5 columns) is stored in _./inputData.bin_ and each cell has an integer value of 32 bits.
\[ 4 5 2 6 8 ... 33 45 23 25 ] (Total 25 numbers, the first 5 numbers correspond to the first row, the next five numbers correspond to the second row and so on)
To use **Type 2** and *k1* equal to 4 during the 4 first levels and *k2* equal to 2 for the rest of the levels.
```bash
./Encodek2Raster ./inputData.bin 5 5 outputFile.k2r 0 2 4 2 4
```
## Queries ##
We have implemented 4 useful queries to retrieve information using indexing techniques to improve the time consumption:
#### Obtaining a cell value ####
Given a position in the raster matrix, this query obtains its cell value.
```bash
./GetCellValuek2Raster <k2rasterFile> <queriesFile>
```
Where:
* **\<k2rasterFile>** Path of the file where the k<sup>2</sup>-raster is stored
* **\<queriesFile>** File with a set of queries. Each line is a query with format "posX posY"
#### Obtaining all the values of a region ####
Given a range of values, this query retrieves all raster positions whose value lies within that range.
```bash
./GetValuesWindowk2Raster <k2rasterFile> <queriesFile> <check>
```
Where:
* **\<k2rasterFile>** Path of the file where the k<sup>2</sup>-raster is stored
* **\<queriesFile>** File with a set of queries. Each line is a query with format "posX1 posX2 posY1 posY2 val1 val2" (val1 and val2 are not used on this version)
* **\<check>** 1 to check if the final result is correct. 0 in other case.
#### Retrieving cells with a given value or range of values ####
Given a range of values, this query retrieves all raster positions whose value lies within that range.
```bash
./GetCellsRangeValuek2Raster <k2rasterFile> <queriesFile> <check>
```
Where:
* **\<k2rasterFile>** Path of the file where the k<sup>2</sup>-raster is stored
* **\<queriesFile>** File with a set of queries. Each line is a query with format "posX1 posX2 posY1 posY2 val1 val2"
* **\<check>** 1 to check if the final result is correct. 0 in other case.
#### Checking the existence of a given value or range of values ####
Given a region and a range, this query checks if all cell values of the region are within the range of values or if there exists at least one cell value in the region whose value lies within the range of values.
```bash
./CheckValuesk2Raster <k2rasterFile> <queriesFile> <check> [allCells]
```
Where:
* **\<k2rasterFile>** Path of the file where the k<sup>2</sup>-raster is stored
* **\<queriesFile>** File with a set of queries. Each line is a query with format "posX1 posX2 posY1 posY2 val1 val2"
* **\<check>** 1 to check if the final result is correct. 0 in other case.
* **\<allCells>** sets whether all cells or at least one must meet query conditions
#### Spatial join - k<sup>2</sup>-raster and R-tree ####
```bash
./joinRTreek2Raster <k2rasterFile> <rtreeFile> <queryFile> <allCells> [strategyType]
```
Where:
* **\<k2rasterFile>** Path of the file where the k<sup>2</sup>-raster is stored
* **\<rtreeFile>** Path of the file where the R-tree is stored
* **\<queriesFile>** File with a set of queries. Each line is a query with format "posX1 posX2 posY1 posY2 val1 val2"
* **\<allCells>** sets whether all cells or at least one must meet query conditions
* **\<strategyType>** Select the strategy used during the spatial join:
* [**Type 0**](src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyQueue.cpp). Using a queue: Submatrices to be processed are added to a queue.
* [**Type 1**](src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyTree.cpp). Using a tree: A tree is created where it stores by levels the submatrices to be processed.
* [**Type 2**](src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyTree2.cpp). Using a tree V2: A tree is created where it stores by levels the submatrices to be processed (version 2).
* [**Type 3**](src/rtree/SpatialJoin/QueryStrategy/GetObjectsQueryStrategyLeaves.cpp). Using leaves: First, the leaves of the R-tree are obtained and afterwards their cells are searched in the k<sup>.
* [**Type 4**](src/joinRTree.cpp). Using cells: First the cells of the k2-raster are obtained and then they are searched in the R-tree if they match in a leaf.
## Publications ##
Ladra, S., Paramá, J. R., & Silva-Coira, F. (2016). Compact and queryable representation of raster datasets. In Proceedings of the 28th International Conference on Scientific and Statistical Database Management - SSDBM ’16 (pp. 1–12). New York, New York, USA: ACM Press. http://doi.org/10.1145/2949689.2949710
## Authors ##
Susana Ladra - <susana.ladra@udc.es>
José R. Paramá - <jose.parama@udc.es>
Fernando Silva-Coira - <fernando.silva@udc.es>
#### Implemented By ####
Fernando Silva-Coira - <fernando.silva@udc.es>
/*
* Created by Fernando Silva on 22/09/17.
*
* Copyright (C) 2017-current-year, Fernando Silva, all rights reserved.
*
*
* Author's contact: Fernando Silva <fernando.silva@udc.es>
* Databases Lab, University of A Coruña. Campus de Elviña s/n. Spain
*
* DESCRIPTION
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef K2_RASTER_ALGEBRA_H_H_
#define K2_RASTER_ALGEBRA_H_H_
#include <k2raster/k2-raster.h>
#include <k2raster/util/InfoMinSubMatrix.h>
using namespace k2raster_static;
namespace k2raster_algebra_static {
K2Raster* algebra(K2Raster *k2raster1, K2Raster *k2raster2, OperationRaster operation);
K2Raster* algebra(K2Raster *k2raster1, K2Raster *k2raster2, OperationRaster operation,
uint k1, uint k2, uint levelK1, bool deleteInputs=false);
}
#endif // K2_RASTER_ALGEBRA_H_H
/*
* Created by Fernando Silva on 24/05/16.
*
* Copyright (C) 2016-current-year, Fernando Silva, all rights reserved.
*
* Author's contact: Fernando Silva <fernando.silva@udc.es>
* Databases Lab, University of A Coruña. Campus de Elviña s/n. Spain
*
* DESCRIPTION
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef K2RASTER_COMPRESS_LEAVES_H_
#define K2RASTER_COMPRESS_LEAVES_H_
#include <k2raster/plain/k2-raster-plain.h>
#include <include/hash/HashTableWord.h>
namespace k2raster_static {
/****** Aux hash functions ******/
int compareFreqListDesc(const void *a, const void *b);
class K2RasterCompressLeaves : public K2RasterPlain {
public:
/****** Constructors ******/
K2RasterCompressLeaves(uint sizeX, uint size, int **data, uint K1, uint K2, uint levelK1, uint plainLevels);
~K2RasterCompressLeaves();
/****** Cell functions ******/
virtual int getPlainCell(uint father, uint row, uint col, uint divK, uint lastValueMax) const;
virtual ulong getPlainWindow(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK, uint maxValue,
uint *positions, ulong totalCells, Query query) const;
virtual bool checkPlainCells(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK,uint maxValue,
Query query, bool allCells) const;
virtual ulong getPlainCellValues(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK, uint maxValue,
int *values, ulong totalCells, Query query) const;
/****** File functions ******/
virtual void save(std::ofstream &of) const;
static K2RasterCompressLeaves *load(std::ifstream &in);
/****** Size functions ******/
virtual size_t getTotalSize() const;
virtual size_t printSize() const;
protected:
K2RasterCompressLeaves();
// Attributes
uint lenWord;
uint numOfWords; // Number of words of the vocabulary
uint totalLengthOfWords; // Length of the vocabulary
unsigned char* words; // Vocabulaby
cds_static::DirectAccess *valuesLeaves; // Encoded values of leaves
};
}
#endif // K2RASTER_COMPRESS_LEAVES_H_
/*
* Created by Fernando Silva on 24/05/16.
*
* Copyright (C) 2016-current-year, Fernando Silva, all rights reserved.
*
* Author's contact: Fernando Silva <fernando.silva@udc.es>
* Databases Lab, University of A Coruña. Campus de Elviña s/n. Spain
*
* DESCRIPTION
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef K2RASTER_COMPRESS_LEAVES_H_H_
#define K2RASTER_COMPRESS_LEAVES_H_H_
#include <k2raster/plain/k2-raster-plain.h>
#include <include/hash/HashTableWord.h>
namespace k2raster_static {
/****** Aux hash functions ******/
int compareFreqListDescH(const void *a, const void *b);
class K2RasterCompressLeavesH : public K2RasterPlain {
public:
/****** Constructors ******/
K2RasterCompressLeavesH(uint sizeX, uint size, int **data, uint K1, uint K2, uint levelK1, uint plainLevels, float minFreqVoc);
~K2RasterCompressLeavesH();
/****** Cell functions ******/
virtual int getPlainCell(uint father, uint row, uint col, uint divK, uint lastValueMax) const;
virtual ulong getPlainWindow(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK, uint maxValue,
uint *positions, ulong totalCells, Query query) const;
virtual bool checkPlainCells(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK,uint maxValue,
Query query, bool allCells) const;
virtual ulong getPlainCellValues(uint xini, uint yini, uint xend, uint yend,
uint offsetValues, uint divK, uint maxValue,
int *values, ulong totalCells, Query query) const;
/****** File functions ******/
virtual void save(std::ofstream &of) const;
static K2RasterCompressLeavesH *load(std::ifstream &in);
/****** Size functions ******/
virtual size_t getTotalSize() const;
virtual size_t printSize() const;
protected:
K2RasterCompressLeavesH();
// Attributes
uint lenWord;
uint numOfWords; // Number of words of the vocabulary
uint totalLengthOfWords; // Length of the vocabulary
unsigned char* words; // Vocabulaby
cds_static::BitSequence *bitmapVocLeaves; // k2-tree representation of the data: single bitmap for T:L
cds_static::DirectAccess *vocLeaves; // Encoded vocabulary of leaves
cds_static::DirectAccess *valuesLeaves; // Encode values of leaves that they are not in the vocabulary
};
}
#endif // KTREAP_RASTER_COMPRESS_LEAVES_H_
/*
* Created by Fernando Silva on 13/06/16.
*
* Copyright (C) 2016-current-year, Fernando Silva, all rights reserved.
*
* Author's contact: Fernando Silva <fernando.silva@udc.es>
* Databases Lab, University of A Coruña. Campus de Elviña s/n. Spain
*
* DESCRIPTION
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef K2RASTER_ENTROPY_H_H_
#define K2RASTER_ENTROPY_H_
#include <k2raster/plain/k2-raster-plain.h>
#include <include/hash/HashTableWord.h>
namespace k2raster_static {
/****** Aux hash functions ******/
int compareFreqListDescHEntropy(const void *a, const void *b);
bool compareFreqListDescHEntropy2(ulong left, ulong right);
class K2RasterEntropy : public K2RasterPlain {
public:
/****** Constructors ******/
K2RasterEntropy(uint sizeX, uint size, int **data, uint K1, uint K2, uint levelK1, uint plainLevels);
~K2RasterEntropy();
/****** Cell functions ******/
// GetCell
virtual int getPlainCell(uint father, uint row, uint col, uint divK, uint lastValueMax) const;
// GetCellsByValue
virtual ulong getPlainWindow(uint xini, uint yini, uint xend, uint yend,
uint valini, uint valend,
uint offsetValues, uint divK, uint maxValue,
uint *positions, ulong totalCells, bool allCells) const;