Skip to content

Commit

Permalink
converter -> reader
Browse files Browse the repository at this point in the history
  • Loading branch information
grammaright committed Jul 25, 2024
1 parent 4d43193 commit a888e78
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
28 changes: 14 additions & 14 deletions src/arr2tbl_converter.cpp → src/array_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

#include "arr2tbl_converter.hpp"
#include "array_reader.hpp"

namespace duckdb {
uint64_t ArrayToTableConverter::_Put2DData(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
uint64_t ArrayReader::_Put2DData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
uint64_t size, DataChunk &output) {
auto &data = bind_data->Cast<ArrayReadData>();

auto total_remains = size - gstate.cell_idx;
Expand Down Expand Up @@ -40,7 +40,7 @@ uint64_t ArrayToTableConverter::_Put2DData(
return local_remains;
}

uint64_t ArrayToTableConverter::_Put2DDataNoPrune(
uint64_t ArrayReader::_Put2DDataNoPrune(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
auto &data = bind_data->Cast<ArrayReadData>();
Expand Down Expand Up @@ -75,7 +75,7 @@ uint64_t ArrayToTableConverter::_Put2DDataNoPrune(
return local_remains;
}

uint64_t ArrayToTableConverter::_Put2DDataNoPruneAndProjection(
uint64_t ArrayReader::_Put2DDataNoPruneAndProjection(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
auto &data = bind_data->Cast<ArrayReadData>();
Expand Down Expand Up @@ -110,9 +110,9 @@ uint64_t ArrayToTableConverter::_Put2DDataNoPruneAndProjection(
return local_remains;
}

uint64_t ArrayToTableConverter::_Put1DData(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
uint64_t ArrayReader::_Put1DData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
uint64_t size, DataChunk &output) {
auto total_remains = size - gstate.cell_idx;
auto local_remains =
std::min((uint64_t)STANDARD_VECTOR_SIZE, total_remains);
Expand All @@ -137,7 +137,7 @@ uint64_t ArrayToTableConverter::_Put1DData(
return local_remains;
}

uint64_t ArrayToTableConverter::_Put1DDataNoPrune(
uint64_t ArrayReader::_Put1DDataNoPrune(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
auto total_remains = size - gstate.cell_idx;
Expand All @@ -164,7 +164,7 @@ uint64_t ArrayToTableConverter::_Put1DDataNoPrune(
return local_remains;
}

uint64_t ArrayToTableConverter::_Put1DDataNoPruneAndProjection(
uint64_t ArrayReader::_Put1DDataNoPruneAndProjection(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
auto total_remains = size - gstate.cell_idx;
Expand Down Expand Up @@ -196,9 +196,9 @@ uint64_t ArrayToTableConverter::_Put1DDataNoPruneAndProjection(
return local_remains;
}

uint64_t ArrayToTableConverter::PutData(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t size, DataChunk &output) {
uint64_t ArrayReader::PutData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
uint64_t size, DataChunk &output) {
auto &data = bind_data->Cast<ArrayReadData>();

if (data.dim_len == 2) {
Expand Down
23 changes: 12 additions & 11 deletions src/coo2tbl_converter.cpp → src/coo_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#include "coo2tbl_converter.hpp"
#include "coo_reader.hpp"

namespace duckdb {
const uint64_t TOTAL_COO_NUM_COLUMNS = 3;

uint64_t COOToTableConverter::_PutData(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t num_rows, DataChunk &output) {
uint64_t CooReader::_PutData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
uint64_t num_rows, DataChunk &output) {
// auto &data = bind_data->Cast<ArrayReadData>();

auto total_remains =
Expand Down Expand Up @@ -39,9 +39,10 @@ uint64_t COOToTableConverter::_PutData(
return local_remains;
}

uint64_t COOToTableConverter::_PutDataNoPrune(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t num_rows, DataChunk &output) {
uint64_t CooReader::_PutDataNoPrune(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate,
double *pagevals, uint64_t num_rows,
DataChunk &output) {
// auto &data = bind_data->Cast<ArrayReadData>();

auto total_remains = num_rows - (gstate.cell_idx / TOTAL_COO_NUM_COLUMNS);
Expand Down Expand Up @@ -74,7 +75,7 @@ uint64_t COOToTableConverter::_PutDataNoPrune(
return local_remains;
}

uint64_t COOToTableConverter::_PutDataNoPruneAndProjection(
uint64_t CooReader::_PutDataNoPruneAndProjection(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t num_rows, DataChunk &output) {
// auto &data = bind_data->Cast<ArrayReadData>();
Expand Down Expand Up @@ -109,9 +110,9 @@ uint64_t COOToTableConverter::_PutDataNoPruneAndProjection(
return local_remains;
}

uint64_t COOToTableConverter::PutData(
optional_ptr<const FunctionData> bind_data, ArrayReadGlobalState &gstate,
double *pagevals, uint64_t num_of_cells, DataChunk &output) {
uint64_t CooReader::PutData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
uint64_t num_of_cells, DataChunk &output) {
auto &data = bind_data->Cast<ArrayReadData>();

// COO must be 2D array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" {
}

namespace duckdb {
class ArrayToTableConverter {
class ArrayReader {
public:
static uint64_t PutData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" {
}

namespace duckdb {
class COOToTableConverter {
class CooReader {
public:
static uint64_t PutData(optional_ptr<const FunctionData> bind_data,
ArrayReadGlobalState &gstate, double *pagevals,
Expand Down
13 changes: 6 additions & 7 deletions src/read_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <duckdb/parser/parsed_data/create_scalar_function_info.hpp>
#include <thread>

#include "arr2tbl_converter.hpp"
#include "array_extension.hpp"
#include "coo2tbl_converter.hpp"
#include "array_reader.hpp"
#include "coo_reader.hpp"
#include "duckdb.hpp"
#include "duckdb/common/exception.hpp"
#include "duckdb/common/string_util.hpp"
Expand Down Expand Up @@ -37,15 +37,14 @@ static void ReadArrayFunction(ClientContext &context,

if (data.is_coo_array) {
// TODO: Multi-tile array is not tested
uint64_t read =
COOToTableConverter::PutData(data_p.bind_data, gstate, pagevals,
size / (data.dim_len + 1), output);
uint64_t read = CooReader::PutData(data_p.bind_data, gstate, pagevals,
size / (data.dim_len + 1), output);

output.SetCardinality(read);
output.Verify();
} else {
uint64_t read = ArrayToTableConverter::PutData(data_p.bind_data, gstate,
pagevals, size, output);
uint64_t read = ArrayReader::PutData(data_p.bind_data, gstate, pagevals,
size, output);

output.SetCardinality(read);
output.Verify();
Expand Down

0 comments on commit a888e78

Please sign in to comment.