OmniSciDB  5ade3759e0
ChunkIter.h File Reference
+ Include dependency graph for ChunkIter.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ChunkIter
 

Functions

void ChunkIter_reset (ChunkIter *it)
 
DEVICE void ChunkIter_get_next (ChunkIter *it, bool uncompress, VarlenDatum *vd, bool *is_end)
 
DEVICE void ChunkIter_get_nth (ChunkIter *it, int nth, bool uncompress, VarlenDatum *vd, bool *is_end)
 
DEVICE void ChunkIter_get_nth (ChunkIter *it, int nth, ArrayDatum *vd, bool *is_end)
 
DEVICE void ChunkIter_get_nth_varlen (ChunkIter *it, int nth, ArrayDatum *vd, bool *is_end)
 
DEVICE void ChunkIter_get_nth_varlen_notnull (ChunkIter *it, int nth, ArrayDatum *vd, bool *is_end)
 

Detailed Description

Author
Wei Hong wei@m.nosp@m.apd..nosp@m.com

Definition in file ChunkIter.h.

Function Documentation

◆ ChunkIter_get_next()

DEVICE void ChunkIter_get_next ( ChunkIter it,
bool  uncompress,
VarlenDatum vd,
bool *  is_end 
)

Definition at line 147 of file ChunkIter.cpp.

References ChunkIter::current_pos, ChunkIter::datum, decompress(), ChunkIter::end_pos, SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), VarlenDatum::is_null, SQLTypeInfoCore< TYPE_FACET_PACK >::is_null(), kENCODING_NONE, VarlenDatum::length, VarlenDatum::pointer, ChunkIter::second_buf, ChunkIter::skip, ChunkIter::skip_size, and ChunkIter::type_info.

Referenced by scan_chunk().

150  {
151  if (it->current_pos >= it->end_pos) {
152  *is_end = true;
153  result->length = 0;
154  result->pointer = NULL;
155  result->is_null = true;
156  return;
157  }
158  *is_end = false;
159 
160  if (it->skip_size > 0) {
161  // for fixed-size
162  if (uncompress && (it->type_info.get_compression() != kENCODING_NONE)) {
163  decompress(it->type_info, it->current_pos, result, &it->datum);
164  } else {
165  result->length = static_cast<size_t>(it->skip_size);
166  result->pointer = it->current_pos;
167  result->is_null = it->type_info.is_null(result->pointer);
168  }
169  it->current_pos += it->skip * it->skip_size;
170  } else {
171  StringOffsetT offset = *(StringOffsetT*)it->current_pos;
172  result->length = static_cast<size_t>(*((StringOffsetT*)it->current_pos + 1) - offset);
173  result->pointer = it->second_buf + offset;
174  // @TODO(wei) treat zero length as null for now
175  result->is_null = (result->length == 0);
176  it->current_pos += it->skip * sizeof(StringOffsetT);
177  }
178 }
int8_t * current_pos
Definition: ChunkIter.h:32
SQLTypeInfo type_info
Definition: ChunkIter.h:30
static DEVICE void decompress(const SQLTypeInfo &ti, int8_t *compressed, VarlenDatum *result, Datum *datum)
Definition: ChunkIter.cpp:26
Datum datum
Definition: ChunkIter.h:38
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
int32_t StringOffsetT
Definition: sqltypes.h:877
int8_t * end_pos
Definition: ChunkIter.h:34
int skip_size
Definition: ChunkIter.h:36
int8_t * second_buf
Definition: ChunkIter.h:31
int skip
Definition: ChunkIter.h:35
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:537
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ChunkIter_get_nth() [1/2]

DEVICE void ChunkIter_get_nth ( ChunkIter it,
int  nth,
bool  uncompress,
VarlenDatum vd,
bool *  is_end 
)

Definition at line 181 of file ChunkIter.cpp.

References ChunkIter::datum, decompress(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), VarlenDatum::is_null, SQLTypeInfoCore< TYPE_FACET_PACK >::is_null(), kENCODING_NONE, VarlenDatum::length, ChunkIter::num_elems, VarlenDatum::pointer, ChunkIter::second_buf, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.

Referenced by anonymous_namespace{ResultSetIteration.cpp}::lazy_fetch_chunk(), ResultSet::lazyReadInt(), ResultSet::makeVarlenTargetValue(), scan_chunk(), Importer_NS::RenderGroupAnalyzer::seedFromExistingTableContents(), and string_decode().

