diff options
Diffstat (limited to 'src/arrow/c_glib/example/lua/read-stream.lua')
-rw-r--r-- | src/arrow/c_glib/example/lua/read-stream.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/arrow/c_glib/example/lua/read-stream.lua b/src/arrow/c_glib/example/lua/read-stream.lua new file mode 100644 index 000000000..7bf1083e2 --- /dev/null +++ b/src/arrow/c_glib/example/lua/read-stream.lua @@ -0,0 +1,51 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +local lgi = require 'lgi' +local Arrow = lgi.Arrow + +local input_path = arg[1] or "/tmp/stream.arrow"; + +local input = Arrow.MemoryMappedInputStream.new(input_path) +local reader = Arrow.RecordBatchStreamReader.new(input) + +local i = 0 +while true do + local record_batch = reader:read_next() + if not record_batch then + break + end + + print(string.rep("=", 40)) + print("record-batch["..i.."]:") + for j = 0, record_batch:get_n_columns() - 1 do + local column_name = record_batch:get_column_name(j) + local column_data = record_batch:get_column_data(j) + io.write(" "..column_name..": [") + for k = 0, record_batch:get_n_rows() - 1 do + if k > 0 then + io.write(", ") + end + io.write(column_data:get_value(k)) + end + print("]") + end + + i = i + 1 +end + +input:close() |