OmniSciDB  a47db9e897
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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)
 

Detailed Description

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

Definition in file ChunkIter.h.

Function Documentation

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.

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
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
static DEVICE void decompress(const SQLTypeInfo &ti, int8_t *compressed, VarlenDatum *result, Datum *datum)
Definition: ChunkIter.cpp:26
Datum datum
Definition: ChunkIter.h:38
int32_t StringOffsetT
Definition: sqltypes.h:912
int8_t * end_pos
Definition: ChunkIter.h:34
int skip_size
Definition: ChunkIter.h:36
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:564
int8_t * second_buf
Definition: ChunkIter.h:31
int skip
Definition: ChunkIter.h:35

+ 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 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(), 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
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
static DEVICE void decompress(const SQLTypeInfo &ti, int8_t *compressed, VarlenDatum *result, Datum *datum)
Definition: ChunkIter.cpp:26
Datum datum
Definition: ChunkIter.h:38
int32_t StringOffsetT
Definition: sqltypes.h:912
size_t num_elems
Definition: ChunkIter.h:37
int skip_size
Definition: ChunkIter.h:36
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:564
int8_t * second_buf
Definition: ChunkIter.h:31

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

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), anonymous_namespace{TypedDataAccessors.h}::is_null(), 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  bool is_null = false;
232  if (!it->type_info.get_notnull()) {
233  // Nulls can only be recognized when iterating over a !notnull-typed chunk
234  is_null = it->type_info.is_null_fixlen_array(result->pointer, result->length);
235  }
236  result->is_null = is_null;
237  } else {
238  int8_t* current_pos = it->start_pos + n * sizeof(ArrayOffsetT);
239  int8_t* next_pos = current_pos + sizeof(ArrayOffsetT);
240  ArrayOffsetT offset = *(ArrayOffsetT*)current_pos;
241  ArrayOffsetT next_offset = *(ArrayOffsetT*)next_pos;
242  if (next_offset < 0) { // Encoded NULL array
243  result->length = 0;
244  result->pointer = NULL;
245  result->is_null = true;
246  } else {
247  if (offset < 0) {
248  offset = -offset; // Previous array may have been NULL, remove negativity
249  }
250  result->length = static_cast<size_t>(next_offset - offset);
251  result->pointer = it->second_buf + offset;
252  result->is_null = false;
253  }
254  }
255 }
int8_t * start_pos
Definition: ChunkIter.h:33
SQLTypeInfo type_info
Definition: ChunkIter.h:30
size_t num_elems
Definition: ChunkIter.h:37
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:333
int skip_size
Definition: ChunkIter.h:36
bool is_null(const T &v, const SQLTypeInfo &t)
int32_t ArrayOffsetT
Definition: sqltypes.h:913
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:626

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

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

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

Definition at line 288 of file ChunkIter.cpp.

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

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