Skip to content
Merged
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
4 changes: 4 additions & 0 deletions ruby/red-arrow-format/lib/arrow-format/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ def build_array(size, validity_buffer, offsets_buffer, values_buffer)
offsets_buffer,
values_buffer)
end

def to_flatbuffers
FB::LargeUtf8::Data.new
end
end

class FixedSizeBinaryType < Type
Expand Down
13 changes: 13 additions & 0 deletions ruby/red-arrow-format/test/test-writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def convert_type(red_arrow_type)
ArrowFormat::LargeBinaryType.singleton
when Arrow::StringDataType
ArrowFormat::UTF8Type.singleton
when Arrow::LargeStringDataType
ArrowFormat::LargeUTF8Type.singleton
else
raise "Unsupported type: #{red_arrow_type.inspect}"
end
Expand Down Expand Up @@ -252,6 +254,17 @@ def test_write
@values)
end
end

sub_test_case("LargeString") do
def build_array
Arrow::LargeStringArray.new(["Hello", nil, "World"])
end

def test_write
assert_equal(["Hello", nil, "World"],
@values)
end
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions ruby/red-arrow/ext/arrow/converters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ namespace red_arrow {
length);
}

inline VALUE convert(const arrow::LargeStringArray& array,
const int64_t i) {
int64_t length;
const auto value = array.GetValue(i, &length);
return rb_utf8_str_new(reinterpret_cast<const char*>(value),
length);
}

inline VALUE convert(const arrow::FixedSizeBinaryArray& array,
const int64_t i) {
return rb_enc_str_new(reinterpret_cast<const char*>(array.Value(i)),
Expand Down
2 changes: 2 additions & 0 deletions ruby/red-arrow/ext/arrow/raw-records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace red_arrow {
VISIT(Binary)
VISIT(LargeBinary)
VISIT(String)
VISIT(LargeString)
VISIT(FixedSizeBinary)
VISIT(Date32)
VISIT(Date64)
Expand Down Expand Up @@ -227,6 +228,7 @@ namespace red_arrow {
VISIT(Binary)
VISIT(LargeBinary)
VISIT(String)
VISIT(LargeString)
VISIT(FixedSizeBinary)
VISIT(Date32)
VISIT(Date64)
Expand Down
1 change: 1 addition & 0 deletions ruby/red-arrow/ext/arrow/values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace red_arrow {
VISIT(Binary)
VISIT(LargeBinary)
VISIT(String)
VISIT(LargeString)
VISIT(FixedSizeBinary)
VISIT(Date32)
VISIT(Date64)
Expand Down
10 changes: 10 additions & 0 deletions ruby/red-arrow/test/raw-records/test-basic-arrays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ def test_string
assert_equal(records, actual_records(target))
end

def test_large_string
records = [
["Ruby"],
[nil],
["\u3042"], # U+3042 HIRAGANA LETTER A
]
target = build({column: :large_string}, records)
assert_equal(records, actual_records(target))
end

def test_date32
records = [
[Date.new(1960, 1, 1)],
Expand Down
10 changes: 10 additions & 0 deletions ruby/red-arrow/test/values/test-basic-arrays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ def test_string
assert_equal(values, target.values)
end

def test_large_string
values = [
"Ruby",
nil,
"\u3042", # U+3042 HIRAGANA LETTER A
]
target = build(Arrow::LargeStringArray.new(values))
assert_equal(values, target.values)
end

def test_date32
values = [
Date.new(1960, 1, 1),
Expand Down
Loading