OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NoneEncoder< T > Class Template Reference

#include <NoneEncoder.h>

+ Inheritance diagram for NoneEncoder< T >:
+ Collaboration diagram for NoneEncoder< T >:

Public Member Functions

 NoneEncoder (Data_Namespace::AbstractBuffer *buffer)
 
size_t getNumElemsForBytesEncodedDataAtIndices (const int8_t *index_data, const std::vector< size_t > &selected_idx, const size_t byte_limit) override
 
std::shared_ptr< ChunkMetadataappendEncodedDataAtIndices (const int8_t *, int8_t *data, const std::vector< size_t > &selected_idx) override
 
std::shared_ptr< ChunkMetadataappendEncodedData (const int8_t *, int8_t *data, const size_t start_idx, const size_t num_elements) override
 
std::shared_ptr< ChunkMetadataappendData (int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &, const bool replicating=false, const int64_t offset=-1) override
 
void getMetadata (const std::shared_ptr< ChunkMetadata > &chunkMetadata) override
 
std::shared_ptr< ChunkMetadatagetMetadata (const SQLTypeInfo &ti) override
 
void updateStats (const int64_t val, const bool is_null) override
 
void updateStats (const double val, const bool is_null) override
 
void updateStats (const int8_t *const src_data, const size_t num_elements) override
 
void updateStatsEncoded (const int8_t *const dst_data, const size_t num_elements) override
 
void updateStats (const std::vector< std::string > *const src_data, const size_t start_idx, const size_t num_elements) override
 
void updateStats (const std::vector< ArrayDatum > *const src_data, const size_t start_idx, const size_t num_elements) override
 
void reduceStats (const Encoder &that) override
 
void writeMetadata (FILE *f) override
 
void readMetadata (FILE *f) override
 
bool resetChunkStats (const ChunkStats &stats) override
 : Reset chunk level stats (min, max, nulls) using new values from the argument. More...
 
void copyMetadata (const Encoder *copyFromEncoder) override
 
void resetChunkStats () override
 
- Public Member Functions inherited from Encoder
 Encoder (Data_Namespace::AbstractBuffer *buffer)
 
virtual ~Encoder ()
 
size_t getNumElems () const
 
void setNumElems (const size_t num_elems)
 

Public Attributes

dataMin
 
dataMax
 
bool has_nulls
 

Private Member Functions

std::shared_ptr< ChunkMetadataappendValidatedOrNonValidatedData (int8_t *&src_data, const size_t num_elems_to_append, const bool replicating, const int64_t offset, const bool is_validated_data)
 
validateDataAndUpdateStats (const T &unencoded_data, const bool is_validated_data=false)
 
void updateStats (const int8_t *const src_data, const size_t num_elements, const bool is_validated_data)
 

Additional Inherited Members

- Static Public Member Functions inherited from Encoder
static EncoderCreate (Data_Namespace::AbstractBuffer *buffer, const SQLTypeInfo sqlType)
 
- Protected Attributes inherited from Encoder
size_t num_elems_
 
Data_Namespace::AbstractBufferbuffer_
 
DecimalOverflowValidator decimal_overflow_validator_
 
DateDaysOverflowValidator date_days_overflow_validator_
 

Detailed Description

template<typename T>
class NoneEncoder< T >

Definition at line 37 of file NoneEncoder.h.

Constructor & Destructor Documentation

template<typename T>
NoneEncoder< T >::NoneEncoder ( Data_Namespace::AbstractBuffer buffer)
inline

Definition at line 39 of file NoneEncoder.h.

References NoneEncoder< T >::resetChunkStats().

39  : Encoder(buffer) {
41  }
void resetChunkStats() override
Definition: NoneEncoder.h:214
Encoder(Data_Namespace::AbstractBuffer *buffer)
Definition: Encoder.cpp:225

+ Here is the call graph for this function:

Member Function Documentation

template<typename T>
std::shared_ptr<ChunkMetadata> NoneEncoder< T >::appendData ( int8_t *&  src_data,
const size_t  num_elems_to_append,
const SQLTypeInfo ti,
const bool  replicating = false,
const int64_t  offset = -1 
)
inlineoverridevirtual

Append data to the chunk buffer backing this encoder.

