-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup ffi import/export, finish readme
- Loading branch information
1 parent
1ed1aaa
commit 9c238d1
Showing
21 changed files
with
313 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test { | ||
_ = @import("./build_arrays.zig"); | ||
_ = @import("./ffi.zig"); | ||
_ = @import("./ipc.zig"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const std = @import("std"); | ||
const arrow = @import("arrow"); | ||
|
||
const abi = arrow.abi; | ||
const Builder = arrow.array.Builder; | ||
const DictBuilder = arrow.array.dict.Builder; | ||
const allocator = std.testing.allocator; | ||
|
||
test "build arrays" { | ||
var b = try Builder(?i16).init(allocator); | ||
errdefer b.deinit(); | ||
|
||
try b.append(null); | ||
try b.append(32); | ||
try b.append(33); | ||
try b.append(34); | ||
|
||
const array = try b.finish(); | ||
defer array.deinit(); | ||
} | ||
|
||
test "build dictionary array" { | ||
var b = try DictBuilder(?[]const u8).init(allocator); | ||
errdefer b.deinit(); | ||
|
||
try b.appendNull(); | ||
try b.append("hello"); | ||
try b.append("there"); | ||
try b.append("friend"); | ||
|
||
const array = try b.finish(); | ||
defer array.deinit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const std = @import("std"); | ||
const arrow = @import("arrow"); | ||
|
||
const abi = arrow.ffi.abi; | ||
const allocator = std.testing.allocator; | ||
|
||
test "ffi export" { | ||
const array = try arrow.sample.all(allocator); | ||
errdefer array.deinit(); | ||
|
||
// Note: these are stack allocated. | ||
var abi_arr = try abi.Array.init(array); | ||
var abi_schema = try abi.Schema.init(array); | ||
|
||
// externFn(&abi_schema, &abi_arr); | ||
|
||
// Normally `externFn` would call these. The order doesn't matter. | ||
abi_schema.release.?(&abi_schema); | ||
abi_arr.release.?(&abi_arr); | ||
} | ||
|
||
test "ffi import" { | ||
const array = try arrow.sample.all(allocator); | ||
|
||
var abi_schema = try abi.Schema.init(array); | ||
var abi_arr = try abi.Array.init(array); | ||
var imported = try arrow.ffi.ImportedArray.init(allocator, abi_arr, abi_schema); | ||
defer imported.deinit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const std = @import("std"); | ||
const arrow = @import("arrow"); | ||
|
||
const ipc = arrow.ipc; | ||
const allocator = std.testing.allocator; | ||
|
||
test "read file" { | ||
var ipc_reader = try ipc.reader.fileReader(allocator, "./testdata/tickers.arrow"); | ||
defer ipc_reader.deinit(); | ||
|
||
while (try ipc_reader.nextBatch()) |rb| { | ||
// Do something with rb | ||
defer rb.deinit(); | ||
} | ||
} | ||
|
||
test "write file" { | ||
const batch = try arrow.sample.all(std.testing.allocator); | ||
try batch.toRecordBatch("record batch"); | ||
defer batch.deinit(); | ||
|
||
const fname = "./sample.arrow"; | ||
var ipc_writer = try ipc.writer.fileWriter(std.testing.allocator, fname); | ||
defer ipc_writer.deinit(); | ||
try ipc_writer.write(batch); | ||
try ipc_writer.finish(); | ||
|
||
try std.fs.cwd().deleteFile(fname); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.