OmniSciDB  c0231cc57d
 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:1247
int8_t * end_pos
Definition: ChunkIter.h:35
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:873
int skip_size
Definition: ChunkIter.h:37
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:412
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:1247
size_t num_elems
Definition: ChunkIter.h:38
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:873
int skip_size
Definition: ChunkIter.h:37
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:412
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(), ChunkIter::num_elems, ChunkIter::second_buf, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.

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

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

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

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

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

262  {
263  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
264 
265  if (!*is_end) {
266  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
267  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
268  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
269  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
270 
271  if (next_offset >= 0) {
272  // Previous array may have been NULL, remove offset negativity
273  if (offset < 0) {
274  offset = -offset;
275  }
276  result->length = static_cast<size_t>(next_offset - offset);
277  result->pointer = it->second_buf + offset;
278  result->is_null = false;
279  return;
280  }
281  }
282  // Encoded NULL array or out of bounds
283  result->length = 0;
284  result->pointer = NULL;
285  result->is_null = true;
286 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1248
int8_t * second_buf
Definition: ChunkIter.h:32
constexpr double n
Definition: Utm.h:38
DEVICE void ChunkIter_get_nth_varlen_notnull ( ChunkIter it,
int  nth,
ArrayDatum vd,
bool *  is_end 
)

Definition at line 289 of file ChunkIter.cpp.

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

292  {
293  *is_end = (static_cast<size_t>(n) >= it->num_elems || n < 0);
294 
295  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
296  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
297  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
298  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
299 
300  result->length = static_cast<size_t>(next_offset - offset);
301  result->pointer = it->second_buf + offset;
302  result->is_null = false;
303 }
int8_t * start_pos
Definition: ChunkIter.h:34
size_t num_elems
Definition: ChunkIter.h:38
int32_t ArrayOffsetT
Definition: sqltypes.h:1248
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