Parameters
src_dataSource data for the append
num_elems_to_appendNumber of elements to append
tiSQL Type Info for the column TODO(adb): used?
replicatingPass one value and fill the chunk with it
offsetWrite data starting at a given offset. Default is -1 which indicates an append, an offset of 0 rewrites the chunk up to num_elems_to_append.

Implements Encoder.

Definition at line 78 of file NoneEncoder.h.

References NoneEncoder< T >::appendValidatedOrNonValidatedData().

Referenced by NoneEncoder< T >::appendEncodedDataAtIndices().

82  {
84  src_data, num_elems_to_append, replicating, offset, false);
85  }
std::shared_ptr< ChunkMetadata > appendValidatedOrNonValidatedData(int8_t *&src_data, const size_t num_elems_to_append, const bool replicating, const int64_t offset, const bool is_validated_data)
Definition: NoneEncoder.h:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
std::shared_ptr<ChunkMetadata> NoneEncoder< T >::appendEncodedData ( const int8_t *  index_data,
int8_t *  data,
const size_t  start_idx,
const size_t  num_elements 
)
inlineoverridevirtual

Append encoded data to the chunk buffer backing this encoder.

Parameters
index_data- (optional) the index data of data to append
data- the data to append
start_idx- the position to start encoding from in the data array
num_elements- the number of elements to encode from the data array
Returns
updated chunk metadata for the chunk buffer backing this encoder

NOTE: index_data must be non-null for varlen encoder types.

Implements Encoder.

Definition at line 70 of file NoneEncoder.h.

References NoneEncoder< T >::appendValidatedOrNonValidatedData(), and heavydb.dtypes::T.

73  {
74  auto current_data = data + sizeof(T) * start_idx;
75  return appendValidatedOrNonValidatedData(current_data, num_elements, false, -1, true);
76  }
std::shared_ptr< ChunkMetadata > appendValidatedOrNonValidatedData(int8_t *&src_data, const size_t num_elems_to_append, const bool replicating, const int64_t offset, const bool is_validated_data)
Definition: NoneEncoder.h:225

+ Here is the call graph for this function:

template<typename T>
std::shared_ptr<ChunkMetadata> NoneEncoder< T >::appendEncodedDataAtIndices ( const int8_t *  index_data,
int8_t *  data,
const std::vector< size_t > &  selected_idx 
)
inlineoverridevirtual

Append selected encoded data to the chunk buffer backing this encoder.

Parameters
index_data- (optional) the index data of data to append
data- the data to append
selected_idx- which indices in the encoded data to append
Returns
updated chunk metadata for the chunk buffer backing this encoder

NOTE: index_data must be non-null for varlen encoder types.

Implements Encoder.

Definition at line 52 of file NoneEncoder.h.

References NoneEncoder< T >::appendData(), shared::execute_over_contiguous_indices(), and heavydb.dtypes::T.

55  {
56  std::shared_ptr<ChunkMetadata> chunk_metadata;
57  // NOTE: the use of `execute_over_contiguous_indices` is an optimization;
58  // it prevents having to copy or move the indexed data and instead performs
59  // an append over contiguous sections of indices.
61  selected_idx, [&](const size_t start_pos, const size_t end_pos) {
62  size_t elem_count = end_pos - start_pos;
63  auto data_ptr = data + sizeof(T) * selected_idx[start_pos];
64  chunk_metadata = appendData(data_ptr, elem_count, SQLTypeInfo{}, false);
65  });
66 
67  return chunk_metadata;
68  }
void execute_over_contiguous_indices(const std::vector< size_t > &indices, std::function< void(const size_t, const size_t)> to_execute)
Definition: Iteration.h:22
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &, const bool replicating=false, const int64_t offset=-1) override
Definition: NoneEncoder.h:78

+ Here is the call graph for this function:

template<typename T>
std::shared_ptr<ChunkMetadata> NoneEncoder< T >::appendValidatedOrNonValidatedData ( int8_t *&  src_data,
const size_t  num_elems_to_append,
const bool  replicating,
const int64_t  offset,
const bool  is_validated_data 
)
inlineprivate

Definition at line 225 of file NoneEncoder.h.

References Data_Namespace::AbstractBuffer::append(), Encoder::buffer_, CHECK, CHECK_GE, gpu_enabled::fill(), NoneEncoder< T >::getMetadata(), Encoder::num_elems_, Data_Namespace::AbstractBuffer::reserve(), NoneEncoder< T >::resetChunkStats(), Data_Namespace::AbstractBuffer::size(), heavydb.dtypes::T, NoneEncoder< T >::updateStats(), NoneEncoder< T >::validateDataAndUpdateStats(), and Data_Namespace::AbstractBuffer::write().

Referenced by NoneEncoder< T >::appendData(), and NoneEncoder< T >::appendEncodedData().

230  {
231  if (offset == 0 && num_elems_to_append >= num_elems_) {
232  resetChunkStats();
233  }
234  T* unencodedData = reinterpret_cast<T*>(src_data);
235  std::vector<T> encoded_data;
236  if (replicating) {
237  if (num_elems_to_append > 0) {
238  encoded_data.resize(num_elems_to_append);
239  T data = validateDataAndUpdateStats(unencodedData[0]);
240  std::fill(encoded_data.begin(), encoded_data.end(), data);
241  }
242  } else {
243  updateStats(src_data, num_elems_to_append, is_validated_data);
244  }
245  if (offset == -1) {
246  auto append_data_size = num_elems_to_append * sizeof(T);
247  buffer_->reserve(buffer_->size() + append_data_size);
248  num_elems_ += num_elems_to_append;
249  buffer_->append(
250  replicating ? reinterpret_cast<int8_t*>(encoded_data.data()) : src_data,
251  append_data_size);
252  if (!replicating) {
253  src_data += num_elems_to_append * sizeof(T);
254  }
255  } else {
256  num_elems_ = offset + num_elems_to_append;
257  CHECK(!replicating);
258  CHECK_GE(offset, 0);
259  buffer_->write(
260  src_data, num_elems_to_append * sizeof(T), static_cast<size_t>(offset));
261  }
262  auto chunk_metadata = std::make_shared<ChunkMetadata>();
263  getMetadata(chunk_metadata);
264  return chunk_metadata;
265  }
size_t num_elems_
Definition: Encoder.h:288
#define CHECK_GE(x, y)
Definition: Logger.h:306
void updateStats(const int64_t val, const bool is_null) override
Definition: NoneEncoder.h:100
void resetChunkStats() override
Definition: NoneEncoder.h:214
DEVICE void fill(ARGS &&...args)
Definition: gpu_enabled.h:60
Data_Namespace::AbstractBuffer * buffer_
Definition: Encoder.h:290
void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata) override
Definition: NoneEncoder.h:87
virtual void write(int8_t *src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int src_device_id=-1)=0
T validateDataAndUpdateStats(const T &unencoded_data, const bool is_validated_data=false)
Definition: NoneEncoder.h:267
virtual void append(int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1)=0
#define CHECK(condition)
Definition: Logger.h:291
virtual void reserve(size_t num_bytes)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
void NoneEncoder< T >::copyMetadata ( const Encoder copyFromEncoder)
inlineoverridevirtual

Implements Encoder.

Definition at line 206 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, Encoder::getNumElems(), NoneEncoder< T >::has_nulls, and Encoder::num_elems_.

206  {
207  num_elems_ = copyFromEncoder->getNumElems();
208  auto castedEncoder = reinterpret_cast<const NoneEncoder<T>*>(copyFromEncoder);
209  dataMin = castedEncoder->dataMin;
210  dataMax = castedEncoder->dataMax;
211  has_nulls = castedEncoder->has_nulls;
212  }
size_t num_elems_
Definition: Encoder.h:288
size_t getNumElems() const
Definition: Encoder.h:284
bool has_nulls
Definition: NoneEncoder.h:222

+ Here is the call graph for this function:

template<typename T>
void NoneEncoder< T >::getMetadata ( const std::shared_ptr< ChunkMetadata > &  chunkMetadata)
inlineoverridevirtual

Reimplemented from Encoder.

Definition at line 87 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, Encoder::getMetadata(), and NoneEncoder< T >::has_nulls.

Referenced by NoneEncoder< T >::appendValidatedOrNonValidatedData().

87  {
88  Encoder::getMetadata(chunkMetadata); // call on parent class
89  chunkMetadata->fillChunkStats(dataMin, dataMax, has_nulls);
90  }
virtual void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata)
Definition: Encoder.cpp:231
bool has_nulls
Definition: NoneEncoder.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
std::shared_ptr<ChunkMetadata> NoneEncoder< T >::getMetadata ( const SQLTypeInfo ti)
inlineoverridevirtual

Implements Encoder.

Definition at line 93 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, and NoneEncoder< T >::has_nulls.

93  {
94  auto chunk_metadata = std::make_shared<ChunkMetadata>(ti, 0, 0, ChunkStats{});
95  chunk_metadata->fillChunkStats(dataMin, dataMax, has_nulls);
96  return chunk_metadata;
97  }
bool has_nulls
Definition: NoneEncoder.h:222
template<typename T>
size_t NoneEncoder< T >::getNumElemsForBytesEncodedDataAtIndices ( const int8_t *  index_data,
const std::vector< size_t > &  selected_idx,
const size_t  byte_limit 
)
inlineoverridevirtual

Compute the maximum number of variable length encoded elements given a byte limit

Parameters
index_data- (optional) index data for the encoded type
selected_idx- which indices in the encoded data to consider
byte_limit- byte limit that must be respected
Returns
the number of elements

NOTE: optional parameters above may be ignored by the implementation, but may or may not be required depending on the encoder type backing the implementation.

Implements Encoder.

Definition at line 43 of file NoneEncoder.h.

References UNREACHABLE.

45  {
46  UNREACHABLE()
47  << "getNumElemsForBytesEncodedDataAtIndices unexpectedly called for non varlen"
48  " encoder";
49  return {};
50  }
#define UNREACHABLE()
Definition: Logger.h:338
template<typename T>
void NoneEncoder< T >::readMetadata ( FILE *  f)
inlineoverridevirtual

Implements Encoder.

Definition at line 184 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, NoneEncoder< T >::has_nulls, Encoder::num_elems_, and heavydb.dtypes::T.

184  {
185  // assumes pointer is already in right place
186  fread((int8_t*)&num_elems_, sizeof(size_t), 1, f);
187  fread((int8_t*)&dataMin, sizeof(T), 1, f);
188  fread((int8_t*)&dataMax, sizeof(T), 1, f);
189  fread((int8_t*)&has_nulls, sizeof(bool), 1, f);
190  }
size_t num_elems_
Definition: Encoder.h:288
bool has_nulls
Definition: NoneEncoder.h:222
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
template<typename T>
void NoneEncoder< T >::reduceStats ( const Encoder that)
inlineoverridevirtual

Implements Encoder.

Definition at line 167 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, and NoneEncoder< T >::has_nulls.

167  {
168  const auto that_typed = static_cast<const NoneEncoder&>(that);
169  if (that_typed.has_nulls) {
170  has_nulls = true;
171  }
172  dataMin = std::min(dataMin, that_typed.dataMin);
173  dataMax = std::max(dataMax, that_typed.dataMax);
174  }
bool has_nulls
Definition: NoneEncoder.h:222
template<typename T>
bool NoneEncoder< T >::resetChunkStats ( const ChunkStats )
inlineoverridevirtual

: Reset chunk level stats (min, max, nulls) using new values from the argument.

Returns
: True if an update occurred and the chunk needs to be flushed. False otherwise. Default false if metadata update is unsupported. Only reset chunk stats if the incoming stats differ from the current stats.

Reimplemented from Encoder.

Definition at line 192 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, ChunkStats::has_nulls, NoneEncoder< T >::has_nulls, ChunkStats::max, and ChunkStats::min.

192  {
193  const auto new_min = DatumFetcher::getDatumVal<T>(stats.min);
194  const auto new_max = DatumFetcher::getDatumVal<T>(stats.max);
195 
196  if (dataMin == new_min && dataMax == new_max && has_nulls == stats.has_nulls) {
197  return false;
198  }
199 
200  dataMin = new_min;
201  dataMax = new_max;
202  has_nulls = stats.has_nulls;
203  return true;
204  }
dictionary stats
Definition: report.py:116
bool has_nulls
Definition: NoneEncoder.h:222
template<typename T>
void NoneEncoder< T >::resetChunkStats ( )
inlineoverridevirtual

Resets chunk metadata stats to their default values.

Implements Encoder.

Definition at line 214 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, and NoneEncoder< T >::has_nulls.

Referenced by NoneEncoder< T >::appendValidatedOrNonValidatedData(), and NoneEncoder< T >::NoneEncoder().

214  {
215  dataMin = std::numeric_limits<T>::max();
216  dataMax = std::numeric_limits<T>::lowest();
217  has_nulls = false;
218  }
bool has_nulls
Definition: NoneEncoder.h:222

+ Here is the caller graph for this function:

template<typename T>
void NoneEncoder< T >::updateStats ( const int64_t  val,
const bool  is_null 
)
inlineoverridevirtual

Implements Encoder.

Definition at line 100 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, NoneEncoder< T >::has_nulls, and heavydb.dtypes::T.

Referenced by NoneEncoder< T >::appendValidatedOrNonValidatedData(), and NoneEncoder< T >::updateStats().

100  {
101  if (is_null) {
102  has_nulls = true;
103  } else {
104  const auto data = static_cast<T>(val);
105  dataMin = std::min(dataMin, data);
106  dataMax = std::max(dataMax, data);
107  }
108  }
CONSTEXPR DEVICE bool is_null(const T &value)
bool has_nulls
Definition: NoneEncoder.h:222

+ Here is the caller graph for this function:

template<typename T>
void NoneEncoder< T >::updateStats ( const double  val,
const bool  is_null 
)
inlineoverridevirtual

Implements Encoder.

Definition at line 111 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, NoneEncoder< T >::has_nulls, and heavydb.dtypes::T.

