Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
e4023c0
test of commitment in CLion
pfeiffer-tim Apr 30, 2019
b496864
remove test commitment in gitignore
pfeiffer-tim Apr 30, 2019
1272bd8
added graph.h with structs, cmakelists.txt
pfeiffer-tim May 2, 2019
7160b74
first test file with print
pfeiffer-tim May 2, 2019
50c0446
Added subdir for graph test in cmakelists
alexKrauseTUD May 2, 2019
e1125ce
change dir of graph test file, cmakelists changes..
pfeiffer-tim May 2, 2019
79c4c23
read LDBC files into dicts (intermediate dictionary)
pfeiffer-tim May 2, 2019
934c2bd
added graph structure with class graph, vertex, edge; generated graph…
pfeiffer-tim May 3, 2019
f79e8ce
removed edge.h (edge is struct in vertex.h); fixed printing vertex infos
pfeiffer-tim May 3, 2019
29b77fd
added some comments...
pfeiffer-tim May 3, 2019
c7205e7
changed unsigned long int's to size_t
pfeiffer-tim May 6, 2019
f8ec509
changed namespace 'graph -> morphstore'; replace size_t with uint64_t
pfeiffer-tim May 13, 2019
6f5c62c
new directory in Engine/core/storage
pfeiffer-tim May 13, 2019
f5da8f5
started ldbc_import.h; changed cmake to handle experimental::filesystem
pfeiffer-tim May 14, 2019
11afae8
little changes...
pfeiffer-tim May 14, 2019
3100ea9
buffer allocation for vertex files
pfeiffer-tim May 16, 2019
a17146f
vertex data structure for intermediate results in ldbc importer
pfeiffer-tim May 16, 2019
cab0446
first attempt of loading ldbc-vertex-data into graph structure (i.e g…
pfeiffer-tim May 16, 2019
5c652bf
little changes; added comments
pfeiffer-tim May 17, 2019
a197aad
added hash function for pair as key in unordered map
pfeiffer-tim May 17, 2019
dfcecb0
added global id lookup when ldbc generating
pfeiffer-tim May 18, 2019
d5b72bb
little changes; started relation-import functionality (to be continued)
pfeiffer-tim May 18, 2019
24915f7
forgotten comments and little changes
pfeiffer-tim May 18, 2019
abc4750
working edge-generating from ldbc files
pfeiffer-tim May 20, 2019
6d9924e
little changes in ldbc importer
pfeiffer-tim May 20, 2019
1f3c739
remove unused include's
pfeiffer-tim May 20, 2019
61d2ff9
added simply functionality for multi-value attributes (just write the…
pfeiffer-tim May 21, 2019
80f1c2c
comment-out stuff
pfeiffer-tim May 21, 2019
4da862f
little changes; added time measuring
pfeiffer-tim May 23, 2019
8e6a881
declaring some function parameters as const
pfeiffer-tim May 23, 2019
af80035
comment stuff
pfeiffer-tim May 24, 2019
c582382
changed directory of LDBC files in test to /opt/...
pfeiffer-tim May 29, 2019
b7573cc
added ldbc.import() -> generate_vertices() + generate_edges()
pfeiffer-tim Jun 6, 2019
8c6be74
calculation of memory usage of graph
pfeiffer-tim Jun 11, 2019
39fb1f5
Reworked size functions. Advise: Write custom allocator to record mem…
alexKrauseTUD Jun 12, 2019
6de73b2
updating comments and cleaning stuff
pfeiffer-tim Jun 17, 2019
2bb9e34
new file structure; prep. for CSR format
pfeiffer-tim Jun 26, 2019
f3ee80d
added abstract graph class; cmakelist-update; preps for new CSR format
pfeiffer-tim Jul 16, 2019
163f51c
no idea whats that
pfeiffer-tim Jul 16, 2019
84acf81
cleaning up
pfeiffer-tim Jul 16, 2019
cf785bb
fixed vertex-entity-redundancy: now, entity-number to lookup
pfeiffer-tim Jul 17, 2019
f0a29e1
fixed edge-relation-redundancy: now, relation-number to lookup
pfeiffer-tim Jul 17, 2019
46adcd8
removed unused function in abstract graph class
pfeiffer-tim Jul 17, 2019
b534935
started CSR-format
pfeiffer-tim Jul 18, 2019
67b84d4
directory csr
pfeiffer-tim Jul 18, 2019
83f7b8e
first woriking implementation of CSR storage format
pfeiffer-tim Jul 19, 2019
af388bf
csr: now sorting neighbors of vertex ASC in the intermediates
pfeiffer-tim Jul 23, 2019
bf0992f
remove test-print vertex
pfeiffer-tim Jul 23, 2019
1c9da54
remove specific ldbc-importer header for CSR/ADJ; now one importer fo…
pfeiffer-tim Jul 23, 2019
3505a6c
clean-up
pfeiffer-tim Jul 23, 2019
0f22a21
some little changes
pfeiffer-tim Jul 23, 2019
52c8dae
code structure
pfeiffer-tim Jul 23, 2019
0d9af48
initialize array pointer as nullptr
pfeiffer-tim Jul 23, 2019
f9e7b07
introducing std::experimental::optional to make edge-property optiona…
pfeiffer-tim Jul 24, 2019
fdfe1cc
remove std::optional -> bad decision, needs moore memory as expected
pfeiffer-tim Jul 24, 2019
3b1cb55
changed array allocation: new [...] to malloc(...)
pfeiffer-tim Jul 24, 2019
4cf8ce7
Merge remote-tracking branch 'origin/master' into graph
pfeiffer-tim Aug 6, 2019
cb94809
Adding Graph-Polymorphism;
pfeiffer-tim Aug 6, 2019
b46ef6b
little changes;
pfeiffer-tim Aug 6, 2019
8cc735d
changing vertex class names
pfeiffer-tim Aug 7, 2019
4024db4
additional function; deleted stuff...
pfeiffer-tim Aug 7, 2019
aaab4d5
Importing edge-property now working...
pfeiffer-tim Aug 19, 2019
f40cc02
tidy-up some comments...
pfeiffer-tim Aug 20, 2019
73efd01
fixed SegFaults of Edge-Properties; Finally working but slowly...
pfeiffer-tim Aug 21, 2019
85b7da8
tidy up
pfeiffer-tim Aug 26, 2019
4ca0cd2
for testing @TUD computers
pfeiffer-tim Aug 26, 2019
543f649
function name wasn't updated
pfeiffer-tim Aug 26, 2019
7f25368
forgotten stuff...
pfeiffer-tim Aug 26, 2019
fc6bed3
tu dresden pcs directories
pfeiffer-tim Aug 26, 2019
459fa93
testing on TUD PC
pfeiffer-tim Aug 27, 2019
76e41bc
added smart pointer for ldbc-import object
pfeiffer-tim Aug 27, 2019
8e83a2b
added naive bfs-alg.
pfeiffer-tim Aug 27, 2019
e166579
bfs impl.
pfeiffer-tim Aug 27, 2019
ec98ee2
added time measurement for BFS
pfeiffer-tim Aug 28, 2019
1f4673b
graph size calculation (in bytes)
pfeiffer-tim Aug 28, 2019
7b494a7
social_network directory for DB Server
pfeiffer-tim Aug 30, 2019
7239760
directory of sn files - switch
pfeiffer-tim Sep 2, 2019
367d71a
added bfs measurement
pfeiffer-tim Sep 3, 2019
f337f07
added intermediate array before writing to file
pfeiffer-tim Sep 3, 2019
b8d9527
some fixes
pfeiffer-tim Sep 4, 2019
ed5bd3e
hopefully a fix
pfeiffer-tim Sep 4, 2019
a5e20d7
finally edge-property working on server
pfeiffer-tim Sep 4, 2019
6818d80
tidy up
pfeiffer-tim Sep 4, 2019
3cdac57
removed segfault error
pfeiffer-tim Sep 4, 2019
1f1dd85
comment stuff
pfeiffer-tim Sep 4, 2019
74e14b6
tidy -up 2
pfeiffer-tim Sep 4, 2019
64d1986
Merge branch 'graph' of https://github.com/MorphStore/Engine into graph
pfeiffer-tim Sep 4, 2019
9cfc337
some optimizations
pfeiffer-tim Sep 5, 2019
31ffcf4
server-side tidy up
pfeiffer-tim Sep 5, 2019
9c7e70d
code push from db server
pfeiffer-tim Nov 1, 2019
7bf2ffa
cleaned bfs.h
pfeiffer-tim Nov 1, 2019
f9e120f
clean code and comments...
pfeiffer-tim Nov 1, 2019
18fb28e
comment out measurements
pfeiffer-tim Nov 1, 2019
0cd5680
Merge branch 'master' into graph
pfeiffer-tim Nov 1, 2019
d35fec8
Check if vertex files could be found for ldbc import
Mar 22, 2020
956b975
Use regExp to filter valid csv files and getEntityType
Mar 22, 2020
5f427f4
Make entity naming consistent
Mar 22, 2020
e490e15
Replace entity with vertexType in ldbc loader
Mar 23, 2020
faf69cb
Store AdjacencyLists in one map per graph
Mar 24, 2020
b06832e
Differentiate between expected and actual vertex/edge count
Mar 24, 2020
711a7ec
Remove edgeValue_array from csr and allow multiple properties for edges
Mar 24, 2020
a6b169d
Unify vertex constructor
Mar 24, 2020
15e52d7
Restructure graph tests
Mar 29, 2020
52f383b
Merge branch 'master' into graph
Mar 29, 2020
5973ea8
Throw runtime error for single edge addition for CSR graph
Mar 29, 2020
c6cfcdd
Extract bfs test into extra package
Mar 29, 2020
7302cf7
Add bfs tests for a simple graph
Mar 30, 2020
519bf59
Upgrade cpp version to 17
Mar 30, 2020
1ea20d2
Fix edge type bug and only build vertex_type_lookup once
Mar 30, 2020
8822abc
Add vscode to gitignore
Mar 30, 2020
f3520d1
Put vertex properties into seperate container
Mar 30, 2020
ef5826e
Put edge properties in a seperate container
Mar 31, 2020
e28ba83
Allow properties of different types
Mar 31, 2020
30af372
Include static part of ldbc dataset
Mar 31, 2020
07c193e
Add stub for vertex_storage benchmark
Mar 31, 2020
31f7761
Add loading time and use an avg of 5 for the vertex_storage benchmark
Apr 3, 2020
b997b52
Replace hashmap with vector of vectors for storing vertices
Apr 3, 2020
1dc4b5d
Fix a memory leak and also throw on invalid edges at CSR
Apr 6, 2020
d2ce6ef
Move vertex storage logic inside separate "vertices_container" class
Apr 6, 2020
b9043e4
Add link to ldbc schema
Apr 6, 2020
4c520dd
Add variant of vertices container using arrays instead of vectors
Apr 7, 2020
cc28244
Use std::optional in ldbc_importer
Apr 7, 2020
7eba8b9
Correct get_size() functions
Apr 7, 2020
967b3f8
Choose vertices container type at construction time
Apr 10, 2020
af15891
Extend vertices container benchmark
Apr 11, 2020
2570075
Provide a default init for property data_type
Apr 13, 2020
00395a8
Add NDEBUG flag in order to skip asserts in release mode
Apr 14, 2020
708bc46
Fix bfs test as it did not include static part of the graph
May 12, 2020
fd88b41
Use free instead of delete[]
Apr 14, 2020
40f3727
Add method stub for graph compression
Apr 14, 2020
e761a88
Use uncompressed columns in the CSR format
Apr 14, 2020
1df8e32
Delete redundant vertices container classes
Apr 17, 2020
2c3dc0a
Use unique Pointers for csr columns
Apr 17, 2020
c136cad
Move vertex id gen inside of vertices container
Apr 17, 2020
d7ab8e4
Add memory usage to vertices container benchmark
Apr 17, 2020
1c0251b
Init compression of csr columns
Apr 20, 2020
dfa247b
Add valid flag for vertices and edges
Apr 27, 2020
cd7a177
Reserve pointers to vertex arrays
Apr 27, 2020
32638e3
Add EdgesContainer similar to VerticesContainer
Apr 27, 2020
65c2737
Use EdgesContainer in graph formats
Apr 27, 2020
e6afcd9
WIP edges_container_benchmark
Apr 27, 2020
fc06966
Align vertices_container naming
Apr 27, 2020
47fb825
Fix edge ids by allowing explicit id
Apr 27, 2020
e90bad1
Add minor improvements
Apr 27, 2020
6325c1c
Try out DELTA and FOR compression for CSR format
Apr 28, 2020
8fbeb1c
WIP Introduce a template free column_base class
May 4, 2020
623af95
Use column_base in CSR
May 4, 2020
6419e02
Fix simple graph test
May 4, 2020
cf621a2
Enable CSR to work on compressed columns
May 4, 2020
113c1d6
Prepare adjacency list format for compression
May 4, 2020
35e81d4
Convert adjacency vectors into colums aka finalize
May 5, 2020
c2dc471
Assert correct out_degrees after compression
May 5, 2020
0d9ab23
Add virtual deconstructor to `column_base`
May 5, 2020
aa0d7f7
Implement `compress` for AdjacencyList format
May 5, 2020
db4fb05
Use a pointer to map for the adj-lists
May 5, 2020
15a6fa4
Delete intermediate columns in morph_graph_col
May 5, 2020
bcbbf6e
Delete temporary colums in CSR and refactor duplicate get_edge_ids code
May 5, 2020
e8fd68a
Comment and rename minor things
May 5, 2020
3f42887
Remove relative imports
May 5, 2020
3e8174e
Morph adj-list map now in-place and add logging
May 5, 2020
8ad4318
Use "morph" instead of "compress"
May 5, 2020
7e50da8
Add edges container benchmark
May 12, 2020
9054cc4
Add debug flag
May 12, 2020
5369f55
Add compression ratios to CSR statistics
May 12, 2020
5256433
Restrict compressed adj_list by minimum size
May 12, 2020
24fe011
Solve issue for building in release mode
May 12, 2020
251eca2
Move ldbc importer to dedicated sub-folder
May 12, 2020
f94092d
Rename graph_compr_format to str function
May 12, 2020
aec3792
Add functions returning column compr. ratios
May 12, 2020
8ba3104
Extract common functions into a graph benchmark helper
May 12, 2020
8459afa
Add graph compression benchmarks
May 12, 2020
005d904
Format graph files
May 14, 2020
6acc75e
Fix compile errors
May 17, 2020
ca0e1a3
Define ldbc resource dir via cmake
May 17, 2020
2a404fb
Fix debug mode by re-adding the DEBUG flag
May 17, 2020
39c0e20
Fix benchmark helper
May 18, 2020
1f6bb69
Reduce use of min_compr_degree in adj_list format
May 18, 2020
ce8110e
Make min_compression_degree non-static
May 18, 2020
539e41f
Generate edge ids at graph-scope and remove duplicate code
May 19, 2020
7c996bd
Add dynamic_vbp as a graph compression format
May 25, 2020
4b4dd33
Correct column-ratio by not counting empty adjacency lists
May 25, 2020
406e545
Set min-compr-degree based on blocksize of compression format
May 25, 2020
c3e82c4
Benchmark full_iterate for adj-list graph
May 25, 2020
3292613
Fix compression benchmark output
May 25, 2020
ab6835c
Replace hard coded block-sizes
May 29, 2020
137ce36
Use format blocksize as min_compr_degree by default
May 29, 2020
6800fc0
Start with `morph_saving_offsets`
May 31, 2020
3c017aa
Check if SSE was defined
May 31, 2020
582aa5a
Implement `morph_saving_offsets`
Jun 1, 2020
58a4f35
Set reasonable LDBC_DIR default value
Jun 2, 2020
b250e4a
Remove one evil `const`
Jun 2, 2020
a02107a
Add template free column_with_blockoffsets_base
Jun 2, 2020
ab94a14
Put morph_graph_col into seperate header
Jun 2, 2020
17a996f
WIP add template free morph_saving_offsets to use for csr columns
Jun 2, 2020
52dbb5c
Improve morph_saving_offsets_test
Jun 5, 2020
fe9967b
Add test for morphing column blocks and fix bug regarding last block
Jun 5, 2020
0e754ff
Fix offset last block if it is uncompressed
Jun 5, 2020
c10ad1d
Fix bug decompressing column_with_blockoffsets at once
Jun 8, 2020
be7abcf
Add decompress_column_block function
Jun 8, 2020
be9e511
Use decompress_column_block in csr format
Jun 9, 2020
d64d01c
Cache decompressed column block
Jun 9, 2020
4a4ea87
Cache edgeId_column in CSR + bug fix for getting edge-ids
Jun 9, 2020
853db0d
Add instructions for LDBC_DIR flag
Jun 12, 2020
68b544a
Fix delete error in AdjacencyList format and correct size_of_graph func
Jun 12, 2020
0b07069
Assert offsets in csr make sense
Jun 12, 2020
252a2b2
Fix title of benchmark
Jun 12, 2020
0e96431
Move degree measurement into a seperate operator and use shared ptr
Jun 12, 2020
b124286
Do not save graph in BFS class as volatile graphs dont work then
Jun 12, 2020
bcec970
Add bfs benchmark
Jun 12, 2020
61d9938
Add naive page rank
Jun 14, 2020
a7b787e
Add tests for page rank
Jun 14, 2020
448cea4
Add page-rank benchmark
Jun 14, 2020
6639a51
Comment more code
Jun 14, 2020
974c756
Fix measurement unit description in benchmark
Jun 15, 2020
11dedfb
Fix documented file names
Jun 15, 2020
aa1a4bf
Merge remote-tracking branch 'origin/master' into graph
Jun 15, 2020
4943d76
Add a getting started section for the graph module
Jun 15, 2020
4ce2b7e
Comment new morph operators
Jun 16, 2020
0c46f8f
Allow different compression formats for the different csr columns
Jun 16, 2020
f031f63
Benchmark partial csr compressions
Jun 16, 2020
6f731e5
Allow fallback to string if data-type could not be found in schema
Jun 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ recentMorphStoreProjectConf.log
Dockerfile
.DS_Store
doc/doxygen/latex
doc/doxygen/html
doc/doxygen/html
.vscode/
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required( VERSION 3.10 )
project( MorphStore )

set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_STANDARD 17 )

macro(morph_flag)
add_definitions(${ARGN})
Expand All @@ -28,9 +28,11 @@ set( LOG_FILE "recentMorphStoreProjectConf.log" )

IF(CMAKE_BUILD_TYPE MATCHES Debug)
morph_flag(-g)
morph_flag(-DDEBUG)
message(STATUS "MorphStore is configured in DEBUG mode.")
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
morph_flag(-O2)
morph_flag(-DNDEBUG)
message(STATUS "MorphStore is configured in RELEASE mode.")
ELSEIF(CMAKE_BUILD_TYPE MATCHES HighPerf)
morph_flag(-O3)
Expand Down Expand Up @@ -93,6 +95,10 @@ ENDIF(CODROID)
# remove build type to allow for custom flag handling
set(CMAKE_BUILD_TYPE "")

# add resource directory for ldbc graph
# (see https://github.com/ldbc/ldbc_snb_datagen for further instructions)
morph_flag(-DLDBC_DIR="$ENV{HOME}/ldbc_snb_datagen/social_network/")

# general compiler settings, meant for all subdirectories and tests
morph_flag(-Werror)
morph_flag(-pedantic)
Expand Down
24 changes: 22 additions & 2 deletions doc/doxygen/pages/tutorials/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Ensure that you have the following tools installed before trying to build:
- g++ >= version 8.2
- cmake >= version 3.10

Older versions may not build all test cases. Note that C++14 is necessary.
Older versions may not build all test cases. Note that C++17 is necessary.


To facilitate building and testing MorphStore, there is a script <i>build.sh</i> in the root folder.
Expand All @@ -42,9 +42,29 @@ build/src/examples/example_query
~~~

This builds some example queries in debug mode and runs them. The source code of these queries can be found in the folder src/examples.
They are runnig in scalar mode. Thus, every system providing C++14 support should be able to build and run them regardless of any (not)
They are runnig in scalar mode. Thus, every system providing C++17 support should be able to build and run them regardless of any (not)
available vector extensions.


The Graph Module
======================

The graph module mainly contains the two different graph storage formats `Compressed Sparse Row (CSR)` and `Adjacency-List`, which differ in their representation of the graph topology .
These underlying graph model is a multi-graph, with properties for vertices and edges as well as types for both.
The model is very similar to the Property-Graph model, except that vertices can only have one type (instead of multiple labels).

The columns describing the graph topology can be compressed using formats from the MorphStore.
Besides there exists simple implementations of the graph algorithms `breadth-first search (bfs)` and `PageRank`.


To run all the test and micro-benchmarks, a LDBC graph has to be generated.
Instructions of how to generate the graph, can be found at `https://github.com/ldbc/ldbc_snb_datagen`.
By default the ldbc graph is expected to be at `"$HOME/ldbc_snb_datagen/social_network/"`.
This can be changed at `/Morphstore/Engine/CMakeLists.txt`.




Test Vector Extensions
======================

Expand Down
95 changes: 95 additions & 0 deletions include/core/morphing/decompress_column_block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**********************************************************************************************
* Copyright (C) 2020 by MorphStore-Team *
* *
* This file is part of MorphStore - a compression aware vectorized column store. *
* *
* This program is free software: you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software Foundation, *
* either version 3 of the License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with this program. *
* If not, see <http://www.gnu.org/licenses/>. *
**********************************************************************************************/

/**
* @file decompress_column_block.h
* @brief Decompressing single blocks of a column based on column_with_blockoffsets.
*/

#ifndef MORPHSTORE_CORE_MORPHING_DECOMPRESS_COLUMN_BLOCK_H
#define MORPHSTORE_CORE_MORPHING_DECOMPRESS_COLUMN_BLOCK_H

#include <core/morphing/morph_batch.h>
#include <core/storage/column.h>
#include <core/storage/column_with_blockoffsets.h>

#include <assert.h>

namespace morphstore {

/**
* @brief Decompressing a range column blocks (inclusive range)
*
* @param inCol The column with block-offsets
* @param start index of blocks to be decompressed
* @param end index of blocks to be decompressed
* @return Specified blocks uncompressed in a new column
*/
template <class ve, class compr_f>
const column<uncompr_f> *decompress_column_blocks(column_with_blockoffsets<compr_f> *inCol, uint64_t start,
uint64_t end) {
static_assert(compr_f::m_BlockSize != 1, "Decompressing column blocks of size 1 is not allowed");

auto block_size = compr_f::m_BlockSize;
auto block_count = inCol->get_block_offsets()->size();
auto inCol_value_count = inCol->get_column()->get_count_values();

// validating range
assert(start <= end);
assert(start < block_count);
assert(end < block_count);

bool last_block_uncompressed = !inCol->last_block_compressed();
bool last_block_included = end == (block_count - 1);

// pessimistic value_count (assuming all blocks are complete)
auto value_count = (end - start + 1) * block_size;

if (last_block_included && last_block_uncompressed) {
// correcting value_count estimation
value_count -= block_size - inCol_value_count % block_size;
}

// TODO: should actually be base_t?
auto alloc_size = value_count * sizeof(uint64_t);

auto decompr_col_blocks = new column<uncompr_f>(alloc_size);
decompr_col_blocks->set_meta_data(value_count, alloc_size);
uint8_t *out8 = decompr_col_blocks->get_data();

for (uint64_t block = start; block <= end; block++) {
const uint8_t *block_offset = inCol->get_block_offset(block);

if (block == end && last_block_included && last_block_uncompressed) {
// handle uncompressed part
morph_batch<ve, uncompr_f, uncompr_f>(block_offset, out8, inCol_value_count % block_size);
} else {
morph_batch<ve, uncompr_f, compr_f>(block_offset, out8, block_size);
}
}

return decompr_col_blocks;
}

template <class ve, class compr_f>
const column<uncompr_f> *decompress_column_block(column_with_blockoffsets<compr_f> *inCol, uint64_t block_index) {
return decompress_column_blocks<ve, compr_f>(inCol, block_index, block_index);
}

} // namespace morphstore

#endif // MORPHSTORE_CORE_MORPHING_DECOMPRESS_COLUMN_BLOCK_H
135 changes: 135 additions & 0 deletions include/core/morphing/graph/morph_graph_col.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**********************************************************************************************
* Copyright (C) 2020 by MorphStore-Team *
* *
* This file is part of MorphStore - a compression aware vectorized column store. *
* *
* This program is free software: you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software Foundation, *
* either version 3 of the License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with this program. *
* If not, see <http://www.gnu.org/licenses/>. *
**********************************************************************************************/

/**
* @file morph_graph_col.h
* @brief helper for morphing graph columns (template-free columns). Basically need to cast to template column as it
* cannot be derieved
* @todo Remove this helper and make graph formats accept templates (can use normal morph() then)
*/

#ifndef MORPHSTORE_GRAPH_MORPH_GRAPH_COL_H
#define MORPHSTORE_GRAPH_MORPH_GRAPH_COL_H

#include <core/storage/graph/graph_compr_format.h>
#include <core/storage/column.h>
#include <core/morphing/morph.h>

#include <memory>

namespace morphstore {
using column_uncompr = column<uncompr_f>;
using column_dyn_vbp = column<default_vbp>;
using column_delta = column<default_delta>;
using column_for = column<default_for>;

// casting the column to the actual column type before morphing (as compiler could not derive it)
// delete_old_col -> delete input column after morphing (if the result is not the input column)
const column_base *morph_graph_col(const column_base *column, const GraphCompressionFormat src_f,
const GraphCompressionFormat trg_f, bool delete_in_col = false) {
if (src_f == trg_f) {
return column;
}

const column_base *result = column;

switch (src_f) {
case GraphCompressionFormat::UNCOMPRESSED: {
const column_uncompr *old_col = dynamic_cast<const column_uncompr *>(column);
switch (trg_f) {
case GraphCompressionFormat::DELTA:
result = morph<ve, default_delta, uncompr_f>(old_col);
break;
case GraphCompressionFormat::FOR:
result = morph<ve, default_for, uncompr_f>(old_col);
break;
case GraphCompressionFormat::DYNAMIC_VBP:
result = morph<ve, default_vbp, uncompr_f>(old_col);
break;
case GraphCompressionFormat::UNCOMPRESSED:
// handled by src_f == trg_f
break;
}
break;
}
case GraphCompressionFormat::DELTA: {
if (trg_f == GraphCompressionFormat::UNCOMPRESSED) {
const column_delta *old_col = dynamic_cast<const column_delta *>(column);
result = morph<ve, uncompr_f, default_delta>(old_col);
} else {
// as direct morphing is not yet supported .. go via decompressing first
auto uncompr_col = morph_graph_col(column, src_f, GraphCompressionFormat::UNCOMPRESSED, false);
result = morph_graph_col(uncompr_col, GraphCompressionFormat::UNCOMPRESSED, trg_f, true);
}
break;
}
case GraphCompressionFormat::FOR: {
if (trg_f == GraphCompressionFormat::UNCOMPRESSED) {
const column_for *old_col = dynamic_cast<const column_for *>(column);
result = morph<ve, uncompr_f, default_for>(old_col);
} else {
// as direct morphing is not yet supported .. go via decompressing first
auto uncompr_col = morph_graph_col(column, src_f, GraphCompressionFormat::UNCOMPRESSED, false);
result = morph_graph_col(uncompr_col, GraphCompressionFormat::UNCOMPRESSED, trg_f, true);
}
break;
}
case GraphCompressionFormat::DYNAMIC_VBP: {
if (trg_f == GraphCompressionFormat::UNCOMPRESSED) {
const column_dyn_vbp *old_col = dynamic_cast<const column_dyn_vbp *>(column);
result = morph<ve, uncompr_f, default_vbp>(old_col);
} else {
// as direct morphing is not yet supported .. go via decompressing first
auto uncompr_col = morph_graph_col(column, src_f, GraphCompressionFormat::UNCOMPRESSED, false);
// delete_in_col = true as temporary uncompr_col should always be deleted
result = morph_graph_col(uncompr_col, GraphCompressionFormat::UNCOMPRESSED, trg_f, true);
}
break;
}
}

// free input column if possible
if (result != column && delete_in_col) {
delete column;
}

if (result == nullptr) {
throw std::runtime_error("Did not handle src: " + graph_compr_f_to_string(src_f) +
" trg: " + graph_compr_f_to_string(trg_f));
}

return result;
}

const column_uncompr *decompress_graph_col(const column_base *column, const GraphCompressionFormat src_f) {
return static_cast<const column_uncompr *>(
morph_graph_col(column, src_f, GraphCompressionFormat::UNCOMPRESSED, false));
}

double compression_ratio(const column_base *col, GraphCompressionFormat col_format) {
auto uncompr_col = decompress_graph_col(col, col_format);
auto ratio = uncompr_col->get_size_used_byte() / (double)col->get_size_used_byte();

if (col != uncompr_col) {
delete uncompr_col;
}

return ratio;
}
} // namespace morphstore

#endif // MORPHSTORE_GRAPH_MORPH_GRAPH_COL_H
Loading