-
Notifications
You must be signed in to change notification settings - Fork 5
/
ChunkedColumnCursor.h
102 lines (80 loc) · 2.44 KB
/
ChunkedColumnCursor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef CHUNKEDCOLUMNCURSOR_H
#define CHUNKEDCOLUMNCURSOR_H
#include <arrow/table.h>
#include "BaseColumnCursor.h"
namespace db {
/**
* A simple column cursor implemented on top of a possibly chunked Arrow column, the hides the
* chunking to present a simpel column structure. This is not directly used for executing queries.
*
* @tparam T The underlying Arrow array type:: for example, arrow::Int64Array.
*/
template<typename T>
class ChunkedColumnCursor : public BaseColumnCursor<T> {
public:
/**
* Create from a column -- initially positioned at first element, if any.
* @param column
*/
explicit ChunkedColumnCursor(std::shared_ptr<arrow::Column> column, TableCursor &table_cursor);
/**
* Will next() produce another element?
* @return
*/
bool hasMore();
/**
* Move to the next element.
* @return True if an element is available, false otherwise (end of column.)
*/
bool next();
/**
* Is the element at the current position null?
* @return
*/
bool isNull();
/**
* Get value at current position.
* @return
*/
typename T::ElementType get();
/**
* Reset to the first element, if any.
*/
void reset();
/**
* Seek to the given position.
* @param to zero-based ordinal position of element in column
* @return True if successful.
*/
bool seek(uint64_t to);
protected:
/**
* Advance to the next chunk in the column's chunk sequence, when the values
* in the current chunk have been exhausted.
* @return True if successful, false if the current chunk was the last.
*/
bool advance_chunk();
private:
/**
* The underlying column
*/
std::shared_ptr<arrow::Column> _column;
/**
* The current chunk of the underlying column
*/
std::shared_ptr<typename T::ArrayType> _current_chunk;
/**
* Offset of current chunk inthe sequence of chunks
*/
int32_t _chunk = 0;
/**
* Offset within the current chunk
*/
int64_t _pos_in_chunk = 0;
/**
* Position within the (logical) column.
*/
int64_t _pos = 0;
};
};
#endif // CHUNKEDCOLUMNCURSOR_H