Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cpp/src/arrow/array/array_dict_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TYPED_TEST(TestDictionaryBuilder, Basic) {
ASSERT_EQ(builder.null_count(), 1);

// Build expected data
auto value_type = std::make_shared<TypeParam>();
auto value_type = TypeTraits<TypeParam>::type_singleton();
auto dict_type = dictionary(int8(), value_type);

std::shared_ptr<Array> result;
Expand All @@ -104,7 +104,7 @@ TYPED_TEST(TestDictionaryBuilder, Basic) {
TYPED_TEST(TestDictionaryBuilder, ArrayInit) {
using c_type = typename TypeParam::c_type;

auto value_type = std::make_shared<TypeParam>();
auto value_type = TypeTraits<TypeParam>::type_singleton();
auto dict_array = ArrayFromJSON(value_type, "[1, 2]");
auto dict_type = dictionary(int8(), value_type);

Expand All @@ -131,7 +131,7 @@ TYPED_TEST(TestDictionaryBuilder, ArrayInit) {
TYPED_TEST(TestDictionaryBuilder, MakeBuilder) {
using c_type = typename TypeParam::c_type;

auto value_type = std::make_shared<TypeParam>();
auto value_type = TypeTraits<TypeParam>::type_singleton();
auto dict_array = ArrayFromJSON(value_type, "[1, 2]");
auto dict_type = dictionary(int8(), value_type);
std::unique_ptr<ArrayBuilder> boxed_builder;
Expand All @@ -158,7 +158,7 @@ TYPED_TEST(TestDictionaryBuilder, MakeBuilder) {
}

TYPED_TEST(TestDictionaryBuilder, ArrayConversion) {
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();

auto intermediate_result = ArrayFromJSON(type, "[1, 2, 1]");
DictionaryBuilder<TypeParam> dictionary_builder;
Expand Down Expand Up @@ -217,7 +217,7 @@ TYPED_TEST(TestDictionaryBuilder, DoubleTableSize) {

TYPED_TEST(TestDictionaryBuilder, DeltaDictionary) {
using c_type = typename TypeParam::c_type;
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();

DictionaryBuilder<TypeParam> builder;

Expand Down Expand Up @@ -250,7 +250,7 @@ TYPED_TEST(TestDictionaryBuilder, DeltaDictionary) {

TYPED_TEST(TestDictionaryBuilder, DoubleDeltaDictionary) {
using c_type = typename TypeParam::c_type;
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();
auto dict_type = dictionary(int8(), type);

DictionaryBuilder<TypeParam> builder;
Expand Down Expand Up @@ -295,7 +295,7 @@ TYPED_TEST(TestDictionaryBuilder, DoubleDeltaDictionary) {

TYPED_TEST(TestDictionaryBuilder, Dictionary32_BasicPrimitive) {
using c_type = typename TypeParam::c_type;
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();
auto dict_type = dictionary(int32(), type);

Dictionary32Builder<TypeParam> builder;
Expand All @@ -316,7 +316,7 @@ TYPED_TEST(TestDictionaryBuilder, Dictionary32_BasicPrimitive) {
TYPED_TEST(TestDictionaryBuilder, FinishResetBehavior) {
// ARROW-6861
using c_type = typename TypeParam::c_type;
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();

Dictionary32Builder<TypeParam> builder;

Expand Down Expand Up @@ -351,7 +351,7 @@ TYPED_TEST(TestDictionaryBuilder, FinishResetBehavior) {

TYPED_TEST(TestDictionaryBuilder, ResetFull) {
using c_type = typename TypeParam::c_type;
auto type = std::make_shared<TypeParam>();
auto type = TypeTraits<TypeParam>::type_singleton();

Dictionary32Builder<TypeParam> builder;

Expand Down
22 changes: 11 additions & 11 deletions cpp/src/arrow/array/array_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestListArray : public ::testing::Test {

void SetUp() {
value_type_ = int16();
type_ = std::make_shared<T>(value_type_);
type_ = TypeTraits<T>::type_instance(value_type_);

std::unique_ptr<ArrayBuilder> tmp;
ASSERT_OK(MakeBuilder(pool_, type_, &tmp));
Expand Down Expand Up @@ -98,7 +98,7 @@ class TestListArray : public ::testing::Test {
auto offsets = std::dynamic_pointer_cast<OffsetArrayType>(result->offsets());
ASSERT_EQ(offsets->length(), result->length() + 1);
ASSERT_EQ(offsets->null_count(), 0);
AssertTypeEqual(*offsets->type(), OffsetType());
AssertTypeEqual(offsets->type(), TypeTraits<OffsetType>::type_singleton());

for (int64_t i = 0; i < result->length(); ++i) {
ASSERT_EQ(offsets->Value(i), result_->raw_value_offsets()[i]);
Expand Down Expand Up @@ -190,7 +190,7 @@ class TestListArray : public ::testing::Test {
}

void TestValuesEquality() {
auto type = std::make_shared<T>(int32());
auto type = TypeTraits<T>::type_instance(int32());
auto left = ArrayFromJSON(type, "[[1, 2], [3], [0]]");
auto right = ArrayFromJSON(type, "[[1, 2], [3], [100000]]");
auto offset = 2;
Expand All @@ -207,7 +207,7 @@ class TestListArray : public ::testing::Test {
&offsets_w_nulls);
ArrayFromVector<OffsetType, offset_type>(offsets, &offsets_wo_nulls);

auto type = std::make_shared<T>(int32());
auto type = TypeTraits<T>::type_instance(int32());
auto expected = std::dynamic_pointer_cast<ArrayType>(
ArrayFromJSON(type, "[[0], null, [0, null], [0]]"));
values = expected->values();
Expand Down Expand Up @@ -260,7 +260,7 @@ class TestListArray : public ::testing::Test {

ArrayFromVector<Int8Type, int8_t>(values_is_valid, values_values, &values);

auto list_type = std::make_shared<T>(int8());
auto list_type = TypeTraits<T>::type_instance(int8());

ASSERT_OK_AND_ASSIGN(auto list1, ArrayType::FromArrays(*offsets1, *values, pool_));
ASSERT_OK_AND_ASSIGN(auto list3, ArrayType::FromArrays(*offsets3, *values, pool_));
Expand Down Expand Up @@ -404,7 +404,7 @@ class TestListArray : public ::testing::Test {
}

void TestBuilderPreserveFieldName() {
auto list_type_with_name = std::make_shared<T>(field("counts", int16()));
auto list_type_with_name = TypeTraits<T>::type_instance(field("counts", int16()));

std::unique_ptr<ArrayBuilder> tmp;
ASSERT_OK(MakeBuilder(pool_, list_type_with_name, &tmp));
Expand All @@ -428,7 +428,7 @@ class TestListArray : public ::testing::Test {
}

void TestFlattenSimple() {
auto type = std::make_shared<T>(int32());
auto type = TypeTraits<T>::type_instance(int32());
auto list_array = std::dynamic_pointer_cast<ArrayType>(
ArrayFromJSON(type, "[[1, 2], [3], [4], null, [5], [], [6]]"));
ASSERT_OK_AND_ASSIGN(auto flattened, list_array->Flatten());
Expand All @@ -437,7 +437,7 @@ class TestListArray : public ::testing::Test {
}

void TestFlattenSliced() {
auto type = std::make_shared<T>(int32());
auto type = TypeTraits<T>::type_instance(int32());
auto list_array = std::dynamic_pointer_cast<ArrayType>(
ArrayFromJSON(type, "[[1, 2], [3], [4], null, [5], [], [6]]"));
auto sliced_list_array =
Expand All @@ -451,7 +451,7 @@ class TestListArray : public ::testing::Test {
}

void TestFlattenNonEmptyBackingNulls() {
auto type = std::make_shared<T>(int32());
auto type = TypeTraits<T>::type_instance(int32());
auto array_data =
std::dynamic_pointer_cast<ArrayType>(
ArrayFromJSON(type, "[[1, 2], [3], null, [5, 6], [7, 8], [], [9]]"))
Expand All @@ -472,7 +472,7 @@ class TestListArray : public ::testing::Test {

Status ValidateOffsets(int64_t length, std::vector<offset_type> offsets,
const std::shared_ptr<Array>& values, int64_t offset = 0) {
auto type = std::make_shared<TypeClass>(values->type());
auto type = TypeTraits<TypeClass>::type_instance(values->type());
ArrayType arr(type, length, Buffer::Wrap(offsets), values,
/*null_bitmap=*/nullptr, /*null_count=*/0, offset);
return arr.ValidateFull();
Expand Down Expand Up @@ -1029,7 +1029,7 @@ TEST_F(TestMapArray, ValueBuilder) {
ASSERT_OK(BuildListOfStructPairs(list_builder, &actual_list));

MapArray* map_ptr = internal::checked_cast<MapArray*>(actual_map.get());
auto list_type = std::make_shared<ListType>(map_type->field(0));
auto list_type = list(map_type->field(0));
ListArray map_as_list(list_type, map_ptr->length(), map_ptr->data()->buffers[1],
map_ptr->values(), actual_map->data()->buffers[0],
map_ptr->null_count());
Expand Down
14 changes: 6 additions & 8 deletions cpp/src/arrow/array/array_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ void LargeListArray::SetData(const std::shared_ptr<ArrayData>& data) {
Result<std::shared_ptr<ListArray>> ListArray::FromArrays(
const Array& offsets, const Array& values, MemoryPool* pool,
std::shared_ptr<Buffer> null_bitmap, int64_t null_count) {
return ListArrayFromArrays<ListType>(std::make_shared<ListType>(values.type()), offsets,
values, pool, null_bitmap, null_count);
return ListArrayFromArrays<ListType>(list(values.type()), offsets, values, pool,
null_bitmap, null_count);
}

Result<std::shared_ptr<ListArray>> ListArray::FromArrays(
Expand All @@ -266,9 +266,8 @@ Result<std::shared_ptr<ListArray>> ListArray::FromArrays(
Result<std::shared_ptr<LargeListArray>> LargeListArray::FromArrays(
const Array& offsets, const Array& values, MemoryPool* pool,
std::shared_ptr<Buffer> null_bitmap, int64_t null_count) {
return ListArrayFromArrays<LargeListType>(
std::make_shared<LargeListType>(values.type()), offsets, values, pool, null_bitmap,
null_count);
return ListArrayFromArrays<LargeListType>(large_list(values.type()), offsets, values,
pool, null_bitmap, null_count);
}

Result<std::shared_ptr<LargeListArray>> LargeListArray::FromArrays(
Expand Down Expand Up @@ -370,8 +369,7 @@ Result<std::shared_ptr<Array>> MapArray::FromArrays(const std::shared_ptr<Array>
const std::shared_ptr<Array>& keys,
const std::shared_ptr<Array>& items,
MemoryPool* pool) {
return FromArraysInternal(std::make_shared<MapType>(keys->type(), items->type()),
offsets, keys, items, pool);
return FromArraysInternal(map(keys->type(), items->type()), offsets, keys, items, pool);
}

Result<std::shared_ptr<Array>> MapArray::FromArrays(std::shared_ptr<DataType> type,
Expand Down Expand Up @@ -473,7 +471,7 @@ Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
"The length of the values Array needs to be a multiple of the list_size");
}
int64_t length = values->length() / list_size;
auto list_type = std::make_shared<FixedSizeListType>(values->type(), list_size);
auto list_type = fixed_size_list(values->type(), list_size);
std::shared_ptr<Buffer> validity_buf;

return std::make_shared<FixedSizeListArray>(list_type, length, values, validity_buf,
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ TEST_F(TestArray, TestMakeArrayFromScalarSliced) {

TEST_F(TestArray, TestMakeArrayFromDictionaryScalar) {
auto dictionary = ArrayFromJSON(utf8(), R"(["foo", "bar", "baz"])");
auto type = std::make_shared<DictionaryType>(int8(), utf8());
auto type = ::arrow::dictionary(int8(), utf8());
ASSERT_OK_AND_ASSIGN(auto value, MakeScalar(int8(), 1));
auto scalar = DictionaryScalar({value, dictionary}, type);

Expand Down Expand Up @@ -978,7 +978,7 @@ struct UniformIntSampleType<int8_t> {
typedef CapType##Type Type; \
typedef c_type T; \
\
static std::shared_ptr<DataType> type() { return std::make_shared<Type>(); }
static std::shared_ptr<DataType> type() { return TypeTraits<Type>::type_singleton(); }

#define PINT_DECL(CapType, c_type) \
struct P##CapType { \
Expand Down Expand Up @@ -2828,7 +2828,7 @@ class DecimalTest : public ::testing::TestWithParam<int> {
std::shared_ptr<Array> TestCreate(int32_t precision, const DecimalVector& draw,
const std::vector<uint8_t>& valid_bytes,
int64_t offset) const {
auto type = std::make_shared<TYPE>(precision, 4);
auto type = TypeTraits<TYPE>::type_instance(precision, 4);
auto builder = std::make_shared<DecimalBuilder>(type);

const size_t size = draw.size();
Expand Down Expand Up @@ -3219,7 +3219,7 @@ TEST(TestSwapEndianArrayData, StringType) {
}

TEST(TestSwapEndianArrayData, ListType) {
auto type1 = std::make_shared<ListType>(int32());
auto type1 = list(int32());
auto array = ArrayFromJSON(type1, "[[0, 1, 2, 3], null, [4, 5]]");
const std::vector<uint8_t> offset1 =
#if ARROW_LITTLE_ENDIAN
Expand All @@ -3238,7 +3238,7 @@ TEST(TestSwapEndianArrayData, ListType) {
test_data = ReplaceBuffersInChild(test_data, 0, data1);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

auto type2 = std::make_shared<LargeListType>(int64());
auto type2 = large_list(int64());
array = ArrayFromJSON(type2, "[[0, 1, 2], null, [3]]");
const std::vector<uint8_t> offset2 =
#if ARROW_LITTLE_ENDIAN
Expand All @@ -3261,7 +3261,7 @@ TEST(TestSwapEndianArrayData, ListType) {
test_data = ReplaceBuffersInChild(test_data, 0, data2);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

auto type3 = std::make_shared<FixedSizeListType>(int32(), 2);
auto type3 = fixed_size_list(int32(), 2);
array = ArrayFromJSON(type3, "[[0, 1], null, [2, 3]]");
expected_data = array->data();
const std::vector<uint8_t> data3 =
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/arrow/array/builder_nested.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class BaseListBuilder : public ArrayBuilder {
}

std::shared_ptr<DataType> type() const override {
return std::make_shared<TYPE>(value_field_->WithType(value_builder_->type()));
return TypeTraits<TYPE>::type_instance(
value_field_->WithType(value_builder_->type()));
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/c/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ struct SchemaImporter {
RETURN_NOT_OK(f_parser_.CheckAtEnd());
RETURN_NOT_OK(CheckNumChildren(1));
ARROW_ASSIGN_OR_RAISE(auto field, MakeChildField(0));
type_ = std::make_shared<ListType>(field);
type_ = list(field);
return Status::OK();
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/exec/hash_join_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Result<std::shared_ptr<ArrayData>> HashJoinDictBuild::RemapOutput(
HashJoinDictUtil::ConvertFromInt32(
index_type_, Datum(indices32Bit), indices32Bit.length, ctx));

auto type = std::make_shared<DictionaryType>(index_type_, value_type_);
auto type = dictionary(index_type_, value_type_);
return ArrayData::Make(type, indices->length, indices->buffers, {},
unified_dictionary_);
}
Expand Down
21 changes: 11 additions & 10 deletions cpp/src/arrow/compute/kernels/scalar_compare_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class TestCompareDecimal : public ::testing::Test {};
TYPED_TEST_SUITE(TestCompareDecimal, DecimalArrowTypes);

TYPED_TEST(TestCompareDecimal, ArrayScalar) {
auto ty = std::make_shared<TypeParam>(3, 2);
auto ty = TypeTraits<TypeParam>::type_instance(3, 2);

std::vector<std::pair<std::string, std::string>> cases = {
{"equal", "[1, 0, 0, null]"}, {"not_equal", "[0, 1, 1, null]"},
Expand All @@ -593,7 +593,7 @@ TYPED_TEST(TestCompareDecimal, ArrayScalar) {
}

TYPED_TEST(TestCompareDecimal, ScalarArray) {
auto ty = std::make_shared<TypeParam>(3, 2);
auto ty = TypeTraits<TypeParam>::type_instance(3, 2);

std::vector<std::pair<std::string, std::string>> cases = {
{"equal", "[1, 0, 0, null]"}, {"not_equal", "[0, 1, 1, null]"},
Expand All @@ -620,7 +620,7 @@ TYPED_TEST(TestCompareDecimal, ScalarArray) {
}

TYPED_TEST(TestCompareDecimal, ArrayArray) {
auto ty = std::make_shared<TypeParam>(3, 2);
auto ty = TypeTraits<TypeParam>::type_instance(3, 2);

std::vector<std::pair<std::string, std::string>> cases = {
{"equal", "[1, 0, 0, 1, 0, 0, null, null]"},
Expand Down Expand Up @@ -659,8 +659,8 @@ TYPED_TEST(TestCompareDecimal, ArrayArray) {
}

TYPED_TEST(TestCompareDecimal, DifferentParameters) {
auto ty1 = std::make_shared<TypeParam>(3, 2);
auto ty2 = std::make_shared<TypeParam>(4, 3);
auto ty1 = TypeTraits<TypeParam>::type_instance(3, 2);
auto ty2 = TypeTraits<TypeParam>::type_instance(4, 3);

std::vector<std::pair<std::string, std::string>> cases = {
{"equal", "[1, 0, 0, 1, 0, 0]"}, {"not_equal", "[0, 1, 1, 0, 1, 1]"},
Expand Down Expand Up @@ -1231,12 +1231,13 @@ template <typename T>
class TestVarArgsCompareDecimal : public TestVarArgsCompare<T> {
protected:
Datum scalar(const std::string& value, int32_t precision = 38, int32_t scale = 2) {
return ScalarFromJSON(std::make_shared<T>(/*precision=*/precision, /*scale=*/scale),
value);
return ScalarFromJSON(
TypeTraits<T>::type_instance(/*precision=*/precision, /*scale=*/scale), value);
}

Datum array(const std::string& value) {
return ArrayFromJSON(std::make_shared<T>(/*precision=*/38, /*scale=*/2), value);
return ArrayFromJSON(TypeTraits<T>::type_instance(/*precision=*/38, /*scale=*/2),
value);
}
};

Expand Down Expand Up @@ -1264,9 +1265,9 @@ class TestVarArgsCompareParametricTemporal : public TestVarArgsCompare<T> {
static std::shared_ptr<DataType> type_singleton() {
// Time32 requires second/milli, Time64 requires nano/micro
if (TypeTraits<T>::bytes_required(1) == 4) {
return std::make_shared<T>(TimeUnit::type::SECOND);
return time32(TimeUnit::type::SECOND);
} else {
return std::make_shared<T>(TimeUnit::type::NANO);
return time64(TimeUnit::type::NANO);
}
}

Expand Down
Loading