Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Feb 9, 2024
1 parent b72c9c5 commit 1f046d3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/row/compare_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void KeyCompare::CompareBinaryColumnToRowHelper(
for (int32_t i = first_row_to_compare; i < num_rows_to_compare; ++i) {
uint32_t irow_left = use_selection ? sel_left_maybe_null[i] : i;
uint32_t irow_right = left_to_right_map[irow_left];
uint32_t offset_right = irow_right * fixed_length + offset_within_row;
int32_t offset_right = irow_right * fixed_length + offset_within_row;
match_bytevector[i] = compare_fn(rows_left, rows_right, irow_left, offset_right);
}
} else {
Expand Down
28 changes: 15 additions & 13 deletions cpp/src/arrow/compute/row/encode_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Status RowTableEncoder::EncodeSelected(RowTableImpl* rows, uint32_t num_selected

for (size_t icol = 0; icol < batch_all_cols_.size(); ++icol) {
if (batch_all_cols_[icol].metadata().is_fixed_length) {
uint32_t offset_within_row = rows->metadata().column_offsets[icol];
int32_t offset_within_row = rows->metadata().column_offsets[icol];
EncoderBinary::EncodeSelected(offset_within_row, rows, batch_all_cols_[icol],
num_selected, selection);
}
Expand All @@ -188,7 +188,7 @@ struct TransformBoolean {
const KeyColumnArray& temp) {
// Make sure that the temp buffer is large enough
DCHECK(temp.length() >= column.length() && temp.metadata().is_fixed_length &&
temp.metadata().fixed_length >= int32_t(sizeof(uint8_t)));
temp.metadata().fixed_length >= static_cast<int32_t>(sizeof(uint8_t)));
KeyColumnMetadata metadata;
metadata.is_fixed_length = true;
metadata.fixed_length = sizeof(uint8_t);
Expand Down Expand Up @@ -238,7 +238,7 @@ void EncoderInteger::PostDecode(const KeyColumnArray& input, KeyColumnArray* out
}

void EncoderInteger::Decode(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col, LightContext* ctx,
KeyColumnArray* temp) {
KeyColumnArray col_prep;
Expand Down Expand Up @@ -327,7 +327,7 @@ void EncoderInteger::Decode(uint32_t start_row, uint32_t num_rows,
}

template <class COPY_FN, class SET_NULL_FN>
void EncoderBinary::EncodeSelectedImp(uint32_t offset_within_row, RowTableImpl* rows,
void EncoderBinary::EncodeSelectedImp(int32_t offset_within_row, RowTableImpl* rows,
const KeyColumnArray& col, uint32_t num_selected,
const uint16_t* selection, COPY_FN copy_fn,
SET_NULL_FN set_null_fn) {
Expand Down Expand Up @@ -372,7 +372,7 @@ void EncoderBinary::EncodeSelectedImp(uint32_t offset_within_row, RowTableImpl*
}
}

void EncoderBinary::EncodeSelected(uint32_t offset_within_row, RowTableImpl* rows,
void EncoderBinary::EncodeSelected(int32_t offset_within_row, RowTableImpl* rows,
const KeyColumnArray& col, uint32_t num_selected,
const uint16_t* selection) {
if (col.metadata().is_null_type) {
Expand Down Expand Up @@ -441,7 +441,7 @@ bool EncoderBinary::IsInteger(const KeyColumnMetadata& metadata) {
}

void EncoderBinary::Decode(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col, LightContext* ctx, KeyColumnArray* temp) {
if (IsInteger(col->metadata())) {
EncoderInteger::Decode(start_row, num_rows, offset_within_row, rows, col, ctx, temp);
Expand Down Expand Up @@ -478,7 +478,7 @@ void EncoderBinary::Decode(uint32_t start_row, uint32_t num_rows,

template <bool is_row_fixed_length>
void EncoderBinary::DecodeImp(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col) {
DecodeHelper<is_row_fixed_length>(
start_row, num_rows, offset_within_row, &rows, nullptr, col, col,
Expand All @@ -492,7 +492,7 @@ void EncoderBinary::DecodeImp(uint32_t start_row, uint32_t num_rows,
}

void EncoderBinaryPair::Decode(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col1, KeyColumnArray* col2,
LightContext* ctx, KeyColumnArray* temp1,
KeyColumnArray* temp2) {
Expand Down Expand Up @@ -567,7 +567,7 @@ void EncoderBinaryPair::Decode(uint32_t start_row, uint32_t num_rows,

template <bool is_row_fixed_length, typename col1_type, typename col2_type>
void EncoderBinaryPair::DecodeImp(uint32_t num_rows_to_skip, uint32_t start_row,
uint32_t num_rows, uint32_t offset_within_row,
uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col1,
KeyColumnArray* col2) {
DCHECK(rows.length() >= start_row + num_rows);
Expand Down Expand Up @@ -648,11 +648,11 @@ void EncoderOffsets::Decode(uint32_t start_row, uint32_t num_rows,
const int32_t* varbinary_ends = rows.metadata().varbinary_end_array(row);

// Update the offset of each column
uint32_t offset_within_row = rows.metadata().fixed_length;
int32_t offset_within_row = rows.metadata().fixed_length;
for (size_t col = 0; col < varbinary_cols->size(); ++col) {
offset_within_row +=
RowTableMetadata::padding_for_alignment(offset_within_row, string_alignment);
uint32_t length = varbinary_ends[col] - offset_within_row;
int32_t length = varbinary_ends[col] - offset_within_row;
offset_within_row = varbinary_ends[col];
int32_t* col_offsets = (*varbinary_cols)[col].mutable_offsets();
col_offsets[i + 1] = col_offsets[i] + length;
Expand Down Expand Up @@ -848,15 +848,17 @@ void EncoderVarBinary::EncodeSelected(uint32_t ivarbinary, RowTableImpl* rows,
if (ivarbinary == 0) {
for (uint32_t i = 0; i < num_selected; ++i) {
uint8_t* row = row_base + row_offsets[i];
int32_t row_offset, length;
int32_t row_offset;
int32_t length;
rows->metadata().first_varbinary_offset_and_length(row, &row_offset, &length);
uint32_t irow = selection[i];
memcpy(row + row_offset, col_base + col_offsets[irow], length);
}
} else {
for (uint32_t i = 0; i < num_selected; ++i) {
uint8_t* row = row_base + row_offsets[i];
int32_t row_offset, length;
int32_t row_offset;
int32_t length;
rows->metadata().nth_varbinary_offset_and_length(row, ivarbinary, &row_offset,
&length);
uint32_t irow = selection[i];
Expand Down
27 changes: 14 additions & 13 deletions cpp/src/arrow/compute/row/encode_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ARROW_EXPORT RowTableEncoder {

class EncoderInteger {
public:
static void Decode(uint32_t start_row, uint32_t num_rows, uint32_t offset_within_row,
static void Decode(uint32_t start_row, uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col, LightContext* ctx,
KeyColumnArray* temp);
static bool UsesTransform(const KeyColumnArray& column);
Expand All @@ -137,24 +137,24 @@ class EncoderInteger {

class EncoderBinary {
public:
static void EncodeSelected(uint32_t offset_within_row, RowTableImpl* rows,
static void EncodeSelected(int32_t offset_within_row, RowTableImpl* rows,
const KeyColumnArray& col, uint32_t num_selected,
const uint16_t* selection);
static void Decode(uint32_t start_row, uint32_t num_rows, uint32_t offset_within_row,
static void Decode(uint32_t start_row, uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col, LightContext* ctx,
KeyColumnArray* temp);
static bool IsInteger(const KeyColumnMetadata& metadata);

private:
template <class COPY_FN, class SET_NULL_FN>
static void EncodeSelectedImp(uint32_t offset_within_row, RowTableImpl* rows,
static void EncodeSelectedImp(int32_t offset_within_row, RowTableImpl* rows,
const KeyColumnArray& col, uint32_t num_selected,
const uint16_t* selection, COPY_FN copy_fn,
SET_NULL_FN set_null_fn);

template <bool is_row_fixed_length, class COPY_FN>
static inline void DecodeHelper(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row,
int32_t offset_within_row,
const RowTableImpl* rows_const,
RowTableImpl* rows_mutable_maybe_null,
const KeyColumnArray* col_const,
Expand Down Expand Up @@ -185,15 +185,15 @@ class EncoderBinary {
}

template <bool is_row_fixed_length>
static void DecodeImp(uint32_t start_row, uint32_t num_rows, uint32_t offset_within_row,
static void DecodeImp(uint32_t start_row, uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col);
#if defined(ARROW_HAVE_RUNTIME_AVX2)
static void DecodeHelper_avx2(bool is_row_fixed_length, uint32_t start_row,
uint32_t num_rows, uint32_t offset_within_row,
uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col);
template <bool is_row_fixed_length>
static void DecodeImp_avx2(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col);
#endif
};
Expand All @@ -204,23 +204,23 @@ class EncoderBinaryPair {
const KeyColumnMetadata& col2) {
return EncoderBinary::IsInteger(col1) && EncoderBinary::IsInteger(col2);
}
static void Decode(uint32_t start_row, uint32_t num_rows, uint32_t offset_within_row,
static void Decode(uint32_t start_row, uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col1, KeyColumnArray* col2,
LightContext* ctx, KeyColumnArray* temp1, KeyColumnArray* temp2);

private:
template <bool is_row_fixed_length, typename col1_type, typename col2_type>
static void DecodeImp(uint32_t num_rows_to_skip, uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col1, KeyColumnArray* col2);
#if defined(ARROW_HAVE_RUNTIME_AVX2)
static uint32_t DecodeHelper_avx2(bool is_row_fixed_length, uint32_t col_width,
uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col1, KeyColumnArray* col2);
template <bool is_row_fixed_length, uint32_t col_width>
static uint32_t DecodeImp_avx2(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col1, KeyColumnArray* col2);
#endif
};
Expand Down Expand Up @@ -278,7 +278,8 @@ class EncoderVarBinary {
int32_t row_offset = row_offsets_for_batch[i];
const uint8_t* row = rows_const->data(2) + row_offset;

int32_t offset_within_row, length;
int32_t offset_within_row;
int32_t length;
if (first_varbinary_col) {
rows_const->metadata().first_varbinary_offset_and_length(row, &offset_within_row,
&length);
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/arrow/compute/row/encode_internal_avx2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace arrow {
namespace compute {

void EncoderBinary::DecodeHelper_avx2(bool is_row_fixed_length, uint32_t start_row,
uint32_t num_rows, uint32_t offset_within_row,
uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col) {
if (is_row_fixed_length) {
DecodeImp_avx2<true>(start_row, num_rows, offset_within_row, rows, col);
Expand All @@ -34,7 +34,7 @@ void EncoderBinary::DecodeHelper_avx2(bool is_row_fixed_length, uint32_t start_r

template <bool is_row_fixed_length>
void EncoderBinary::DecodeImp_avx2(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows,
int32_t offset_within_row, const RowTableImpl& rows,
KeyColumnArray* col) {
DecodeHelper<is_row_fixed_length>(
start_row, num_rows, offset_within_row, &rows, nullptr, col, col,
Expand All @@ -49,10 +49,10 @@ void EncoderBinary::DecodeImp_avx2(uint32_t start_row, uint32_t num_rows,

uint32_t EncoderBinaryPair::DecodeHelper_avx2(
bool is_row_fixed_length, uint32_t col_width, uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row, const RowTableImpl& rows, KeyColumnArray* col1,
int32_t offset_within_row, const RowTableImpl& rows, KeyColumnArray* col1,
KeyColumnArray* col2) {
using DecodeImp_avx2_t =
uint32_t (*)(uint32_t start_row, uint32_t num_rows, uint32_t offset_within_row,
uint32_t (*)(uint32_t start_row, uint32_t num_rows, int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col1, KeyColumnArray* col2);
static const DecodeImp_avx2_t DecodeImp_avx2_fn[] = {
DecodeImp_avx2<false, 1>, DecodeImp_avx2<false, 2>, DecodeImp_avx2<false, 4>,
Expand All @@ -66,7 +66,7 @@ uint32_t EncoderBinaryPair::DecodeHelper_avx2(

template <bool is_row_fixed_length, uint32_t col_width>
uint32_t EncoderBinaryPair::DecodeImp_avx2(uint32_t start_row, uint32_t num_rows,
uint32_t offset_within_row,
int32_t offset_within_row,
const RowTableImpl& rows, KeyColumnArray* col1,
KeyColumnArray* col2) {
ARROW_DCHECK(col_width == 1 || col_width == 2 || col_width == 4 || col_width == 8);
Expand Down

0 comments on commit 1f046d3

Please sign in to comment.