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

Method CompareColumnsToRows

cpp/src/arrow/compute/row/compare_internal.cc:332–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332void KeyCompare::CompareColumnsToRows(
333 uint32_t num_rows_to_compare, const uint16_t* sel_left_maybe_null,
334 const uint32_t* left_to_right_map, LightContext* ctx, uint32_t* out_num_rows,
335 uint16_t* out_sel_left_maybe_same, const std::vector<KeyColumnArray>& cols,
336 const RowTableImpl& rows, bool are_cols_in_encoding_order,
337 uint8_t* out_match_bitvector_maybe_null) {
338 if (num_rows_to_compare == 0) {
339 if (out_match_bitvector_maybe_null) {
340 DCHECK_EQ(out_num_rows, nullptr);
341 DCHECK_EQ(out_sel_left_maybe_same, nullptr);
342 bit_util::ClearBitmap(out_match_bitvector_maybe_null, 0, num_rows_to_compare);
343 } else {
344 *out_num_rows = 0;
345 }
346 return;
347 }
348
349 // Allocate temporary byte and bit vectors
350 auto bytevector_A_holder =
351 util::TempVectorHolder<uint8_t>(ctx->stack, num_rows_to_compare);
352 auto bytevector_B_holder =
353 util::TempVectorHolder<uint8_t>(ctx->stack, num_rows_to_compare);
354 auto bitvector_holder =
355 util::TempVectorHolder<uint8_t>(ctx->stack, num_rows_to_compare);
356
357 uint8_t* match_bytevector_A = bytevector_A_holder.mutable_data();
358 uint8_t* match_bytevector_B = bytevector_B_holder.mutable_data();
359 uint8_t* match_bitvector = bitvector_holder.mutable_data();
360
361 bool is_first_column = true;
362 for (size_t icol = 0; icol < cols.size(); ++icol) {
363 const KeyColumnArray& col = cols[icol];
364
365 if (col.metadata().is_null_type) {
366 // If this null type col is the first column, the match_bytevector_A needs to be
367 // initialized with 0xFF. Otherwise, the calculation can be skipped
368 if (is_first_column) {
369 std::memset(match_bytevector_A, 0xFF, num_rows_to_compare * sizeof(uint8_t));
370 }
371 continue;
372 }
373
374 uint32_t offset_within_row =
375 rows.metadata().encoded_field_offset(ColIdInEncodingOrder(
376 rows, static_cast<uint32_t>(icol), are_cols_in_encoding_order));
377 if (col.metadata().is_fixed_length) {
378 if (sel_left_maybe_null) {
379 CompareBinaryColumnToRow<true>(
380 offset_within_row, num_rows_to_compare, sel_left_maybe_null,
381 left_to_right_map, ctx, col, rows,
382 is_first_column ? match_bytevector_A : match_bytevector_B);
383 NullUpdateColumnToRow<true>(
384 static_cast<uint32_t>(icol), num_rows_to_compare, sel_left_maybe_null,
385 left_to_right_map, ctx, col, rows, are_cols_in_encoding_order,
386 is_first_column ? match_bytevector_A : match_bytevector_B);
387 } else {
388 // Version without using selection vector
389 CompareBinaryColumnToRow<false>(

Callers

nothing calls this directly

Calls 8

ClearBitmapFunction · 0.85
bytes_to_bitsFunction · 0.85
BytesForBitsFunction · 0.85
bits_filter_indexesFunction · 0.85
bits_to_indexesFunction · 0.85
mutable_dataMethod · 0.45
sizeMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected