OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
 
DEVICE void ChunkIter_get_nth_point_coords (ChunkIter *it, int nth, ArrayDatum *vd, bool *is_end)
 

Function Documentation

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

Definition at line 148 of file ChunkIter.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 182 of file ChunkIter.cpp.

References ChunkIter::datum, decompress(), SQLTypeInfo::get_compression(), VarlenDatum::is_null, SQLTypeInfo::is_null(), FlatBufferManager::isFlatBuffer(), kENCODING_NONE, VarlenDatum::length, ChunkIter::num_elems, VarlenDatum::pointer, ChunkIter::second_buf, ChunkIter::skip_size, ChunkIter::start_pos, ChunkIter::type_info, and VarlenArray_get_nth().

Referenced by anonymous_namespace{ResultSetIteration.cpp}::lazy_fetch_chunk(), ResultSet::lazyReadInt(), ResultSet::makeVarlenTargetValue(), string_decode(), and anonymous_namespace{ExternalExecutor.cpp}::vt_column().

186  {
188  VarlenArray_get_nth(reinterpret_cast<int8_t*>(it), n, uncompress, result, is_end);
189  return;
190  }
191  if (!it || static_cast<size_t>(n) >= it->num_elems || n < 0) {
192  *is_end = true;
193  result->length = 0;
194  result->pointer = NULL;
195  result->is_null = true;
196  return;
197  }
198  *is_end = false;
199 
200  if (it->skip_size > 0) {
201  // for fixed-size
202  int8_t* current_pos = it->start_pos + n * it->skip_size;
203  if (uncompress && (it->type_info.get_compression() != kENCODING_NONE)) {
204  decompress(it->type_info, current_pos, result, &it->datum);
205  } else {
206  result->length = static_cast<size_t>(it->skip_size);
207  result->pointer = current_pos;
208  result->is_null = it->type_info.is_null(result->pointer);
209  }
210  } else {
211  int8_t* current_pos = it->start_pos + n * sizeof(StringOffsetT);
212  StringOffsetT offset = *(StringOffsetT*)current_pos;
213  result->length = static_cast<size_t>(*((StringOffsetT*)current_pos + 1) - offset);
214  result->pointer = it->second_buf + offset;
215  // @TODO(wei) treat zero length as null for now
216  result->is_null = (result->length == 0);
217  }
218 }
int8_t * start_pos
Definition: ChunkIter.h:34
SQLTypeInfo type_info
Definition: ChunkIter.h:31
static DEVICE void decompress(const SQLTypeInfo &ti, int8_t *compressed, VarlenDatum *result, Datum *datum)
Definition: ChunkIter.cpp:27
Datum datum
Definition: ChunkIter.h:39
int32_t StringOffsetT
Definition: sqltypes.h:1493
size_t num_elems
Definition: ChunkIter.h:38
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:866
int skip_size
Definition: ChunkIter.h:37
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528
DEVICE void VarlenArray_get_nth(int8_t *buf, int n, ArrayDatum *result, bool *is_end)
Definition: sqltypes.h:1714

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 221 of file ChunkIter.cpp.

References SQLTypeInfo::get_notnull(), is_null(), SQLTypeInfo::is_null_fixlen_array(), FlatBufferManager::isFlatBuffer(), ChunkIter::num_elems, ChunkIter::second_buf, ChunkIter::skip_size, ChunkIter::start_pos, ChunkIter::type_info, and VarlenArray_get_nth().

