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

Function TestListViewSpecificPrettyPrinting

cpp/src/arrow/pretty_print_test.cc:923–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921
922template <typename ListViewType>
923void TestListViewSpecificPrettyPrinting() {
924 using ArrayType = typename TypeTraits<ListViewType>::ArrayType;
925 using OffsetType = typename TypeTraits<ListViewType>::OffsetType;
926
927 auto string_values = ArrayFromJSON(utf8(), R"(["Hello", "World", null])");
928 auto int32_values = ArrayFromJSON(int32(), "[1, 20, 3]");
929 auto int16_values = ArrayFromJSON(int16(), "[10, 2, 30]");
930
931 auto Offsets = [](std::string_view json) {
932 return ArrayFromJSON(TypeTraits<OffsetType>::type_singleton(), json);
933 };
934 auto Sizes = Offsets;
935
936 ASSERT_OK_AND_ASSIGN(auto int_list_view_array,
937 ArrayType::FromArrays(*Offsets("[0, 0, 1, 2]"),
938 *Sizes("[2, 1, 1, 1]"), *int32_values));
939 ASSERT_OK(int_list_view_array->ValidateFull());
940 static const char* ex1 =
941 "[\n"
942 " [\n"
943 " 1,\n"
944 " 20\n"
945 " ],\n"
946 " [\n"
947 " 1\n"
948 " ],\n"
949 " [\n"
950 " 20\n"
951 " ],\n"
952 " [\n"
953 " 3\n"
954 " ]\n"
955 "]";
956 CheckStream(*int_list_view_array, {}, ex1);
957
958 ASSERT_OK_AND_ASSIGN(auto string_list_view_array,
959 ArrayType::FromArrays(*Offsets("[0, 0, 1, 2]"),
960 *Sizes("[2, 1, 1, 1]"), *string_values));
961 ASSERT_OK(string_list_view_array->ValidateFull());
962 static const char* ex2 =
963 "[\n"
964 " [\n"
965 " \"Hello\",\n"
966 " \"World\"\n"
967 " ],\n"
968 " [\n"
969 " \"Hello\"\n"
970 " ],\n"
971 " [\n"
972 " \"World\"\n"
973 " ],\n"
974 " [\n"
975 " null\n"
976 " ]\n"
977 "]";
978 CheckStream(*string_list_view_array, {}, ex2);
979
980 auto sliced_array = string_list_view_array->Slice(1, 2);

Callers

nothing calls this directly

Calls 5

ArrayFromJSONFunction · 0.85
CheckStreamFunction · 0.85
type_singletonFunction · 0.70
ValidateFullMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected