31 namespace Data_Namespace {
36 #define MAX_INPUT_BUF_SIZE 1048576
48 max_ = (int64_t)std::pow((
double)10.0, precision);
50 pow10_ = precision - scale;
55 if (std::is_integral<T>::value) {
66 throw std::runtime_error(
"Decimal overflow: value is greater than 10^" +
72 throw std::runtime_error(
"Decimal overflow: value is less than -10^" +
85 template <
typename INNER_VALIDATOR>
115 max_ = is_date_16_ ?
static_cast<int64_t
>(std::numeric_limits<int16_t>::max())
116 : static_cast<int64_t>(std::numeric_limits<int32_t>::max());
117 min_ = is_date_16_ ?
static_cast<int64_t
>(std::numeric_limits<int16_t>::min())
118 : static_cast<int64_t>(std::numeric_limits<int32_t>::min());
121 template <
typename T>
129 throw std::runtime_error(
"Date encoding overflow: Epoch days " +
134 throw std::runtime_error(
"Date encoding underflow: Epoch days " +
168 const int8_t* index_data,
169 const std::vector<size_t>& selected_idx,
170 const size_t byte_limit) = 0;
184 const int8_t* index_data,
186 const std::vector<size_t>& selected_idx) = 0;
199 virtual std::shared_ptr<ChunkMetadata>
appendEncodedData(
const int8_t* index_data,
201 const size_t start_idx,
202 const size_t num_elements) = 0;
211 virtual std::shared_ptr<ChunkMetadata>
appendData(int8_t*& src_data,
212 const size_t num_elems_to_append,
214 const bool replicating =
false,
215 const int64_t offset = -1) = 0;
216 virtual void getMetadata(
const std::shared_ptr<ChunkMetadata>& chunkMetadata);
228 virtual void updateStats(
const int8_t*
const src_data,
const size_t num_elements) = 0;
237 const size_t num_elements) {
248 virtual void updateStats(
const std::vector<std::string>*
const src_data,
249 const size_t start_idx,
250 const size_t num_elements) = 0;
259 virtual void updateStats(
const std::vector<ArrayDatum>*
const src_data,
260 const size_t start_idx,
261 const size_t num_elements) = 0;
275 UNREACHABLE() <<
"Attempting to reset stats for unsupported type.";
virtual void resetChunkStats()=0
DateDaysOverflowValidator(SQLTypeInfo type)
DecimalOverflowValidator decimal_overflow_validator_
HOST DEVICE int get_scale() const
static Encoder * Create(Data_Namespace::AbstractBuffer *buffer, const SQLTypeInfo sqlType)
INNER_VALIDATOR * inner_validator_
Constants for Builtin SQL Types supported by HEAVY.AI.
void setNumElems(const size_t num_elems)
virtual bool resetChunkStats(const ChunkStats &)
: Reset chunk level stats (min, max, nulls) using new values from the argument.
virtual void reduceStats(const Encoder &)=0
virtual void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata)
void do_validate(int64_t value) const
virtual size_t getNumElemsForBytesEncodedDataAtIndices(const int8_t *index_data, const std::vector< size_t > &selected_idx, const size_t byte_limit)=0
CONSTEXPR DEVICE bool is_null(const T &value)
Data_Namespace::AbstractBuffer * buffer_
size_t getNumElems() const
An AbstractBuffer is a unit of data management for a data manager.
Encoder(Data_Namespace::AbstractBuffer *buffer)
DateDaysOverflowValidator date_days_overflow_validator_
int get_precision() const
bool is_date_in_days() const
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
NullAwareValidator(SQLTypeInfo type, INNER_VALIDATOR *inner_validator)
HOST DEVICE int get_comp_param() const
virtual void updateStatsEncoded(const int8_t *const dst_data, const size_t num_elements)
int64_t get_epoch_days_from_seconds(const int64_t seconds)
virtual void writeMetadata(FILE *f)=0
virtual std::shared_ptr< ChunkMetadata > appendEncodedDataAtIndices(const int8_t *index_data, int8_t *data, const std::vector< size_t > &selected_idx)=0
HOST DEVICE bool get_notnull() const
void validate(T value) const
virtual void updateStats(const int64_t val, const bool is_null)=0
SQLTypeInfo get_elem_type() const
virtual void copyMetadata(const Encoder *copyFromEncoder)=0
virtual void readMetadata(FILE *f)=0
DecimalOverflowValidator(SQLTypeInfo type)
virtual std::shared_ptr< ChunkMetadata > appendEncodedData(const int8_t *index_data, int8_t *data, const size_t start_idx, const size_t num_elements)=0
virtual 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)=0