Tuple provides fast, binary-sortable serialization for arrays of simple Ruby types. This means you do not have to deserialize your tuples to store them. This leads to significant performance benifits when using Tuples as keys for a BTree.
As of version 0.4.0 (in this fork) a pure ruby implementation is included, which is used for ruby versions which are not supported by the C-implementation (as of this writing >= 2.3). Its use may be forced on installation by using the compiler flag -DPURE_RUBY. There seems to be no noticeble run time penalty.
A Tuple is just an Array of any number of simple Ruby types. The following types are supported (listed in ascending sort order):
-
NilClass
-
FalseClass
-
Integer (Fixnum or Bignum)
-
String
-
Symbol
-
True
require 'tuple' data = Tuple.dump([1, -43, :foo, "bar", true, false, nil]) => "\000\000\020\000\000\000\000\001..." Tuple.load(data) => [1, -43, :foo, "bar", true, false, nil]
gem install tuple
The binary serialization only supports the integer range -2**(32*255)+1 to 2**(32*255)-1. An ArgumentError is raised in the ruby implementation if these boundaries are exceeded. The C-implementiation produces a result which is outside the correct sort order and cannot be loaded back correctly.
<img src=“https://travis-ci.org/tandem-softworks/tuple.svg?branch=master” alt=“Build Status” />
Copyright © 2009 Justin Balthrop; Published under The MIT License, see LICENSE Copyright © 2017 Jörg Schray; Published under The MIT License, see LICENSE