221  {
223  VarlenArray_get_nth(reinterpret_cast<int8_t*>(it), n, result, is_end);
224  return;
225  }
226  if (!it || static_cast<size_t>(n) >= it->num_elems || n < 0) {
227  *is_end = true;
228  result->length = 0;
229  result->pointer = NULL;
230  result->is_null = true;
231  return;
232  }
233  *is_end = false;
234 
235  if (it->skip_size > 0) {
236  // for fixed-size
237  int8_t* current_pos = it->start_pos + n * it->skip_size;
238  result->length = static_cast<size_t>(it->skip_size);
239  result->pointer = current_pos;
240  bool is_null = false;
241  if (!it->type_info.get_notnull()) {
242  // Nulls can only be recognized when iterating over a !notnull-typed chunk
243  is_null = it->type_info.is_null_fixlen_array(result->pointer, result->length);
244  }
245  result->is_null = is_null;
246  } else {
247  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
248  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
249  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
250  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
251  if (next_offset < 0) { // Encoded NULL array
252  result->length = 0;
253  result->pointer = NULL;
254  result->is_null = true;
255  } else {
256  if (offset < 0) {
257  offset = -offset; // Previous array may have been NULL, remove negativity
258  }
259  result->length = static_cast<size_t>(next_offset - offset);
260  result->pointer = it->second_buf + offset;
261  result->is_null = false;
262  }
263  }
264 }
int8_t * start_pos
Definition: ChunkIter.h:34
SQLTypeInfo type_info
Definition: ChunkIter.h:31
HOST DEVICE bool is_null_fixlen_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:928
size_t num_elems
Definition: ChunkIter.h:38
CONSTEXPR DEVICE bool is_null(const T &value)
int skip_size
Definition: ChunkIter.h:37
int32_t ArrayOffsetT
Definition: sqltypes.h:1494
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528
DEVICE void VarlenArray_get_nth(int8_t *buf, int n, ArrayDatum *result, bool *is_end)
Definition: sqltypes.h:1714

+ Here is the call graph for this function:

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

Definition at line 321 of file ChunkIter.cpp.

References SQLTypeInfo::get_notnull(), is_null(), SQLTypeInfo::is_null_point_coord_array(), ChunkIter::num_elems, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.

324  {
325  if (!it || static_cast<size_t>(n) >= it->num_elems || n < 0) {
326  *is_end = true;
327  result->length = 0;
328  result->pointer = NULL;
329  result->is_null = true;
330  return;
331  }
332  *is_end = false;
333 
334  assert(it->skip_size > 0);
335  int8_t* current_pos = it->start_pos + n * it->skip_size;
336  result->length = static_cast<size_t>(it->skip_size);
337  result->pointer = current_pos;
338  bool is_null = false;
339  if (!it->type_info.get_notnull()) {
340  // Nulls can only be recognized when iterating over a !notnull-typed chunk
341  is_null = it->type_info.is_null_point_coord_array(result->pointer, result->length);
342  }
343  result->is_null = is_null;
344 }
int8_t * start_pos
Definition: ChunkIter.h:34
SQLTypeInfo type_info
Definition: ChunkIter.h:31
size_t num_elems
Definition: ChunkIter.h:38
CONSTEXPR DEVICE bool is_null(const T &value)
int skip_size
Definition: ChunkIter.h:37
constexpr double n
Definition: Utm.h:38
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
HOST DEVICE bool is_null_point_coord_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:961

+ Here is the call graph for this function:

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

Definition at line 267 of file ChunkIter.cpp.

References FlatBufferManager::isFlatBuffer(), anonymous_namespace{Utm.h}::n, ChunkIter::num_elems, ChunkIter::second_buf, ChunkIter::start_pos, and VarlenArray_get_nth().

270  {
272  VarlenArray_get_nth(reinterpret_cast<int8_t*>(it), n, result, is_end);
273  return;
274  }
275  *is_end = (!it || static_cast<size_t>(n) >= it->num_elems || n < 0);
276 
277  if (!*is_end) {
278  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
279  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
280  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
281  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
282 
283  if (next_offset >= 0) {
284  // Previous array may have been NULL, remove offset negativity
285  if (offset < 0) {
286  offset = -offset;
287  }
288  result->length = static_cast<size_t>(next_offset - offset);
289  result->pointer = it->second_buf + offset;
290  result->is_null = false;
291  return;
292  }
293  }
294  // Encoded NULL array or out of bounds
295  result->length = 0;
296  result->pointer = NULL;
297  result->is_null = true;
298 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1494
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528
DEVICE void VarlenArray_get_nth(int8_t *buf, int n, ArrayDatum *result, bool *is_end)
Definition: sqltypes.h:1714

+ Here is the call graph for this function:

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

Definition at line 301 of file ChunkIter.cpp.

References anonymous_namespace{Utm.h}::n, ChunkIter::num_elems, ChunkIter::second_buf, and ChunkIter::start_pos.

304  {
305  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
306 
307  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
308  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
309  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
310  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
311 
312  result->length = static_cast<size_t>(next_offset - offset);
313  result->pointer = it->second_buf + offset;
314  result->is_null = false;
315 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1494
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38
void ChunkIter_reset ( ChunkIter it)

Definition at line 144 of file ChunkIter.cpp.

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

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