Kuzu module

The top level namespace for Kuzu classes.

Constants

KUZU_CATALOG_FILENAME

Name of the file to look for when testing a path to see if it’s a Kuzu database.

VERSION

Library version

Public Class Methods

database( path='', **config )

Create and return a Kuzu::Database. If path is nil, an empty string, or the Symbol :memory, creates an in-memory database. Valid options are:

:buffer_pool_size

Max size of the buffer pool in bytes.

:max_num_threads

The maximum number of threads to use during query execution.

:enable_compression

Whether or not to compress data on-disk for supported types

:read_only

If true, open the database in read-only mode. No write transaction is allowed on the Database object. If false, open the database read-write.

:max_db_size

The maximum size of the database in bytes.

:auto_checkpoint

If true, the database will automatically checkpoint when the size of the WAL file exceeds the checkpoint threshold.

:checkpoint_threshold

The threshold of the WAL file size in bytes. When the size of the WAL file exceeds this threshold, the database will checkpoint if auto_checkpoint is true.

# File lib/kuzu.rb, line 51
def self::database( path='', **config )
        path = '' if path.nil? || path == :memory
        self.log.info "Opening database %p" % [ path ]
        return Kuzu::Database.new( path.to_s, **config )
end
is_database?( pathname )

Returns true if the specified pathname appears to be a valid Kuzu database for the current version of the storage format.

# File lib/kuzu.rb, line 60
def self::is_database?( pathname )
        pathname = Pathname( pathname )
        if Kuzu.storage_version <= 38
                return false unless pathname.directory?
                testfile = pathname / KUZU_CATALOG_FILENAME
                return testfile.exist?
        else
                return false unless pathname.file?
                magic = pathname.read( 5 )
                return magic[0, 4] == 'KUZU' && magic[4, 1].ord == Kuzu.storage_version
        end
end
kuzu_version → string

Return the version of the underlying Kuzu library.

static VALUE
rkuzu_s_kuzu_version( VALUE _ )
{
        const char *version = kuzu_get_version();

        return rb_str_new2( version );
}
storage_version → integer

Return the storage version used by the underlying library.

static VALUE
rkuzu_s_storage_version( VALUE _ )
{
        const unsigned long long version = kuzu_get_storage_version();

        return ULONG2NUM( version );
}
timestamp_from_timestamp_ms( milliseconds )

Return a Time object from the given milliseconds epoch time.

# File lib/kuzu.rb, line 76
def self::timestamp_from_timestamp_ms( milliseconds )
        seconds, subsec = milliseconds.divmod( 1_000 )
        return Time.at( seconds, subsec, :millisecond )
end
timestamp_from_timestamp_ns( nanoseconds )

Return a Time object from the given nanoseconds epoch time.

# File lib/kuzu.rb, line 91
def self::timestamp_from_timestamp_ns( nanoseconds )
        seconds, subsec = nanoseconds.divmod( 1_000_000_000 )
        return Time.at( seconds, subsec, :nanosecond )
end
timestamp_from_timestamp_us( microseconds, zone=nil )

Return a Time object from the given microseconds epoch time and optional timezone offset in seconds via the zone argument.

# File lib/kuzu.rb, line 84
def self::timestamp_from_timestamp_us( microseconds, zone=nil )
        seconds, subsec = microseconds.divmod( 1_000_000 )
        return Time.at( seconds, subsec, :microsecond, in: zone )
end