111  {
112  if (is_null) {
113  has_nulls = true;
114  } else {
115  const auto data = static_cast<T>(val);
116  dataMin = std::min(dataMin, data);
117  dataMax = std::max(dataMax, data);
118  }
119  }
CONSTEXPR DEVICE bool is_null(const T &value)
bool has_nulls
Definition: NoneEncoder.h:222
template<typename T>
void NoneEncoder< T >::updateStats ( const int8_t *const  src_data,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for data without appending.

Parameters
src_data- the data with which to update statistics
num_elements- the number of elements to scan in the data

Implements Encoder.

Definition at line 121 of file NoneEncoder.h.

References NoneEncoder< T >::updateStats().

121  {
122  updateStats(src_data, num_elements, false);
123  }
void updateStats(const int64_t val, const bool is_null) override
Definition: NoneEncoder.h:100

+ Here is the call graph for this function:

template<typename T>
void NoneEncoder< T >::updateStats ( const std::vector< std::string > *const  src_data,
const size_t  start_idx,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for string data without appending.

Parameters
src_data- the string data with which to update statistics
start_idx- the offset into src_data to start the update
num_elements- the number of elements to scan in the string data

Implements Encoder.

Definition at line 154 of file NoneEncoder.h.

References UNREACHABLE.

156  {
157  UNREACHABLE();
158  }
#define UNREACHABLE()
Definition: Logger.h:338
template<typename T>
void NoneEncoder< T >::updateStats ( const std::vector< ArrayDatum > *const  src_data,
const size_t  start_idx,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for array data without appending.

Parameters
src_data- the array data with which to update statistics
start_idx- the offset into src_data to start the update
num_elements- the number of elements to scan in the array data

Implements Encoder.

Definition at line 160 of file NoneEncoder.h.

References UNREACHABLE.

162  {
163  UNREACHABLE();
164  }
#define UNREACHABLE()
Definition: Logger.h:338
template<typename T>
void NoneEncoder< T >::updateStats ( const int8_t *const  src_data,
const size_t  num_elements,
const bool  is_validated_data 
)
inlineprivate

Definition at line 281 of file NoneEncoder.h.

References heavydb.dtypes::T, and NoneEncoder< T >::validateDataAndUpdateStats().

283  {
284  const T* unencoded_data = reinterpret_cast<const T*>(src_data);
285  for (size_t i = 0; i < num_elements; ++i) {
286  validateDataAndUpdateStats(unencoded_data[i], is_validated_data);
287  }
288  }
T validateDataAndUpdateStats(const T &unencoded_data, const bool is_validated_data=false)
Definition: NoneEncoder.h:267

+ Here is the call graph for this function:

template<typename T>
void NoneEncoder< T >::updateStatsEncoded ( const int8_t *const  dst_data,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for encoded data without appending.

Parameters
dst_data- the data with which to update statistics
num_elements- the number of elements to scan in the data

Reimplemented from Encoder.

Definition at line 125 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, Encoder::decimal_overflow_validator_, NoneEncoder< T >::has_nulls, logger::init(), threading_serial::parallel_reduce(), heavydb.dtypes::T, and DecimalOverflowValidator::validate().

126  {
127  const T* data = reinterpret_cast<const T*>(dst_data);
128 
130  tbb::blocked_range(size_t(0), num_elements),
131  std::tuple(dataMin, dataMax, has_nulls),
132  [&](const auto& range, auto init) {
133  auto [min, max, nulls] = init;
134  for (size_t i = range.begin(); i < range.end(); i++) {
135  if (data[i] != none_encoded_null_value<T>()) {
137  min = std::min(min, data[i]);
138  max = std::max(max, data[i]);
139  } else {
140  nulls = true;
141  }
142  }
143  return std::tuple(min, max, nulls);
144  },
145  [&](auto lhs, auto rhs) {
146  const auto [lhs_min, lhs_max, lhs_nulls] = lhs;
147  const auto [rhs_min, rhs_max, rhs_nulls] = rhs;
148  return std::tuple(std::min(lhs_min, rhs_min),
149  std::max(lhs_max, rhs_max),
150  lhs_nulls || rhs_nulls);
151  });
152  }
DecimalOverflowValidator decimal_overflow_validator_
Definition: Encoder.h:292
void init(LogOptions const &log_opts)
Definition: Logger.cpp:364
Value parallel_reduce(const blocked_range< Int > &range, const Value &identity, const RealBody &real_body, const Reduction &reduction, const Partitioner &p=Partitioner())
Parallel iteration with reduction.
bool has_nulls
Definition: NoneEncoder.h:222
void validate(T value) const
Definition: Encoder.h:54

+ Here is the call graph for this function:

template<typename T>
T NoneEncoder< T >::validateDataAndUpdateStats ( const T &  unencoded_data,
const bool  is_validated_data = false 
)
inlineprivate

Definition at line 267 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, Encoder::decimal_overflow_validator_, NoneEncoder< T >::has_nulls, and DecimalOverflowValidator::validate().

Referenced by NoneEncoder< T >::appendValidatedOrNonValidatedData(), and NoneEncoder< T >::updateStats().

268  {
269  if (unencoded_data == none_encoded_null_value<T>()) {
270  has_nulls = true;
271  } else {
272  if (!is_validated_data) { // does not need validation
273  decimal_overflow_validator_.validate(unencoded_data);
274  }
275  dataMin = std::min(dataMin, unencoded_data);
276  dataMax = std::max(dataMax, unencoded_data);
277  }
278  return unencoded_data;
279  }
DecimalOverflowValidator decimal_overflow_validator_
Definition: Encoder.h:292
bool has_nulls
Definition: NoneEncoder.h:222
void validate(T value) const
Definition: Encoder.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T>
void NoneEncoder< T >::writeMetadata ( FILE *  f)
inlineoverridevirtual

Implements Encoder.

Definition at line 176 of file NoneEncoder.h.

References NoneEncoder< T >::dataMax, NoneEncoder< T >::dataMin, NoneEncoder< T >::has_nulls, Encoder::num_elems_, and heavydb.dtypes::T.

176  {
177  // assumes pointer is already in right place
178  fwrite((int8_t*)&num_elems_, sizeof(size_t), 1, f);
179  fwrite((int8_t*)&dataMin, sizeof(T), 1, f);
180  fwrite((int8_t*)&dataMax, sizeof(T), 1, f);
181  fwrite((int8_t*)&has_nulls, sizeof(bool), 1, f);
182  }
size_t num_elems_
Definition: Encoder.h:288
bool has_nulls
Definition: NoneEncoder.h:222
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)

Member Data Documentation


The documentation for this class was generated from the following file: