duckdb 0.3.2-dev735.0 → 0.3.2-dev780.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +91 -40
- package/src/duckdb.hpp +6 -3
- package/src/parquet-amalgamation.cpp +35720 -35009
- package/src/parquet-amalgamation.hpp +118 -0
|
@@ -7055,8 +7055,22 @@ private:
|
|
|
7055
7055
|
} // namespace duckdb
|
|
7056
7056
|
|
|
7057
7057
|
|
|
7058
|
+
//===----------------------------------------------------------------------===//
|
|
7059
|
+
// DuckDB
|
|
7060
|
+
//
|
|
7061
|
+
// parquet_rle_bp_decoder.hpp
|
|
7062
|
+
//
|
|
7063
|
+
//
|
|
7064
|
+
//===----------------------------------------------------------------------===//
|
|
7065
|
+
|
|
7066
|
+
|
|
7067
|
+
|
|
7068
|
+
|
|
7069
|
+
|
|
7070
|
+
|
|
7058
7071
|
|
|
7059
7072
|
namespace duckdb {
|
|
7073
|
+
|
|
7060
7074
|
class RleBpDecoder {
|
|
7061
7075
|
public:
|
|
7062
7076
|
/// Create a decoder object. buffer/buffer_len is the decoded data.
|
|
@@ -7104,6 +7118,17 @@ public:
|
|
|
7104
7118
|
}
|
|
7105
7119
|
}
|
|
7106
7120
|
|
|
7121
|
+
static uint8_t ComputeBitWidth(idx_t val) {
|
|
7122
|
+
if (val == 0) {
|
|
7123
|
+
return 0;
|
|
7124
|
+
}
|
|
7125
|
+
uint8_t ret = 1;
|
|
7126
|
+
while (((idx_t)(1 << ret) - 1) < val) {
|
|
7127
|
+
ret++;
|
|
7128
|
+
}
|
|
7129
|
+
return ret;
|
|
7130
|
+
}
|
|
7131
|
+
|
|
7107
7132
|
private:
|
|
7108
7133
|
ByteBuffer buffer_;
|
|
7109
7134
|
|
|
@@ -7528,6 +7553,89 @@ private:
|
|
|
7528
7553
|
#endif
|
|
7529
7554
|
|
|
7530
7555
|
|
|
7556
|
+
//===----------------------------------------------------------------------===//
|
|
7557
|
+
// DuckDB
|
|
7558
|
+
//
|
|
7559
|
+
// column_writer.hpp
|
|
7560
|
+
//
|
|
7561
|
+
//
|
|
7562
|
+
//===----------------------------------------------------------------------===//
|
|
7563
|
+
|
|
7564
|
+
|
|
7565
|
+
|
|
7566
|
+
#include "duckdb.hpp"
|
|
7567
|
+
|
|
7568
|
+
|
|
7569
|
+
namespace duckdb {
|
|
7570
|
+
class BufferedSerializer;
|
|
7571
|
+
class ParquetWriter;
|
|
7572
|
+
class ColumnWriterPageState;
|
|
7573
|
+
|
|
7574
|
+
class ColumnWriterState {
|
|
7575
|
+
public:
|
|
7576
|
+
virtual ~ColumnWriterState();
|
|
7577
|
+
|
|
7578
|
+
vector<uint16_t> definition_levels;
|
|
7579
|
+
vector<uint16_t> repetition_levels;
|
|
7580
|
+
vector<bool> is_empty;
|
|
7581
|
+
};
|
|
7582
|
+
|
|
7583
|
+
class ColumnWriter {
|
|
7584
|
+
//! We limit the uncompressed page size to 100MB
|
|
7585
|
+
// The max size in Parquet is 2GB, but we choose a more conservative limit
|
|
7586
|
+
static constexpr const idx_t MAX_UNCOMPRESSED_PAGE_SIZE = 100000000;
|
|
7587
|
+
|
|
7588
|
+
public:
|
|
7589
|
+
ColumnWriter(ParquetWriter &writer, idx_t schema_idx, idx_t max_repeat, idx_t max_define);
|
|
7590
|
+
virtual ~ColumnWriter();
|
|
7591
|
+
|
|
7592
|
+
ParquetWriter &writer;
|
|
7593
|
+
idx_t schema_idx;
|
|
7594
|
+
idx_t max_repeat;
|
|
7595
|
+
idx_t max_define;
|
|
7596
|
+
|
|
7597
|
+
public:
|
|
7598
|
+
//! Create the column writer for a specific type recursively
|
|
7599
|
+
static unique_ptr<ColumnWriter> CreateWriterRecursive(vector<duckdb_parquet::format::SchemaElement> &schemas,
|
|
7600
|
+
ParquetWriter &writer, const LogicalType &type,
|
|
7601
|
+
const string &name, idx_t max_repeat = 0,
|
|
7602
|
+
idx_t max_define = 1);
|
|
7603
|
+
|
|
7604
|
+
virtual unique_ptr<ColumnWriterState> InitializeWriteState(duckdb_parquet::format::RowGroup &row_group,
|
|
7605
|
+
vector<string> schema_path);
|
|
7606
|
+
virtual void Prepare(ColumnWriterState &state, ColumnWriterState *parent, Vector &vector, idx_t count);
|
|
7607
|
+
|
|
7608
|
+
virtual void BeginWrite(ColumnWriterState &state);
|
|
7609
|
+
virtual void Write(ColumnWriterState &state, Vector &vector, idx_t count);
|
|
7610
|
+
virtual void FinalizeWrite(ColumnWriterState &state);
|
|
7611
|
+
|
|
7612
|
+
protected:
|
|
7613
|
+
void HandleDefineLevels(ColumnWriterState &state, ColumnWriterState *parent, ValidityMask &validity, idx_t count,
|
|
7614
|
+
uint16_t define_value, uint16_t null_value);
|
|
7615
|
+
void HandleRepeatLevels(ColumnWriterState &state_p, ColumnWriterState *parent, idx_t count, idx_t max_repeat);
|
|
7616
|
+
|
|
7617
|
+
void WriteLevels(Serializer &temp_writer, const vector<uint16_t> &levels, idx_t max_value, idx_t start_offset,
|
|
7618
|
+
idx_t count);
|
|
7619
|
+
|
|
7620
|
+
void NextPage(ColumnWriterState &state_p);
|
|
7621
|
+
void FlushPage(ColumnWriterState &state_p);
|
|
7622
|
+
|
|
7623
|
+
//! Retrieves the row size of a vector at the specified location. Only used for scalar types.
|
|
7624
|
+
virtual idx_t GetRowSize(Vector &vector, idx_t index) = 0;
|
|
7625
|
+
//! Writes a (subset of a) vector to the specified serializer. Only used for scalar types.
|
|
7626
|
+
virtual void WriteVector(Serializer &temp_writer, ColumnWriterPageState *page_state, Vector &vector,
|
|
7627
|
+
idx_t chunk_start, idx_t chunk_end) = 0;
|
|
7628
|
+
//! Initialize the writer for a specific page. Only used for scalar types.
|
|
7629
|
+
virtual unique_ptr<ColumnWriterPageState> InitializePageState();
|
|
7630
|
+
//! Flushes the writer for a specific page. Only used for scalar types.
|
|
7631
|
+
virtual void FlushPageState(Serializer &temp_writer, ColumnWriterPageState *state);
|
|
7632
|
+
|
|
7633
|
+
void CompressPage(BufferedSerializer &temp_writer, size_t &compressed_size, data_ptr_t &compressed_data,
|
|
7634
|
+
unique_ptr<data_t[]> &compressed_buf);
|
|
7635
|
+
};
|
|
7636
|
+
|
|
7637
|
+
} // namespace duckdb
|
|
7638
|
+
|
|
7531
7639
|
|
|
7532
7640
|
|
|
7533
7641
|
namespace duckdb {
|
|
@@ -7535,6 +7643,10 @@ class FileSystem;
|
|
|
7535
7643
|
class FileOpener;
|
|
7536
7644
|
|
|
7537
7645
|
class ParquetWriter {
|
|
7646
|
+
friend class ColumnWriter;
|
|
7647
|
+
friend class ListColumnWriter;
|
|
7648
|
+
friend class StructColumnWriter;
|
|
7649
|
+
|
|
7538
7650
|
public:
|
|
7539
7651
|
ParquetWriter(FileSystem &fs, string file_name, FileOpener *file_opener, vector<LogicalType> types,
|
|
7540
7652
|
vector<string> names, duckdb_parquet::format::CompressionCodec::type codec);
|
|
@@ -7543,6 +7655,10 @@ public:
|
|
|
7543
7655
|
void Flush(ChunkCollection &buffer);
|
|
7544
7656
|
void Finalize();
|
|
7545
7657
|
|
|
7658
|
+
static duckdb_parquet::format::Type::type DuckDBTypeToParquetType(const LogicalType &duckdb_type);
|
|
7659
|
+
static bool DuckDBTypeToConvertedType(const LogicalType &duckdb_type,
|
|
7660
|
+
duckdb_parquet::format::ConvertedType::type &result);
|
|
7661
|
+
|
|
7546
7662
|
private:
|
|
7547
7663
|
string file_name;
|
|
7548
7664
|
vector<LogicalType> sql_types;
|
|
@@ -7553,6 +7669,8 @@ private:
|
|
|
7553
7669
|
shared_ptr<duckdb_apache::thrift::protocol::TProtocol> protocol;
|
|
7554
7670
|
duckdb_parquet::format::FileMetaData file_meta_data;
|
|
7555
7671
|
std::mutex lock;
|
|
7672
|
+
|
|
7673
|
+
vector<unique_ptr<ColumnWriter>> column_writers;
|
|
7556
7674
|
};
|
|
7557
7675
|
|
|
7558
7676
|
} // namespace duckdb
|