こないだインストール した Apache Arrow がとりあえず Ruby でうごくようになったのでメモ

メモ

gemのインストールは前回のインストールを行なえば問題ないです。ですが、arrowを利用しようとすると失敗します。

require "arrow"
/home/katsu/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.1.4/lib/gobject-introspection/loader.rb:37:in `require':GObjectIntrospection::RepositoryError::TypelibNotFound: Typelib file for namespace 'Arrow' (any version) not found

これは GObjectIntrospectionロードに失敗しているようです。 なのでここここを参考に環境変数 GI_TYPELIB_PATH を設定すると読み込まれるようになり実行できます。

$ export GI_TYPELIB_PATH=/path/to/girepository-1.0
$ irb -rarrow

とやるとエラーがなくなります。

最後にサンプルを実行して確認しました!

% ruby write-file.rb
% ruby read-file.rb
========================================
record-batch[0]:
  uint8: [1, 2, 4, 8]
  uint16: [1, 2, 4, 8]
  uint32: [1, 2, 4, 8]
  uint64: [1, 2, 4, 8]
  int8: [1, -2, 4, -8]
  int16: [1, -2, 4, -8]
  int32: [1, -2, 4, -8]
  int64: [1, -2, 4, -8]
  float: [1.100000023841858, -2.200000047683716, 4.400000095367432, -8.800000190734863]
  double: [1.1, -2.2, 4.4, -8.8]
========================================
record-batch[1]:
  uint8: [2, 4, 8]
  uint16: [2, 4, 8]
  uint32: [2, 4, 8]
  uint64: [2, 4, 8]
  int8: [-2, 4, -8]
  int16: [-2, 4, -8]
  int32: [-2, 4, -8]
  int64: [-2, 4, -8]
  float: [-2.200000047683716, 4.400000095367432, -8.800000190734863]
  double: [-2.2, 4.4, -8.8]

おわり

最初ろーどえらーでこまってた