forked from duckdb/duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VERY MUCH WIP: write empty validity. it works, but it's for sure not …
…what we want to do
- Loading branch information
Showing
10 changed files
with
158 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#pragma once | ||
|
||
#include "duckdb/function/compression_function.hpp" | ||
#include "duckdb/storage/table/column_data.hpp" | ||
#include "duckdb/storage/table/scan_state.hpp" | ||
#include "duckdb/storage/table/column_data_checkpointer.hpp" | ||
|
||
namespace duckdb { | ||
|
||
class EmptyValidityCompression { | ||
public: | ||
struct EmptyValidityAnalyzeState : public AnalyzeState { | ||
explicit EmptyValidityAnalyzeState(const CompressionInfo &info) : AnalyzeState(info) { | ||
} | ||
idx_t count = 0; | ||
}; | ||
struct EmptyValidityCompressionState : public CompressionState { | ||
explicit EmptyValidityCompressionState(const CompressionInfo &info) : CompressionState(info) { | ||
} | ||
}; | ||
struct EmptyValiditySegmentScanState : public SegmentScanState { | ||
EmptyValiditySegmentScanState() { | ||
} | ||
}; | ||
|
||
public: | ||
static unique_ptr<CompressionFunction> CreateFunction() { | ||
return make_uniq<CompressionFunction>(CompressionType::COMPRESSION_AUTO, PhysicalType::BIT, InitAnalyze, | ||
Analyze, FinalAnalyze, InitCompression, Compress, FinalizeCompress, | ||
InitScan, Scan, ScanPartial, FetchRow, Skip, InitSegment); | ||
} | ||
|
||
public: | ||
static unique_ptr<AnalyzeState> InitAnalyze(ColumnData &col_data, PhysicalType type) { | ||
CompressionInfo info(col_data.GetBlockManager().GetBlockSize()); | ||
return make_uniq<EmptyValidityAnalyzeState>(info); | ||
} | ||
static bool Analyze(AnalyzeState &state_p, Vector &input, idx_t count) { | ||
auto &state = state_p.Cast<EmptyValidityAnalyzeState>(); | ||
state.count += count; | ||
return true; | ||
} | ||
static idx_t FinalAnalyze(AnalyzeState &state_p) { | ||
return 0; | ||
} | ||
static unique_ptr<CompressionState> InitCompression(ColumnDataCheckpointer &checkpointer, | ||
unique_ptr<AnalyzeState> state_p) { | ||
auto res = make_uniq<EmptyValidityCompressionState>(state_p->info); | ||
auto &state = state_p->Cast<EmptyValidityAnalyzeState>(); | ||
|
||
auto &db = checkpointer.GetDatabase(); | ||
auto &type = checkpointer.GetType(); | ||
|
||
auto function = CreateFunction(); | ||
auto &info = state.info; | ||
auto compressed_segment = | ||
ColumnSegment::CreateTransientSegment(db, *function, type, 0, info.GetBlockSize(), info.GetBlockSize()); | ||
compressed_segment->count = state.count; | ||
|
||
auto &buffer_manager = BufferManager::GetBufferManager(checkpointer.GetDatabase()); | ||
auto handle = buffer_manager.Pin(compressed_segment->block); | ||
|
||
auto &checkpointer_state = checkpointer.GetCheckpointState(); | ||
checkpointer_state.FlushSegment(std::move(compressed_segment), std::move(handle), 0); | ||
|
||
return res; | ||
} | ||
static void Compress(CompressionState &state_p, Vector &scan_vector, idx_t count) { | ||
return; | ||
} | ||
static void FinalizeCompress(CompressionState &state_p) { | ||
return; | ||
} | ||
static unique_ptr<SegmentScanState> InitScan(ColumnSegment &segment) { | ||
return make_uniq<EmptyValiditySegmentScanState>(); | ||
} | ||
static void ScanPartial(ColumnSegment &segment, ColumnScanState &state, idx_t scan_count, Vector &result, | ||
idx_t result_offset) { | ||
return; | ||
} | ||
static void Scan(ColumnSegment &segment, ColumnScanState &state, idx_t scan_count, Vector &result) { | ||
return; | ||
} | ||
static void FetchRow(ColumnSegment &segment, ColumnFetchState &state, row_t row_id, Vector &result, | ||
idx_t result_idx) { | ||
return; | ||
} | ||
static void Skip(ColumnSegment &segment, ColumnScanState &state, idx_t skip_count) { | ||
return; | ||
} | ||
static unique_ptr<CompressedSegmentState> InitSegment(ColumnSegment &segment, block_id_t block_id, | ||
optional_ptr<ColumnSegmentState> segment_state) { | ||
return nullptr; | ||
} | ||
}; | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters