Skip to content
Merged
7 changes: 4 additions & 3 deletions benchmark/bench_accuracy_over_rowgroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ void bench_accuracy_over_rowgroups() {
}

// Run the benchmark
auto size = benchmarker.bench(file_path, thread_specific_fls_dir_path);
const auto& footer_up = benchmarker.GetTableDescriptor(thread_specific_fls_dir_path);
const auto& first_rowgroup_descriptor = footer_up->m_rowgroup_descriptors[0];
auto size = benchmarker.bench(file_path, thread_specific_fls_dir_path);
const auto& table_descriptor_handle = benchmarker.GetTableDescriptor(thread_specific_fls_dir_path);
const auto& first_rowgroup_descriptor =
table_descriptor_handle->Unpack()->m_rowgroup_descriptors[0];

{
// Lock and store the main result
Expand Down
5 changes: 3 additions & 2 deletions benchmark/bench_compression_ratio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ void run_compression_ratio_benchmark(const BenchmarkCase& benchmark_case) {
main_results.emplace_back(table_name, fls_size, csv_size);
}

const auto& tbl_desc = benchmarker.GetTableDescriptor(fls_dir);
const auto& rg_desc = tbl_desc->m_rowgroup_descriptors[0];
const auto& table_descriptor_handle = benchmarker.GetTableDescriptor(fls_dir);
const auto& table_descriptor_object = table_descriptor_handle->Unpack();
const auto& rg_desc = table_descriptor_object->m_rowgroup_descriptors[0];
{
std::lock_guard<std::mutex> lk(results_mutex);
for (const auto& col : rg_desc->m_column_descriptors) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/bench_compression_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CompressionTimeBenchmarker : public CompressionRatioBenchmarker {

auto start = std::chrono::high_resolution_clock::now();
for (n_t repetition_idx {0}; repetition_idx < n_repetitions; repetition_idx++) {
for (n_t vec_idx {0}; vec_idx < first_rowgroup_reader->get_descriptor().m_n_vec; vec_idx++) {
for (n_t vec_idx {0}; vec_idx < first_rowgroup_reader->get_descriptor().m_n_vec(); vec_idx++) {
first_rowgroup_reader->get_chunk(vec_idx);
};
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/bench_decompression_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DecompressionTimeBenchmarker : public CompressionRatioBenchmarker {

auto start = std::chrono::high_resolution_clock::now();
for (n_t repetition_idx {0}; repetition_idx < n_repetitions; repetition_idx++) {
for (n_t vec_idx {0}; vec_idx < first_rowgroup_reader->get_descriptor().m_n_vec; vec_idx++) {
for (n_t vec_idx {0}; vec_idx < first_rowgroup_reader->get_descriptor().m_n_vec(); vec_idx++) {
first_rowgroup_reader->get_chunk(vec_idx);
};
}
Expand Down
3 changes: 0 additions & 3 deletions benchmark/bench_random_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class DecompressionTimeBenchmarker : public CompressionRatioBenchmarker {
auto fls_reader = conn.reset().read_fls(dir_path / "data.fls");
auto first_rowgroup_reader = fls_reader->get_rowgroup_reader(0);

const auto rowgroup_up = std::make_unique<Rowgroup>(first_rowgroup_reader->get_descriptor(), conn);
// RandomAccessor random_accessor {*rowgroup_up};

auto start = std::chrono::high_resolution_clock::now();
for (n_t repetition_idx {0}; repetition_idx < n_repetitions; repetition_idx++) {
[[maybe_unused]] auto& expressions = first_rowgroup_reader->get_chunk(0);
Expand Down
9 changes: 5 additions & 4 deletions benchmark/bench_sample_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ void bench_sampling() {

auto size =
benchmarker.bench_with_sample_size(file_path, thread_specific_fls_dir_path, sample_size);
const auto& table_descriptor = benchmarker.GetTableDescriptor(thread_specific_fls_dir_path);
const auto& first_rowgroup_descriptor = table_descriptor->m_rowgroup_descriptors[0];
const auto& table_descriptor_handle = benchmarker.GetTableDescriptor(thread_specific_fls_dir_path);
const auto& table_descriptor_object = table_descriptor_handle->Unpack();
const auto& first_rg_desc = table_descriptor_object->m_rowgroup_descriptors[0];

// Store the main result (thread-safe)
{
Expand All @@ -76,9 +77,9 @@ void bench_sampling() {
// Store the detailed results (thread-safe)
{
std::lock_guard<std::mutex> lock(results_mutex);
for (const auto& column_descriptor : first_rowgroup_descriptor->m_column_descriptors) {
for (const auto& column_descriptor : first_rg_desc->m_column_descriptors) {
double bpt = static_cast<double>(column_descriptor->total_size) /
(static_cast<double>(first_rowgroup_descriptor->m_n_vec * CFG::VEC_SZ));
(static_cast<double>(first_rg_desc->m_n_vec * CFG::VEC_SZ));
double Bpt = bpt / 8;

detailed_results.emplace_back(table_name,
Expand Down
8 changes: 4 additions & 4 deletions benchmark/include/benchmarker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CompressionRatioBenchmarker {
}

// Method to get the footer for the thread-specific directory
[[nodiscard]] up<TableDescriptorT> GetTableDescriptor(const path& thread_specific_fls_dir_path) const {
[[nodiscard]] up<TableDescriptorHandle> GetTableDescriptor(const path& thread_specific_fls_dir_path) const {
return make_table_descriptor(thread_specific_fls_dir_path / TABLE_DESCRIPTOR_FILE_NAME);
}

Expand Down Expand Up @@ -133,12 +133,12 @@ class CompressionRatioBenchmarker {
Write(table_path, thread_specific_fls_dir_path);
vector<OperatorToken> result;
auto table_descriptor = GetTableDescriptor(thread_specific_fls_dir_path);
auto& rowgroup_descriptor = table_descriptor->m_rowgroup_descriptors[0];
auto& rowgroup_descriptor = *(*table_descriptor->Get()->m_rowgroup_descriptors())[0];

// Store the detailed results (thread-safe)
{
for (const auto& column_descriptor : rowgroup_descriptor->m_column_descriptors) {
result.emplace_back(column_descriptor->encoding_rpn->operator_tokens[0]);
for (const auto& column_descriptor : *rowgroup_descriptor.m_column_descriptors()) {
result.emplace_back((*column_descriptor->encoding_rpn()->operator_tokens())[0]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions benchmark/micro_benchmark_decompression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class DecompressionTimeBenchmarker : public CompressionRatioBenchmarker {

auto start = benchmark::cycleclock::Now();
for (n_t repetition_idx {0}; repetition_idx < n_repetitions; repetition_idx++) {
for (n_t vec_idx {0}; vec_idx < rowgroup_reader->get_descriptor().m_n_vec; vec_idx++) {
for (n_t vec_idx {0}; vec_idx < rowgroup_reader->get_descriptor().m_n_vec(); vec_idx++) {
rowgroup_reader->get_chunk(vec_idx);
};
}
const auto end = benchmark::cycleclock::Now();
auto elapsed_cycles = end - start;

return static_cast<double>(elapsed_cycles) /
(static_cast<double>(rowgroup_reader->get_descriptor().m_n_vec * CFG::VEC_SZ * n_repetitions));
(static_cast<double>(rowgroup_reader->get_descriptor().m_n_vec() * CFG::VEC_SZ * n_repetitions));
}

public:
Expand Down
12 changes: 8 additions & 4 deletions mk/format.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@ FMT_CMD := python3 scripts/run-clang-format.py \
$(EXCLUDES)


.PHONY: format clang-format format-check rust-format-check
.PHONY: format clang-format format-check rust-format-check check-docker

clang-format:
# check if docker daemon is running
check-docker:
@docker info > /dev/null 2>&1 || \
{ $(call echo_error,❌ Docker is not running. Please start Docker and retry.); exit 1; }

clang-format: check-docker
$(call echo_start,Running clang-format with Docker…)
$(DOCKER) $(UBUNTU_IMAGE) \
bash -c "apt update && apt install -y python3 clang-format-14 && \
ln -s /usr/bin/clang-format-14 /usr/bin/clang-format && \
$(FMT_CMD) -i"
$(call echo_done,clang-format run complete.)

format-check:
format-check: check-docker
$(call echo_start,Checking formatting…)
$(DOCKER) $(UBUNTU_IMAGE) \
bash -c "apt update && apt install -y clang-format-14 python3 && \
ln -s /usr/bin/clang-format-14 /usr/bin/clang-format && \
$(FMT_CMD)"
$(call echo_done,Formatting check complete.)

10 changes: 8 additions & 2 deletions mk/preamble.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ COLOR ?= 1
ifeq ($(COLOR),1)
_Y := $(shell tput setaf 3 2>/dev/null || printf '\033[0;33m')
_G := $(shell tput setaf 2 2>/dev/null || printf '\033[0;32m')
_E := $(shell tput setaf 1 2>/dev/null || printf '\033[0;31m')
_R := $(shell tput sgr0 2>/dev/null || printf '\033[0m')
else
_Y :=
_G :=
_E :=
_R :=
endif

define echo_done
@printf '%s%s%s\n' '$(_G)' '$(1)' '$(_R)'
printf '%s%s%s\n' '$(_G)' '$(1)' '$(_R)'
endef

define echo_start
@printf '%s%s%s\n' '$(_Y)' '$(1)' '$(_R)'
printf '%s%s%s\n' '$(_Y)' '$(1)' '$(_R)'
endef

define echo_error
printf '%s%s%s\n' '$(_E)' '$(1)' '$(_R)'
endef

# ── Root paths ──────────────────────────────────────────
Expand Down
33 changes: 19 additions & 14 deletions src/expression/cross_rle_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ void enc_cross_rle_opr<fls_string_t>::MoveSegments(vector<up<Segment>>& segments
* dec_cross_rle_opr
\*--------------------------------------------------------------------------------------------------------------------*/
template <typename PT>
dec_cross_rle_opr<PT>::dec_cross_rle_opr(PhysicalExpr& physical_expr,
dec_cross_rle_opr<PT>::dec_cross_rle_opr(PhysicalExpr& /*physical_expr*/,
const ColumnView& column_view,
InterpreterState& state)
: values_segment(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 1]))
, lengths_segment(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 0])) {
state.cur_operand = state.cur_operand - 2;
: values_segment(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 1)])))
, lengths_segment(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 0)]))) {
state.cur_operand -= 2;

values_segment.PointTo(0);
lengths_segment.PointTo(0);
Expand Down Expand Up @@ -227,16 +229,19 @@ template struct dec_cross_rle_opr<u16_pt>;
template struct dec_cross_rle_opr<u32_pt>;
template struct dec_cross_rle_opr<u64_pt>;

dec_cross_rle_opr<fls_string_t>::dec_cross_rle_opr(PhysicalExpr& physical_expr,
dec_cross_rle_opr<fls_string_t>::dec_cross_rle_opr(PhysicalExpr& /*physical_expr*/,
const ColumnView& column_view,
InterpreterState& state)
: values_bytes_seg(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 2]))
, values_offset_seg(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 1]))
, lengths_segment(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 0])) {
state.cur_operand = state.cur_operand - 3;
: values_bytes_seg(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 2)])))
, values_offset_seg(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 1)])))
, lengths_segment(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 0)]))) {
state.cur_operand -= 3;

values_bytes_seg.PointTo(0);
values_offset_seg.PointTo(0);
Expand Down
1 change: 0 additions & 1 deletion src/expression/data_parallelize_patch_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "fls/expression/decoding_operator.hpp"
#include "fls/expression/interpreter.hpp"
#include "fls/expression/physical_expression.hpp"
#include "fls/reader/column_view.hpp"
#include "fls/std/variant.hpp"
#include "fls/table/rowgroup.hpp"
#include <cstring>
Expand Down
40 changes: 21 additions & 19 deletions src/expression/decoding_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ namespace fastlanes {
template <typename PT>
dec_unffor_opr<PT>::dec_unffor_opr(const ColumnView& column_view, InterpreterState& state)
: bitpacked_segment_view(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 2]))
, bw_segment_view(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 1]))
column_view.GetSegment((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 2)]))
, bw_segment_view(column_view.GetSegment((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 1)]))
, base_segment_view(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 0])) {
state.cur_operand = state.cur_operand - 3;
column_view.GetSegment((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 0)])) {
state.cur_operand -= 3;
}

template <typename PT>
Expand Down Expand Up @@ -93,15 +95,15 @@ template struct dec_uncompressed_opr<str_pt>;
\*--------------------------------------------------------------------------------------------------------------------*/
template <typename PT>
dec_constant_opr<PT>::dec_constant_opr(const ColumnView& column_view) {
FLS_ASSERT_E(column_view.column_descriptor.max->binary_data.size(), sizeof(PT));
value = *reinterpret_cast<const PT*>(column_view.column_descriptor.max->binary_data.data());
FLS_ASSERT_E(column_view.column_descriptor.max()->binary_data()->size(), sizeof(PT));
value = *reinterpret_cast<const PT*>(column_view.column_descriptor.max()->binary_data()->data());
}

dec_constant_str_opr::dec_constant_str_opr(const ColumnView& column_view) {
bytes.resize(column_view.column_descriptor.max->binary_data.size());
bytes.resize(column_view.column_descriptor.max()->binary_data()->size());
memcpy(bytes.data(),
column_view.column_descriptor.max->binary_data.data(),
column_view.column_descriptor.max->binary_data.size());
column_view.column_descriptor.max()->binary_data()->data(),
column_view.column_descriptor.max()->binary_data()->size());
};

template struct dec_constant_opr<i64_pt>;
Expand All @@ -118,10 +120,10 @@ template struct dec_constant_opr<str_pt>;
/*--------------------------------------------------------------------------------------------------------------------*\
* dec_fls_str_uncompressed_opr
\*--------------------------------------------------------------------------------------------------------------------*/
dec_fls_str_uncompressed_opr::dec_fls_str_uncompressed_opr(const ColumnView& column_view, const RPNT& rpn)
: byte_arr_segment(column_view.GetSegment(rpn.operand_tokens[0]))
, length_segment(column_view.GetSegment(rpn.operand_tokens[1])) {
FLS_ASSERT_EQUALITY(rpn.operand_tokens.size(), 2);
dec_fls_str_uncompressed_opr::dec_fls_str_uncompressed_opr(const ColumnView& column_view, const RPN& rpn)
: byte_arr_segment(column_view.GetSegment((*rpn.operand_tokens())[0]))
, length_segment(column_view.GetSegment((*rpn.operand_tokens())[1])) {
FLS_ASSERT_EQUALITY(rpn.operand_tokens()->size(), 2);
}

void dec_fls_str_uncompressed_opr::PointTo(n_t vec_idx) {
Expand All @@ -140,18 +142,18 @@ len_t* dec_fls_str_uncompressed_opr::Length() const {
/*--------------------------------------------------------------------------------------------------------------------*\
* dec_struct_opr
\*--------------------------------------------------------------------------------------------------------------------*/
dec_struct_opr::dec_struct_opr(const ColumnDescriptorT& column_descriptor,
const ColumnView& column_view,
dec_struct_opr::dec_struct_opr(const ColumnDescriptor& column_descriptor,
const ColumnView& column_view,
InterpreterState&,
RowgroupReader& reader) {
auto& children = column_descriptor.children;
auto& children = *column_descriptor.children();

for (n_t children_idx {0}; children_idx < children.size(); ++children_idx) {
auto& child_column_descriptor = children[children_idx];
auto& child_column_descriptor = *children[static_cast<uint32_t>(children_idx)];

InterpreterState state;
auto child_physical_expr =
make_decoding_expression(*child_column_descriptor, column_view.children[children_idx], reader, state);
make_decoding_expression(child_column_descriptor, column_view.children[children_idx], reader, state);

internal_exprs.push_back(child_physical_expr);
}
Expand Down
8 changes: 4 additions & 4 deletions src/expression/dict_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ template <typename KEY_PT, typename INDEX_PT>
dec_dict_opr<KEY_PT, INDEX_PT>::dec_dict_opr(const PhysicalExpr& physical_expr,
const ColumnView& column_view,
InterpreterState& state)
: key_segment_view(
column_view.GetSegment(column_view.column_descriptor.encoding_rpn->operand_tokens[state.cur_operand - 0]))
: key_segment_view(column_view.GetSegment(
static_cast<uint32_t>((*column_view.column_descriptor.encoding_rpn()
->operand_tokens())[static_cast<uint32_t>(state.cur_operand - 0)])))
, index_arr(nullptr) {

state.cur_operand = state.cur_operand - 1;
state.cur_operand -= 1;
visit(DictExprVisitor<INDEX_PT> {index_arr}, physical_expr.operators[0]);
}

Expand Down
Loading
Loading