MCPcopy Create free account
hub / github.com/ByConity/ByConity / readImpl

Method readImpl

src/DataStreams/LimitBlockInputStream.cpp:42–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42Block LimitBlockInputStream::readImpl()
43{
44 Block res;
45 UInt64 rows = 0;
46
47 /// pos >= offset + limit and all rows in the end of previous block were equal
48 /// to row at 'limit' position. So we check current block.
49 if (!ties_row_ref.empty() && pos >= offset + limit)
50 {
51 res = children.back()->read();
52 rows = res.rows();
53
54 if (!res)
55 return res;
56
57 SharedBlockPtr ptr = new detail::SharedBlock(std::move(res));
58 ptr->sort_columns = extractSortColumns(*ptr, description);
59
60 UInt64 len;
61 for (len = 0; len < rows; ++len)
62 {
63 SharedBlockRowRef current_row;
64 current_row.set(ptr, &ptr->sort_columns, len);
65
66 if (current_row != ties_row_ref)
67 {
68 ties_row_ref.reset();
69 break;
70 }
71 }
72
73 if (len < rows)
74 {
75 for (size_t i = 0; i < ptr->columns(); ++i)
76 ptr->safeGetByPosition(i).column = ptr->safeGetByPosition(i).column->cut(0, len);
77 }
78
79 return *ptr;
80 }
81
82 if (pos >= offset + limit)
83 {
84 if (!always_read_till_end)
85 return res;
86 else
87 {
88 while (children.back()->read())
89 ;
90 return res;
91 }
92 }
93
94 do
95 {
96 res = children.back()->read();
97 if (!res)
98 return res;
99 rows = res.rows();

Callers

nothing calls this directly

Calls 10

extractSortColumnsFunction · 0.85
columnsMethod · 0.80
maxFunction · 0.50
minFunction · 0.50
emptyMethod · 0.45
readMethod · 0.45
rowsMethod · 0.45
setMethod · 0.45
resetMethod · 0.45
cutMethod · 0.45

Tested by

no test coverage detected