OmniSciDB  c1a53651b2
 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->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:1258
int8_t * end_pos
Definition: ChunkIter.h:35
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:854
int skip_size
Definition: ChunkIter.h:37
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
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(), 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(), import_export::RenderGroupAnalyzer::seedFromExistingTableContents(), string_decode(), and anonymous_namespace{ExternalExecutor.cpp}::vt_column().

186  {
187  if (static_cast<size_t>(n) >= it->num_elems || n < 0) {
188  *is_end = true;
189  result->length = 0;
190  result->pointer = NULL;
191  result->is_null = true;
192  return;
193  }
194  *is_end = false;
195 
196  if (it->skip_size > 0) {
197  // for fixed-size
198  int8_t* current_pos = it->start_pos + n * it->skip_size;
199  if (uncompress && (it->type_info.get_compression() != kENCODING_NONE)) {
200  decompress(it->type_info, current_pos, result, &it->datum);
201  } else {
202  result->length = static_cast<size_t>(it->skip_size);
203  result->pointer = current_pos;
204  result->is_null = it->type_info.is_null(result->pointer);
205  }
206  } else {
207  int8_t* current_pos = it->start_pos + n * sizeof(StringOffsetT);
208  StringOffsetT offset = *(StringOffsetT*)current_pos;
209  result->length = static_cast<size_t>(*((StringOffsetT*)current_pos + 1) - offset);
210  result->pointer = it->second_buf + offset;
211  // @TODO(wei) treat zero length as null for now
212  result->is_null = (result->length == 0);
213  }
214 }
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:1258
size_t num_elems
Definition: ChunkIter.h:38
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:854
int skip_size
Definition: ChunkIter.h:37
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38

+ 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 217 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().

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

+ 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 317 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.

320  {
321  if (static_cast<size_t>(n) >= it->num_elems || n < 0) {
322  *is_end = true;
323  result->length = 0;
324  result->pointer = NULL;
325  result->is_null = true;
326  return;
327  }
328  *is_end = false;
329 
330  assert(it->skip_size > 0);
331  int8_t* current_pos = it->start_pos + n * it->skip_size;
332  result->length = static_cast<size_t>(it->skip_size);
333  result->pointer = current_pos;
334  bool is_null = false;
335  if (!it->type_info.get_notnull()) {
336  // Nulls can only be recognized when iterating over a !notnull-typed chunk
337  is_null = it->type_info.is_null_point_coord_array(result->pointer, result->length);
338  }
339  result->is_null = is_null;
340 }
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:388
HOST DEVICE bool is_null_point_coord_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:949

+ 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 263 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().

266  {
268  VarlenArray_get_nth(reinterpret_cast<int8_t*>(it), n, result, is_end);
269  return;
270  }
271  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
272 
273  if (!*is_end) {
274  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
275  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
276  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
277  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
278 
279  if (next_offset >= 0) {
280  // Previous array may have been NULL, remove offset negativity
281  if (offset < 0) {
282  offset = -offset;
283  }
284  result->length = static_cast<size_t>(next_offset - offset);
285  result->pointer = it->second_buf + offset;
286  result->is_null = false;
287  return;
288  }
289  }
290  // Encoded NULL array or out of bounds
291  result->length = 0;
292  result->pointer = NULL;
293  result->is_null = true;
294 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1259
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:186
DEVICE void VarlenArray_get_nth(int8_t *buf, int n, ArrayDatum *result, bool *is_end)
Definition: sqltypes.h:1503

+ 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 297 of file ChunkIter.cpp.

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

300  {
301  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
302 
303  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
304  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
305  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
306  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
307 
308  result->length = static_cast<size_t>(next_offset - offset);
309  result->pointer = it->second_buf + offset;
310  result->is_null = false;
311 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1259
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