MCPcopy Create free account
hub / github.com/apache/arrow / GetSegments

Method GetSegments

cpp/src/arrow/compute/row/grouper.cc:128–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 }
127
128 Result<std::vector<Segment>> GetSegments(const ExecSpan& batch) override {
129 RETURN_NOT_OK(CheckForGetSegments(batch, {key_type_}));
130
131 if (batch.length == 0) {
132 return std::vector<Segment>{};
133 }
134
135 const auto& value = batch.values[0];
136 DCHECK(is_fixed_width(*value.type()));
137
138 std::vector<Segment> segments;
139 const void* key_data;
140 if (value.is_scalar()) {
141 const auto& scalar = *value.scalar;
142 DCHECK(scalar.is_valid);
143 key_data = checked_cast<const PrimitiveScalarBase&>(scalar).data();
144 bool extends = Extend(key_data);
145 segments.push_back(MakeSegment(batch.length, 0, batch.length, extends));
146 } else {
147 DCHECK(value.is_array());
148 const auto& array = value.array;
149 DCHECK_EQ(array.GetNullCount(), 0);
150 auto data = GetValuesAsBytes(array);
151 int64_t byte_width = array.type->byte_width();
152 int64_t offset = 0;
153 bool extends = Extend(data);
154 while (offset < array.length) {
155 int64_t match_length = GetMatchLength(data + offset * byte_width, byte_width,
156 data, offset, array.length);
157 segments.push_back(MakeSegment(array.length, offset, match_length,
158 offset == 0 ? extends : false));
159 offset += match_length;
160 }
161 key_data = data + (array.length - 1) * byte_width;
162 }
163
164 SaveKeyData(key_data);
165
166 return segments;
167 }
168
169 private:
170 static const uint8_t* GetValuesAsBytes(const ArraySpan& data, int64_t offset = 0) {

Callers

nothing calls this directly

Calls 11

CheckForGetSegmentsFunction · 0.85
is_fixed_widthFunction · 0.85
ExtendFunction · 0.85
MakeSegmentFunction · 0.85
is_scalarMethod · 0.80
push_backMethod · 0.80
is_arrayMethod · 0.80
GetNullCountMethod · 0.80
typeMethod · 0.45
dataMethod · 0.45
byte_widthMethod · 0.45

Tested by

no test coverage detected