@@ -62,8 +62,7 @@ void CheckSimpleSearchSorted(const std::shared_ptr<DataType>& type,
6262
6363void CheckSimpleScalarSearchSorted (const std::shared_ptr<DataType>& type,
6464 const std::string& values_json,
65- const std::string& needle_json,
66- uint64_t expected_left,
65+ const std::string& needle_json, uint64_t expected_left,
6766 uint64_t expected_right) {
6867 auto values = ArrayFromJSON (type, values_json);
6968 auto needle = ScalarFromJSON (type, needle_json);
@@ -95,61 +94,55 @@ struct SearchSortedSmokeCase {
9594
9695std::vector<SearchSortedSmokeCase> SupportedTypeSmokeCases () {
9796 return {
98- {" Boolean" , boolean (), " [false, false, true, true]" , " [false, true]" ,
99- " [0, 2] " , " [ 2, 4]" , " true" , 2 , 4 },
100- {" Int8" , int8 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
101- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
102- {" Int16" , int16 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
103- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
104- {" Int32" , int32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
105- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
106- {" Int64" , int64 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
107- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
108- {" UInt8" , uint8 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
109- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
110- {" UInt16" , uint16 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
111- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
112- {" UInt32" , uint32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
113- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
114- {" UInt64" , uint64 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
115- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
97+ {" Boolean" , boolean (), " [false, false, true, true]" , " [false, true]" , " [0, 2] " ,
98+ " [2, 4]" , " true" , 2 , 4 },
99+ {" Int8" , int8 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
100+ " 3" , 1 , 3 },
101+ {" Int16" , int16 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
102+ " 3" , 1 , 3 },
103+ {" Int32" , int32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
104+ " 3" , 1 , 3 },
105+ {" Int64" , int64 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
106+ " 3" , 1 , 3 },
107+ {" UInt8" , uint8 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
108+ " 3" , 1 , 3 },
109+ {" UInt16" , uint16 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
110+ " 3" , 1 , 3 },
111+ {" UInt32" , uint32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
112+ " 3" , 1 , 3 },
113+ {" UInt64" , uint64 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
114+ " 3" , 1 , 3 },
116115 {" Float32" , float32 (), " [1.0, 3.0, 3.0, 5.0]" , " [0.0, 3.0, 4.0, 6.0]" ,
117116 " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , " 3.0" , 1 , 3 },
118117 {" Float64" , float64 (), " [1.0, 3.0, 3.0, 5.0]" , " [0.0, 3.0, 4.0, 6.0]" ,
119118 " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , " 3.0" , 1 , 3 },
120- {" Date32" , date32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" ,
121- " [0, 3, 3, 4] " , " 3" , 1 , 3 },
119+ {" Date32" , date32 (), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
120+ " 3" , 1 , 3 },
122121 {" Date64" , date64 (), " [86400000, 259200000, 259200000, 432000000]" ,
123- " [0, 259200000, 345600000, 518400000]" , " [0, 1, 3, 4]" ,
124- " [0, 3, 3, 4] " , " 259200000" , 1 , 3 },
125- {" Time32" , time32 (TimeUnit::SECOND), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" ,
126- " [0, 1, 3, 4] " , " [0, 3, 3, 4]" , " 3" , 1 , 3 },
127- {" Time64" , time64 (TimeUnit::NANO), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" ,
128- " [0, 1, 3, 4] " , " [0, 3, 3, 4]" , " 3" , 1 , 3 },
122+ " [0, 259200000, 345600000, 518400000]" , " [0, 1, 3, 4]" , " [0, 3, 3, 4] " ,
123+ " 259200000" , 1 , 3 },
124+ {" Time32" , time32 (TimeUnit::SECOND), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4] " ,
125+ " [0, 3, 3, 4]" , " 3" , 1 , 3 },
126+ {" Time64" , time64 (TimeUnit::NANO), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" , " [0, 1, 3, 4] " ,
127+ " [0, 3, 3, 4]" , " 3" , 1 , 3 },
129128 {" Timestamp" , timestamp (TimeUnit::SECOND),
130129 R"( ["1970-01-02", "1970-01-04", "1970-01-04", "1970-01-06"])" ,
131- R"( ["1970-01-01", "1970-01-04", "1970-01-05", "1970-01-07"])" ,
132- " [0, 1, 3, 4] " , " [0, 3, 3, 4]" , R"( "1970-01-04")" , 1 , 3 },
130+ R"( ["1970-01-01", "1970-01-04", "1970-01-05", "1970-01-07"])" , " [0, 1, 3, 4] " ,
131+ " [0, 3, 3, 4]" , R"( "1970-01-04")" , 1 , 3 },
133132 {" Duration" , duration (TimeUnit::NANO), " [1, 3, 3, 5]" , " [0, 3, 4, 6]" ,
134133 " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , " 3" , 1 , 3 },
135- {" Binary" , binary (), R"( ["aa", "bb", "bb", "dd"])" ,
136- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
137- R"( "bb")" , 1 , 3 },
138- {" String" , utf8 (), R"( ["aa", "bb", "bb", "dd"])" ,
139- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
140- R"( "bb")" , 1 , 3 },
134+ {" Binary" , binary (), R"( ["aa", "bb", "bb", "dd"])" , R"( ["a", "bb", "bc", "z"])" ,
135+ " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
136+ {" String" , utf8 (), R"( ["aa", "bb", "bb", "dd"])" , R"( ["a", "bb", "bc", "z"])" ,
137+ " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
141138 {" LargeBinary" , large_binary (), R"( ["aa", "bb", "bb", "dd"])" ,
142- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
143- R"( "bb")" , 1 , 3 },
139+ R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
144140 {" LargeString" , large_utf8 (), R"( ["aa", "bb", "bb", "dd"])" ,
145- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
146- R"( "bb")" , 1 , 3 },
141+ R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
147142 {" BinaryView" , binary_view (), R"( ["aa", "bb", "bb", "dd"])" ,
148- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
149- R"( "bb")" , 1 , 3 },
143+ R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
150144 {" StringView" , utf8_view (), R"( ["aa", "bb", "bb", "dd"])" ,
151- R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" ,
152- R"( "bb")" , 1 , 3 },
145+ R"( ["a", "bb", "bc", "z"])" , " [0, 1, 3, 4]" , " [0, 3, 3, 4]" , R"( "bb")" , 1 , 3 },
153146 };
154147}
155148
@@ -175,9 +168,8 @@ TEST(SearchSorted, ScalarNeedle) {
175168 auto values = ArrayFromJSON (int32 (), " [1, 3, 5, 7]" );
176169
177170 ASSERT_OK_AND_ASSIGN (
178- auto result,
179- SearchSorted (Datum (values), Datum (std::make_shared<Int32Scalar>(5 )),
180- SearchSortedOptions (SearchSortedOptions::Right)));
171+ auto result, SearchSorted (Datum (values), Datum (std::make_shared<Int32Scalar>(5 )),
172+ SearchSortedOptions (SearchSortedOptions::Right)));
181173
182174 ASSERT_TRUE (result.is_scalar ());
183175 ASSERT_EQ (checked_cast<const UInt64Scalar&>(*result.scalar ()).value , 3 );
@@ -281,7 +273,8 @@ TEST(SearchSorted, RejectUnclusteredNullValues) {
281273
282274TEST (SearchSorted, RunEndEncodedNulls) {
283275 auto values_type = run_end_encoded (int16 (), int32 ());
284- ASSERT_OK_AND_ASSIGN (auto ree_values, REEFromJSON (values_type, " [null, null, 2, 4, 4]" ));
276+ ASSERT_OK_AND_ASSIGN (auto ree_values,
277+ REEFromJSON (values_type, " [null, null, 2, 4, 4]" ));
285278 auto needles_type = run_end_encoded (int16 (), int32 ());
286279 ASSERT_OK_AND_ASSIGN (auto ree_needles,
287280 REEFromJSON (needles_type, " [null, null, 1, 4, 4, null, 8]" ));
@@ -402,17 +395,15 @@ TEST_P(SearchSortedSupportedTypesTest, ArraySmoke) {
402395TEST_P (SearchSortedSupportedTypesTest, ScalarSmoke) {
403396 const auto & param = GetParam ();
404397 CheckSimpleScalarSearchSorted (param.type , param.values_json , param.scalar_needle_json ,
405- param.expected_scalar_left ,
406- param.expected_scalar_right );
398+ param.expected_scalar_left , param.expected_scalar_right );
407399}
408400
409- INSTANTIATE_TEST_SUITE_P (
410- SupportedTypes, SearchSortedSupportedTypesTest,
411- ::testing::ValuesIn (SupportedTypeSmokeCases()),
412- [](const ::testing::TestParamInfo<SearchSortedSmokeCase>& info) {
413- return info.param .name ;
414- });
401+ INSTANTIATE_TEST_SUITE_P (SupportedTypes, SearchSortedSupportedTypesTest,
402+ ::testing::ValuesIn (SupportedTypeSmokeCases()),
403+ [](const ::testing::TestParamInfo<SearchSortedSmokeCase>& info) {
404+ return info.param .name ;
405+ });
415406
416407} // namespace
417408} // namespace compute
418- } // namespace arrow
409+ } // namespace arrow
0 commit comments