Skip to content

Commit

Permalink
s/AppendToCurrent/ExtendCurrent/
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Jun 7, 2021
1 parent 64f47e5 commit 489f0c8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions cpp/src/arrow/array/array_binary_test.cc
Expand Up @@ -473,7 +473,7 @@ class TestStringBuilder : public TestBuilder {
CheckStringArray(*result_, strings, is_valid, reps);
}

void TestAppendToCurrent() {
void TestExtendCurrent() {
std::vector<std::string> strings = {"", "bbbb", "aaaaa", "", "ccc"};
std::vector<uint8_t> is_valid = {1, 1, 1, 0, 1};

Expand All @@ -486,7 +486,7 @@ class TestStringBuilder : public TestBuilder {
ASSERT_OK(builder_->AppendNull());
} else if (strings[i].length() > 3) {
ASSERT_OK(builder_->Append(strings[i].substr(0, 3)));
ASSERT_OK(builder_->AppendToCurrent(strings[i].substr(3)));
ASSERT_OK(builder_->ExtendCurrent(strings[i].substr(3)));
} else {
ASSERT_OK(builder_->Append(strings[i]));
}
Expand All @@ -501,7 +501,7 @@ class TestStringBuilder : public TestBuilder {
CheckStringArray(*result_, strings, is_valid, reps);
}

void TestAppendToCurrentUnsafe() {
void TestExtendCurrentUnsafe() {
std::vector<std::string> strings = {"", "bbbb", "aaaaa", "", "ccc"};
std::vector<uint8_t> is_valid = {1, 1, 1, 0, 1};

Expand All @@ -521,7 +521,7 @@ class TestStringBuilder : public TestBuilder {
builder_->UnsafeAppendNull();
} else if (strings[i].length() > 3) {
builder_->UnsafeAppend(strings[i].substr(0, 3));
builder_->UnsafeAppendToCurrent(strings[i].substr(3));
builder_->UnsafeExtendCurrent(strings[i].substr(3));
} else {
builder_->UnsafeAppend(strings[i]);
}
Expand Down Expand Up @@ -672,10 +672,10 @@ TYPED_TEST(TestStringBuilder, TestScalarAppend) { this->TestScalarAppend(); }

TYPED_TEST(TestStringBuilder, TestScalarAppendUnsafe) { this->TestScalarAppendUnsafe(); }

TYPED_TEST(TestStringBuilder, TestAppendToCurrent) { this->TestAppendToCurrent(); }
TYPED_TEST(TestStringBuilder, TestExtendCurrent) { this->TestExtendCurrent(); }

TYPED_TEST(TestStringBuilder, TestAppendToCurrentUnsafe) {
this->TestAppendToCurrentUnsafe();
TYPED_TEST(TestStringBuilder, TestExtendCurrentUnsafe) {
this->TestExtendCurrentUnsafe();
}

TYPED_TEST(TestStringBuilder, TestVectorAppend) { this->TestVectorAppend(); }
Expand Down
20 changes: 10 additions & 10 deletions cpp/src/arrow/array/builder_binary.h
Expand Up @@ -77,10 +77,10 @@ class BaseBinaryBuilder : public ArrayBuilder {
return Append(value.data(), static_cast<offset_type>(value.size()));
}

/// Append to the last appended value
/// Extend the last appended value by appending more data at the end
///
/// Unlike Append, this does not create a new offset.
Status AppendToCurrent(const uint8_t* value, offset_type length) {
Status ExtendCurrent(const uint8_t* value, offset_type length) {
// Safety check for UBSAN.
if (ARROW_PREDICT_TRUE(length > 0)) {
ARROW_RETURN_NOT_OK(ValidateOverflow(length));
Expand All @@ -89,9 +89,9 @@ class BaseBinaryBuilder : public ArrayBuilder {
return Status::OK();
}

Status AppendToCurrent(util::string_view value) {
return AppendToCurrent(reinterpret_cast<const uint8_t*>(value.data()),
static_cast<offset_type>(value.size()));
Status ExtendCurrent(util::string_view value) {
return ExtendCurrent(reinterpret_cast<const uint8_t*>(value.data()),
static_cast<offset_type>(value.size()));
}

Status AppendNulls(int64_t length) final {
Expand Down Expand Up @@ -150,14 +150,14 @@ class BaseBinaryBuilder : public ArrayBuilder {
UnsafeAppend(value.data(), static_cast<offset_type>(value.size()));
}

/// Like AppendToCurrent, but do not check capacity
void UnsafeAppendToCurrent(const uint8_t* value, offset_type length) {
/// Like ExtendCurrent, but do not check capacity
void UnsafeExtendCurrent(const uint8_t* value, offset_type length) {
value_data_builder_.UnsafeAppend(value, length);
}

void UnsafeAppendToCurrent(util::string_view value) {
UnsafeAppendToCurrent(reinterpret_cast<const uint8_t*>(value.data()),
static_cast<offset_type>(value.size()));
void UnsafeExtendCurrent(util::string_view value) {
UnsafeExtendCurrent(reinterpret_cast<const uint8_t*>(value.data()),
static_cast<offset_type>(value.size()));
}

void UnsafeAppendNull() {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/kernels/scalar_string.cc
Expand Up @@ -2655,8 +2655,8 @@ struct BinaryJoin {
}
builder->UnsafeAppend(strings.GetView(j_start));
for (int64_t j = j_start + 1; j < j_end; ++j) {
builder->UnsafeAppendToCurrent(separators.GetView(i));
builder->UnsafeAppendToCurrent(strings.GetView(j));
builder->UnsafeExtendCurrent(separators.GetView(i));
builder->UnsafeExtendCurrent(strings.GetView(j));
}
}

Expand Down
2 changes: 0 additions & 2 deletions cpp/src/arrow/compute/kernels/test_util.cc
Expand Up @@ -35,8 +35,6 @@ namespace compute {

namespace {

using DatumVector = std::vector<Datum>;

template <typename T>
DatumVector GetDatums(const std::vector<T>& inputs) {
std::vector<Datum> datums;
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/compute/kernels/test_util.h
Expand Up @@ -43,6 +43,8 @@ using internal::checked_cast;

namespace compute {

using DatumVector = std::vector<Datum>;

template <typename Type, typename T>
std::shared_ptr<Array> _MakeArray(const std::shared_ptr<DataType>& type,
const std::vector<T>& values,
Expand Down Expand Up @@ -93,7 +95,7 @@ void CheckScalar(std::string func_name, const ScalarVector& inputs,
std::shared_ptr<Scalar> expected,
const FunctionOptions* options = nullptr);

void CheckScalar(std::string func_name, const ArrayVector& inputs,
void CheckScalar(std::string func_name, const DatumVector& inputs,
std::shared_ptr<Array> expected,
const FunctionOptions* options = nullptr);

Expand Down

0 comments on commit 489f0c8

Please sign in to comment.