Kuzu::

Database class

Main Kùzu database class

Public Class Methods

new( path, **options ) → database

Create a new Datbase using the given path and options.

static VALUE
rkuzu_database_initialize( int argc, VALUE *argv, VALUE self )
{
        rkuzu_database *ptr = check_database( self );

        if ( !ptr ) {
                VALUE path, options, config;
                VALUE config_argv[1];
                rkuzu_database *ptr = NULL;
                kuzu_system_config *sysconfig;

                rb_scan_args( argc, argv, "1:", &path, &options );
                config_argv[0] = options;
                config = rb_funcallv_public_kw( rkuzu_cKuzuConfig, rb_intern("from_options"), 1,
                        config_argv, RB_PASS_KEYWORDS );
                sysconfig = rkuzu_check_config( config );

                const char *database_path = StringValueCStr( path );
                DATA_PTR( self ) = ptr = rkuzu_database_alloc();
                kuzu_database_init( database_path, *sysconfig, &ptr->db );

                ptr->connections = rb_ary_new();
                ptr->path = rb_obj_freeze( rb_obj_dup(path) );
                ptr->config = rb_obj_freeze( config );

        } else {
                rb_raise( rb_eRuntimeError, "cannot reinit database" );
        }

        rb_call_super( 0, 0 );

        return Qtrue;
}

Public Instance Methods

auto_checkpointing?()

Returns true if this database will automatically checkpoint when the size of the WAL file exceeds the checkpoint_threshold.

# File lib/kuzu/database.rb, line 30
def auto_checkpointing?
        return self.config.auto_checkpoint
end
compression_enabled?()

Returns true if this database uses compression for data on disk.

# File lib/kuzu/database.rb, line 36
def compression_enabled?
        return self.config.enable_compression
end
config() → config

Return the Kuzu::Config that reflects the config options the database was created with.

static VALUE
rkuzu_database_config( VALUE self )
{
        rkuzu_database *ptr = check_database( self );
        return ptr->config;
}
connect()

Return a connection (Kuzu::Connection) to this database.

# File lib/kuzu/database.rb, line 17
def connect
        return Kuzu::Connection.new( self )
end
connections → array

Return the Array of current connections to this Database.

static VALUE
rkuzu_database_connections( VALUE self )
{
        rkuzu_database *ptr = check_database( self );
        VALUE connections = rb_obj_dup( ptr->connections );

        return rb_obj_freeze( connections );
}
inspect()

Return a string representation of the receiver suitable for debugging.

# File lib/kuzu/database.rb, line 42
def inspect
        details = " path:%p read-only:%p" % [
                self.path,
                self.read_only?,
        ]

        default = super
        return default.sub( />/, details + '>' )
end
path() → string or nil

Return the path the database was created with, or nil if it was created in memory.

static VALUE
rkuzu_database_path( VALUE self )
{
        rkuzu_database *ptr = check_database( self );

        if ( RSTRING_LEN(ptr->path) == 0 ) {
                return Qnil;
        } else {
                return ptr->path;
        }
}
read_only?()

Return true if this database was created in read-only mode.

# File lib/kuzu/database.rb, line 23
def read_only?
        return self.config.read_only
end