185  {
186  if (static_cast<size_t>(n) >= it->num_elems || n < 0) {
187  *is_end = true;
188  result->length = 0;
189  result->pointer = NULL;
190  result->is_null = true;
191  return;
192  }
193  *is_end = false;
194 
195  if (it->skip_size > 0) {
196  // for fixed-size
197  int8_t* current_pos = it->start_pos + n * it->skip_size;
198  if (uncompress && (it->type_info.get_compression() != kENCODING_NONE)) {
199  decompress(it->type_info, current_pos, result, &it->datum);
200  } else {
201  result->length = static_cast<size_t>(it->skip_size);
202  result->pointer = current_pos;
203  result->is_null = it->type_info.is_null(result->pointer);
204  }
205  } else {
206  int8_t* current_pos = it->start_pos + n * sizeof(StringOffsetT);
207  StringOffsetT offset = *(StringOffsetT*)current_pos;
208  result->length = static_cast<size_t>(*((StringOffsetT*)current_pos + 1) - offset);
209  result->pointer = it->second_buf + offset;
210  // @TODO(wei) treat zero length as null for now
211  result->is_null = (result->length == 0);
212  }
213 }
int8_t * start_pos
Definition: ChunkIter.h:33
SQLTypeInfo type_info
Definition: ChunkIter.h:30
static DEVICE void decompress(const SQLTypeInfo &ti, int8_t *compressed, VarlenDatum *result, Datum *datum)
Definition: ChunkIter.cpp:26
Datum datum
Definition: ChunkIter.h:38
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
int32_t StringOffsetT
Definition: sqltypes.h:877
size_t num_elems
Definition: ChunkIter.h:37
int skip_size
Definition: ChunkIter.h:36
int8_t * second_buf
Definition: ChunkIter.h:31
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:537
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ChunkIter_get_nth() [2/2]

DEVICE void ChunkIter_get_nth ( ChunkIter it,
int  nth,
ArrayDatum vd,
bool *  is_end 
)

Definition at line 216 of file ChunkIter.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::is_null_fixlen_array(), ChunkIter::num_elems, ChunkIter::second_buf, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.

216  {
217  if (static_cast<size_t>(n) >= it->num_elems || n < 0) {
218  *is_end = true;
219  result->length = 0;
220  result->pointer = NULL;
221  result->is_null = true;
222  return;
223  }
224  *is_end = false;
225 
226  if (it->skip_size > 0) {
227  // for fixed-size
228  int8_t* current_pos = it->start_pos + n * it->skip_size;
229  result->length = static_cast<size_t>(it->skip_size);
230  result->pointer = current_pos;
231  result->is_null = it->type_info.is_null_fixlen_array(result->pointer, result->length);
232  } else {
233  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
234  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
235  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
236  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
237  if (next_offset < 0) { // Encoded NULL array
238  result->length = 0;
239  result->pointer = NULL;
240  result->is_null = true;
241  } else {
242  if (offset < 0) {
243  offset = -offset; // Previous array may have been NULL, remove negativity
244  }
245  result->length = static_cast<size_t>(next_offset - offset);
246  result->pointer = it->second_buf + offset;
247  result->is_null = false;
248  }
249  }
250 }
int8_t * start_pos
Definition: ChunkIter.h:33
SQLTypeInfo type_info
Definition: ChunkIter.h:30
size_t num_elems
Definition: ChunkIter.h:37
int skip_size
Definition: ChunkIter.h:36
int32_t ArrayOffsetT
Definition: sqltypes.h:878
int8_t * second_buf
Definition: ChunkIter.h:31
HOST DEVICE bool is_null_fixlen_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:599
+ Here is the call graph for this function:

◆ ChunkIter_get_nth_varlen()

DEVICE void ChunkIter_get_nth_varlen ( ChunkIter it,
int  nth,
ArrayDatum vd,
bool *  is_end 
)

Definition at line 253 of file ChunkIter.cpp.

References ChunkIter::num_elems, ChunkIter::second_buf, and ChunkIter::start_pos.

256  {
257  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
258 
259  if (!*is_end) {
260  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
261  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
262  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
263  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
264 
265  if (next_offset >= 0) {
266  // Previous array may have been NULL, remove offset negativity
267  if (offset < 0) {
268  offset = -offset;
269  }
270  result->length = static_cast<size_t>(next_offset - offset);
271  result->pointer = it->second_buf + offset;
272  result->is_null = false;
273  return;
274  }
275  }
276  // Encoded NULL array or out of bounds
277  result->length = 0;
278  result->pointer = NULL;
279  result->is_null = true;
280 }
int8_t * start_pos
Definition: ChunkIter.h:33
size_t num_elems
Definition: ChunkIter.h:37
int32_t ArrayOffsetT
Definition: sqltypes.h:878
int8_t * second_buf
Definition: ChunkIter.h:31

◆ ChunkIter_get_nth_varlen_notnull()

DEVICE void ChunkIter_get_nth_varlen_notnull ( ChunkIter it,
int  nth,
ArrayDatum vd,
bool *  is_end 
)

Definition at line 283 of file ChunkIter.cpp.

References ChunkIter::num_elems, ChunkIter::second_buf, and ChunkIter::start_pos.

286  {
287  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
288 
289  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
290  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
291  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
292  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
293 
294  result->length = static_cast<size_t>(next_offset - offset);
295  result->pointer = it->second_buf + offset;
296  result->is_null = false;
297 }
int8_t * start_pos
Definition: ChunkIter.h:33
size_t num_elems
Definition: ChunkIter.h:37
int32_t ArrayOffsetT
Definition: sqltypes.h:878
int8_t * second_buf
Definition: ChunkIter.h:31

◆ ChunkIter_reset()

void ChunkIter_reset ( ChunkIter it)

Definition at line 143 of file ChunkIter.cpp.

References ChunkIter::current_pos, and ChunkIter::start_pos.

143  {
144  it->current_pos = it->start_pos;
145 }
int8_t * start_pos
Definition: ChunkIter.h:33
int8_t * current_pos
Definition: ChunkIter.h:32