23 #ifndef FIXED_LENGTH_ARRAY_NONE_ENCODER_H
24 #define FIXED_LENGTH_ARRAY_NONE_ENCODER_H
46 const std::vector<size_t>& selected_idx,
47 const size_t byte_limit)
override {
48 size_t data_size = selected_idx.size() *
array_size;
49 if (data_size > byte_limit) {
50 data_size = byte_limit;
57 const size_t numAppendElems,
58 const size_t byteLimit,
59 const bool replicating =
false) {
61 if (dataSize > byteLimit) {
68 const int8_t* index_data,
70 const std::vector<size_t>& selected_idx)
override {
71 std::vector<ArrayDatum> data_subset;
72 data_subset.reserve(selected_idx.size());
73 for (
const auto& index : selected_idx) {
74 auto current_data = data +
array_size * (index);
80 return appendData(&data_subset, 0, selected_idx.size(),
false);
85 const size_t start_idx,
86 const size_t num_elements)
override {
87 std::vector<ArrayDatum> data_subset;
88 data_subset.reserve(num_elements);
89 for (
size_t count = 0; count < num_elements; ++count) {
90 auto current_data = data +
array_size * (start_idx + count);
91 data_subset.emplace_back(
94 return appendData(&data_subset, 0, num_elements,
false);
97 std::shared_ptr<ChunkMetadata>
appendData(int8_t*& src_data,
98 const size_t num_elems_to_append,
100 const bool replicating =
false,
101 const int64_t offset = -1)
override {
106 std::shared_ptr<ChunkMetadata>
appendData(
const std::vector<ArrayDatum>* srcData,
108 const size_t numAppendElems,
109 const bool replicating =
false) {
111 const size_t append_data_size = array_size * numAppendElems;
113 std::vector<int8_t> append_buffer(append_data_size);
114 int8_t* append_ptr = append_buffer.data();
123 const size_t len = (*srcData)[0].length;
125 const int8_t* replicated_ptr = (*srcData)[0].pointer;
126 for (
size_t i = 0; i < numAppendElems; ++i) {
127 std::memcpy(append_ptr + i * array_size, replicated_ptr, array_size);
130 for (
size_t i = 0; i < numAppendElems; ++i) {
133 const size_t source_idx = start_idx + i;
134 const size_t len = (*srcData)[source_idx].length;
139 append_ptr + i * array_size, (*srcData)[source_idx].pointer, array_size);
158 auto chunk_metadata = std::make_shared<ChunkMetadata>();
160 return chunk_metadata;
163 void getMetadata(
const std::shared_ptr<ChunkMetadata>& chunkMetadata)
override {
170 auto chunk_metadata = std::make_shared<ChunkMetadata>(
172 return chunk_metadata;
181 void updateStats(
const int8_t*
const src_data,
const size_t num_elements)
override {
186 const size_t start_idx,
187 const size_t num_elements)
override {
192 const size_t start_idx,
193 const size_t num_elements)
override {
194 for (
size_t n = start_idx;
n < start_idx + num_elements;
n++) {
201 fwrite((int8_t*)&
num_elems_,
sizeof(
size_t), 1, f);
204 fwrite((int8_t*)&
has_nulls,
sizeof(
bool), 1, f);
210 fread((int8_t*)&
num_elems_,
sizeof(
size_t), 1, f);
213 fread((int8_t*)&
has_nulls,
sizeof(
bool), 1, f);
237 const int32_t* int_array = (int32_t*)array;
241 const int16_t* smallint_array = (int16_t*)array;
245 const int8_t* tinyint_array = (int8_t*)array;
251 const int64_t* bigint_array = (int64_t*)array;
255 const float* flt_array = (
float*)array;
259 const double* dbl_array = (
double*)array;
265 const int64_t* tm_array =
reinterpret_cast<int64_t*
>(array);
272 const int32_t* int_array = (int32_t*)array;
334 const int8_t* bool_array = array.pointer;
335 for (
size_t i = 0; i < array.length /
sizeof(bool); i++) {
357 const int32_t* int_array = (int32_t*)array.pointer;
358 for (
size_t i = 0; i < array.length /
sizeof(int32_t); i++) {
380 const int16_t* smallint_array = (int16_t*)array.pointer;
381 for (
size_t i = 0; i < array.length /
sizeof(int16_t); i++) {
403 const int8_t* tinyint_array = (int8_t*)array.pointer;
404 for (
size_t i = 0; i < array.length /
sizeof(int8_t); i++) {
428 const int64_t* bigint_array = (int64_t*)array.pointer;
429 for (
size_t i = 0; i < array.length /
sizeof(int64_t); i++) {
453 const float* flt_array = (
float*)array.pointer;
454 for (
size_t i = 0; i < array.length /
sizeof(float); i++) {
476 const double* dbl_array = (
double*)array.pointer;
477 for (
size_t i = 0; i < array.length /
sizeof(double); i++) {
501 const int64_t* tm_array =
reinterpret_cast<int64_t*
>(array.pointer);
502 for (
size_t i = 0; i < array.length /
sizeof(int64_t); i++) {
527 const int32_t* int_array = (int32_t*)array.pointer;
528 for (
size_t i = 0; i < array.length /
sizeof(int32_t); i++) {
549 #endif // FIXED_LENGTH_ARRAY_NONE_ENCODER_H
HOST DEVICE SQLTypes get_subtype() const
void updateStats(const int8_t *const src_data, const size_t num_elements) override
bool is_null(int8_t *array)
bool is_null_ignore_not_null(int8_t *array)
DecimalOverflowValidator decimal_overflow_validator_
std::shared_ptr< ChunkMetadata > appendEncodedData(const int8_t *index_data, int8_t *data, const size_t start_idx, const size_t num_elements) override
#define NULL_ARRAY_SMALLINT
#define NULL_ARRAY_TINYINT
void resetChunkStats() override
void updateMetadata(int8_t *array)
virtual void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata)
void updateStats(const double, const bool) override
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
FixedLengthArrayNoneEncoder(AbstractBuffer *buffer, size_t as)
void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata) override
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
Data_Namespace::AbstractBuffer * buffer_
std::shared_ptr< ChunkMetadata > getMetadata(const SQLTypeInfo &ti) override
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
size_t getNumElemsForBytesEncodedDataAtIndices(const int8_t *index_data, const std::vector< size_t > &selected_idx, const size_t byte_limit) override
void copyMetadata(const Encoder *copyFromEncoder) override
size_t getNumElems() const
std::shared_ptr< ChunkMetadata > appendEncodedDataAtIndices(const int8_t *index_data, int8_t *data, const std::vector< size_t > &selected_idx) override
An AbstractBuffer is a unit of data management for a data manager.
void writeMetadata(FILE *f) override
void readMetadata(FILE *f) override
void updateStats(const std::vector< std::string > *const src_data, const size_t start_idx, const size_t num_elements) override
HOST DEVICE EncodingType get_compression() const
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
virtual void append(int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1)=0
SQLTypeInfo getSqlType() const
#define NULL_ARRAY_DOUBLE
void update_elem_stats(const ArrayDatum &array)
void reduceStats(const Encoder &) override
bool g_enable_watchdog false
void updateStats(const int64_t, const bool) override
#define NULL_ARRAY_BIGINT
static bool is_null(const SQLTypeInfo &type, int8_t *array)
void updateStats(const std::vector< ArrayDatum > *const src_data, const size_t start_idx, const size_t num_elements) override
#define NULL_ARRAY_BOOLEAN
HOST DEVICE bool get_notnull() const
static bool is_null_ignore_not_null(const SQLTypeInfo &type, int8_t *array)
size_t getNumElemsForBytesInsertData(const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const size_t byteLimit, const bool replicating=false)
void validate(T value) const
SQLTypeInfo get_elem_type() const
virtual void reserve(size_t num_bytes)=0
std::shared_ptr< ChunkMetadata > appendData(const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const bool replicating=false)
bool resetChunkStats(const ChunkStats &stats) override
: Reset chunk level stats (min, max, nulls) using new values from the argument.