unqlitego

package module
v0.0.0-...-3c31784 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2018 License: BSD-2-Clause Imports: 5 Imported by: 2

README

unqlitego Build Status

UnQLite Binding for golang.

Install

$ go get github.com/GJRTimmer/unqlitego

Dependencies

Dependencies are management by Golang Dep

$ go get github.com/golang/dep/cmd/dep
$ dep ensure

Test

$ cd ${GOPATH/:*/}/src/github.com/GJRTimmer/unqlitego
$ go test .

Benchmark

$ cd ${GOPATH/:*/}/src/github.com/GJRTimmer/unqlitego
$ go test -bench Bench*

Output:(Lenovo T560 i7-6600U, 16GB Memory, Win:10)

BenchmarkFileStore-4      500000              5946 ns/op
BenchmarkFileFetch-4      500000              2941 ns/op
BenchmarkMemStore-4      1000000              2695 ns/op
BenchmarkMemFetch-4      1000000              2287 ns/op

Output:(Clevo-N850HK1 i7-7700HQ, 32GB Memory, Ubuntu:17.10)

BenchmarkFileStore-8      500000              3746 ns/op
BenchmarkFileFetch-8     1000000              1940 ns/op
BenchmarkMemStore-8      1000000              1714 ns/op
BenchmarkMemFetch-8      1000000              1715 ns/op

Documentation

Overview

Package unqlitego provides a Golang binding for UnQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

Cursor represents an UnQLite database cursor.

func (*Cursor) Close

func (cr *Cursor) Close() error

Close closes the open cursor.

func (*Cursor) Delete

func (cr *Cursor) Delete() error

Delete current cursor entry.

func (*Cursor) First

func (cr *Cursor) First() error

First returns the first entry of the cursor.

func (*Cursor) IsValid

func (cr *Cursor) IsValid() bool

IsValid returns a boolean indicating if the cursor is valid.

func (*Cursor) Key

func (cr *Cursor) Key() (key []byte, err error)

Key returns the key at the current cursor location.

func (*Cursor) Last

func (cr *Cursor) Last() error

Last returns the last entry of the cursor.

func (*Cursor) Next

func (cr *Cursor) Next() error

Next moves the cursor to the next entry.

func (*Cursor) Prev

func (cr *Cursor) Prev() error

Prev moves the cursor the the previous entry.

func (*Cursor) Reset

func (cr *Cursor) Reset() error

Reset the cursor.

func (*Cursor) Seek

func (cr *Cursor) Seek(key []byte) error

Seek will search the cursor for an exact match. If the record exists the cursor is left pointing to it. Otherwise it is left pointing to EOF and UNQLITE_NOTFOUND is returned.

func (*Cursor) SeekGE

func (cr *Cursor) SeekGE(key []byte) error

SeekGE will search the cursor and left pointing to the smallest key in the database that is larger than (pKey/nKey). If the database contains no keys larger than (pKey/nKey), the cursor is left at EOF. This option have sense only if the underlying key/value storage subsystem support range search (i.e: B+Tree, R+Tree, etc.). Otherwise this option is ignored and an exact match is performed.

func (*Cursor) SeekLE

func (cr *Cursor) SeekLE(key []byte) error

SeekLE will search the cursor and left pointing to the largest key in the database that is smaller than (pKey/nKey). If the database contains no keys smaller than (pKey/nKey), the cursor is left at EOF. This option have sense only if the underlying key/value storage subsystem support range search (i.e: B+Tree, R+Tree, etc.). Otherwise this option is ignored and an exact match is performed.

func (*Cursor) Value

func (cr *Cursor) Value() (value []byte, err error)

Value returns the value at the current cursor position.

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a UnQLite Database.

func NewDatabase

func NewDatabase(filename string) (db *Database, err error)

NewDatabase creates and initalizes a new UnQLite database connection.

func (*Database) Append

func (db *Database) Append(key, value []byte) (err error)

Append will write a new record into the database. If the record does not exists it will be created, else the new data is appended to the end of the old data.

func (*Database) Begin

func (db *Database) Begin() (err error)

Begin will start a transaction.

func (*Database) Close

func (db *Database) Close() (err error)

Close will close the database connection.

func (*Database) Commit

func (db *Database) Commit() (err error)

Commit will commit a transaction to the database.

func (*Database) Compile

func (db *Database) Compile(jx9 string, vm *VM) (string, error)

Compile a JX9 Script into a Virtual Machine.

func (*Database) Cursor

func (db *Database) Cursor() (*Cursor, error)

Cursor creates and initializes a new UnQLite database cursor.

func (*Database) Delete

func (db *Database) Delete(key []byte) (err error)

Delete a record from the database.

func (*Database) Fetch

func (db *Database) Fetch(key []byte) (value []byte, err error)

Fetch a record from the database.

func (*Database) Rollback

func (db *Database) Rollback() (err error)

Rollback a transaction.

func (*Database) Store

func (db *Database) Store(key, value []byte) (err error)

Store will store a new Key/Value pair in the database.

type Library

type Library struct {
	// contains filtered or unexported fields
}

Library represents the UnQLite Library Control.

func Info

func Info() *Library

Info returns the UnQLite Library.

func (*Library) Copyright

func (l *Library) Copyright() string

Copyright returns the Copyright string.

func (*Library) Ident

func (l *Library) Ident() string

Ident returns the UnQLite identification string.

func (*Library) Init

func (l *Library) Init()

Init will initialize the library. After call init, the library must be shutdown first before any re-configuration can be done. Subsequent calls result in NOOP. This is autocalled when a database is opened.

func (*Library) IsInitialized

func (l *Library) IsInitialized() bool

IsInitialized will return boolean indicating if the library is initialized.

func (*Library) IsThreadSafe

func (l *Library) IsThreadSafe() bool

IsThreadSafe returns a boolean identifiying if the UnQLite library is compiled Thread Safe.

func (*Library) Shutdown

func (l *Library) Shutdown() error

Shutdown the UnQLite Library.

func (*Library) Signature

func (l *Library) Signature() string

Signature returns the Signature string.

func (*Library) Version

func (l *Library) Version() string

Version returns the version string.

type UnQLiteError

type UnQLiteError int

UnQLiteError is returned on both UnQLite native errors as well as UnQLite Go errors. Native errors are within the range of '<= 0' (Equal and lesser then Zero) while the errors from UnQLite Go are > 0 (Greater then Zero).

( UnQLiteError <= 0 ) Native Errors
( UnQLiteError >  0 ) UnQLite Go Errors.

func (UnQLiteError) Error

func (e UnQLiteError) Error() string

Error returns the string representation of the UnQLiteError.

func (UnQLiteError) String

func (e UnQLiteError) String() string

type VM

type VM struct {
	// contains filtered or unexported fields
}

VM Represents an UnQLite/Jx9 Virtual Machine.

func NewVM

func NewVM() (vm *VM)

NewVM creates and intializes a new UnQlite/Jx9 Virtual Machine.

func (*VM) Execute

func (vm *VM) Execute() int

Execute Virtual Machine.

func (*VM) ExtractBool

func (vm *VM) ExtractBool(v string) (bool, error)

ExtractBool will extract the result from the Virtual Machine as bool.

func (*VM) ExtractFloat64

func (vm *VM) ExtractFloat64(v string) (float64, error)

ExtractFloat64 will extract the result from the Virtual Machine as float64.

func (*VM) ExtractInt

func (vm *VM) ExtractInt(v string) (int, error)

ExtractInt will extract the result from the Virtual Machine as int.

func (*VM) ExtractInt64

func (vm *VM) ExtractInt64(v string) (int64, error)

ExtractInt64 will extract the result from the Virtual Machine as int64.

func (*VM) ExtractString

func (vm *VM) ExtractString(v string) (string, error)

ExtractString will extract the result from the Virtual Machine as string.

func (VM) Free

func (vm VM) Free()

Free releases the Virtual Machine.

func (*VM) Result

func (vm *VM) Result() string

Result will return the output of the Virtual Machine after execution.

Directories

Path Synopsis
The JX9 Package represents a JX9 script code with the ability to compile and execute the code.
The JX9 Package represents a JX9 script code with the ability to compile and execute the code.
The collections package represents a high level approach to use unqlite trough collections which allow reading/writing/deleting/updating documents (JSONs) to and from the unqlite database.
The collections package represents a high level approach to use unqlite trough collections which allow reading/writing/deleting/updating documents (JSONs) to and from the unqlite database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL