C# Класс Upscaledb.Database

A Database class
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddCursor ( Cursor c ) : void

Adds a Cursor to the Cursor list

Close ( ) : void

Closes the Database

This method wraps the native ups_db_close function.
Before closing the Database, the cache is flushed to Disk.

Database ( ) : System

Default Constructor

Dispose ( ) : void

Closes the Database

Erase ( Transaction txn, byte key ) : void

Erases a Database Item

This method wraps the native ups_db_erase function.
This function erases a Database item. If the item with the specified key does not exist in the Database, error code UpsConst.UPS_KEY_NOT_FOUND is thrown.
Note that this method can not erase a single duplicate key. If the key has multiple duplicates, all duplicates of this key will be erased. Use Cursor.Erase to erase a specific duplicate key.

Erase ( byte key ) : void

Erases a Database Item

Find ( Transaction txn, byte key ) : byte[]

Searches an item in the Database, returns the record

Find ( Transaction txn, byte &key, int flags ) : byte[]

Searches an item in the Database, returns the record

This method wraps the native ups_db_find function.

This function searches the Database for a key. If the key is found, the method will return the record of this item.
Database.Find can not search for duplicate keys. If the key has multiple duplicates, only the first duplicate is returned.

Find ( byte key ) : byte[]

Searches an item in the Database, returns the record

GetCount ( ) : System.Int64

Returns the number of keys in this Database

GetCount ( Transaction txn, int flags ) : System.Int64

Returns the number of keys in this Database

This method wraps the native ups_db_count function.
You can specify UPS_SKIP_DUPLICATES if you do now want to include any duplicates in the count.

GetCount ( int flags ) : System.Int64

Returns the number of keys in this Database

GetLastError ( ) : int

Returns the last error code

This method wraps the native ups_db_get_error function.

GetVersion ( ) : Version

Returns the upscaledb.dll version

Insert ( Transaction txn, byte key, byte record ) : void

Inserts a Database item

This is an overloaded function for Database.Insert(txn, key, record, 0).

Insert ( Transaction txn, byte key, byte record, int flags ) : void

Inserts a Database Item

This method wraps the native ups_db_insert function.
This function inserts a key/record pair as a new Database item.
If the key already exists in the Database, error code UpsConst.UPS_DUPLICATE_KEY is thrown.
If you wish to overwrite an existing entry specify the flag UpsConst.UPS_OVERWRITE
If you wish to insert a duplicate key specify the flag UpsConst.UPS_DUPLICATE. (Note that the Database has to be created with the flag UpsConst.UPS_ENABLE_DUPLICATE_KEYS in order to use duplicate keys.) The duplicate key is inserted after all other duplicate keys (see UpsConst.UPS_DUPLICATE_INSERT_LAST).

Insert ( byte key, byte record ) : void

Inserts a Database item

This is an overloaded function for Database.Insert(null, key, record, 0).

Insert ( byte key, byte record, int flags ) : void

Inserts a Database item

This is an overloaded function for Database.Insert(null, key, record, flags).

InsertRecNo ( Transaction txn, byte record, int flags ) : byte[]

Inserts a Database Item into a Record Number Database

This method wraps the native ups_db_insert function.
This function inserts a record as a new Database item.

InsertRecNo ( byte record ) : byte[]

Inserts a Database Item into a Record Number Database

This is an overloaded function for Database.InsertRecNo(null, record, 0).

InsertRecNo ( byte record, int flags ) : byte[]

Inserts a Database Item into a Record Number Database

This is an overloaded function for Database.InsertRecNo(null, record, flags).

RegisterCompare ( String name, CompareFunc foo ) : void

Registers a global compare function.

This method wraps the native ups_register_compare function.

RemoveCursor ( Cursor c ) : void

Removes a Cursor from the Cursor list

SetCompareFunc ( CompareFunc foo ) : void

Sets the comparison function

This method wraps the native ups_db_set_compare_func function.

The CompareFunc delegate compares two index keys. It returns -1 if the first key is smaller, +1 if the second key is smaller or 0 if both keys are equal.

If foo is null, upscaledb will use the default compare function (which is based on memcmp(3)).

SetErrorHandler ( ErrorHandler eh ) : void

Sets the global error handler

This method wraps the native ups_set_error_handler function.

This handler will receive all debug messages that are emitted by upscaledb. You can install the default handler by setting eh to null.

Защищенные методы

Метод Описание
Dispose ( bool all ) : void

Closes the Database

Приватные методы

Метод Описание
AppendNullParameter ( Parameter parameters ) : Upscaledb.Parameter[]
Database ( IntPtr handle ) : System

Описание методов

AddCursor() публичный Метод

Adds a Cursor to the Cursor list
public AddCursor ( Cursor c ) : void
c Cursor
Результат void

Close() публичный Метод

Closes the Database
This method wraps the native ups_db_close function.
Before closing the Database, the cache is flushed to Disk.
public Close ( ) : void
Результат void

Database() публичный Метод

Default Constructor
public Database ( ) : System
Результат System

Dispose() публичный Метод

Closes the Database
public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

Closes the Database
protected Dispose ( bool all ) : void
all bool
Результат void

Erase() публичный Метод

Erases a Database Item
This method wraps the native ups_db_erase function.
This function erases a Database item. If the item with the specified key does not exist in the Database, error code UpsConst.UPS_KEY_NOT_FOUND is thrown.
Note that this method can not erase a single duplicate key. If the key has multiple duplicates, all duplicates of this key will be erased. Use Cursor.Erase to erase a specific duplicate key.
/// /// /// if the key was not found /// /// if you tried to insert a key in a read-only Database /// ///
public Erase ( Transaction txn, byte key ) : void
txn Transaction The optional Transaction
key byte The key of the item to delete
Результат void

Erase() публичный Метод

Erases a Database Item
public Erase ( byte key ) : void
key byte
Результат void

Find() публичный Метод

Searches an item in the Database, returns the record
public Find ( Transaction txn, byte key ) : byte[]
txn Transaction
key byte
Результат byte[]

Find() публичный Метод

Searches an item in the Database, returns the record
This method wraps the native ups_db_find function.

This function searches the Database for a key. If the key is found, the method will return the record of this item.
Database.Find can not search for duplicate keys. If the key has multiple duplicates, only the first duplicate is returned.
/// /// /// if the item was not found /// ///
public Find ( Transaction txn, byte &key, int flags ) : byte[]
txn Transaction The optional Transaction
key byte The key of the item
flags int The flags of the operation
Результат byte[]

Find() публичный Метод

Searches an item in the Database, returns the record
public Find ( byte key ) : byte[]
key byte
Результат byte[]

GetCount() публичный Метод

Returns the number of keys in this Database
public GetCount ( ) : System.Int64
Результат System.Int64

GetCount() публичный Метод

Returns the number of keys in this Database
This method wraps the native ups_db_count function.
You can specify UPS_SKIP_DUPLICATES if you do now want to include any duplicates in the count.
public GetCount ( Transaction txn, int flags ) : System.Int64
txn Transaction
flags int
Результат System.Int64

GetCount() публичный Метод

Returns the number of keys in this Database
public GetCount ( int flags ) : System.Int64
flags int
Результат System.Int64

GetLastError() публичный Метод

Returns the last error code
This method wraps the native ups_db_get_error function.
public GetLastError ( ) : int
Результат int

GetVersion() публичный статический Метод

Returns the upscaledb.dll version
public static GetVersion ( ) : Version
Результат Version

Insert() публичный Метод

Inserts a Database item
This is an overloaded function for Database.Insert(txn, key, record, 0).
public Insert ( Transaction txn, byte key, byte record ) : void
txn Transaction
key byte
record byte
Результат void

Insert() публичный Метод

Inserts a Database Item
This method wraps the native ups_db_insert function.
This function inserts a key/record pair as a new Database item.
If the key already exists in the Database, error code UpsConst.UPS_DUPLICATE_KEY is thrown.
If you wish to overwrite an existing entry specify the flag UpsConst.UPS_OVERWRITE
If you wish to insert a duplicate key specify the flag UpsConst.UPS_DUPLICATE. (Note that the Database has to be created with the flag UpsConst.UPS_ENABLE_DUPLICATE_KEYS in order to use duplicate keys.) The duplicate key is inserted after all other duplicate keys (see UpsConst.UPS_DUPLICATE_INSERT_LAST).
/// /// /// if the flags UpsConst.UPS_DUPLICATE AND /// UpsConst.UPS_OVERWRITE were specified, or if /// UpsConst.UPS_DUPLICATE was specified but the Database /// was not created with UpsConst.UPS_ENABLE_DUPLICATE_KEYS /// /// if you tried to insert a key in a read-only Database /// /// if key size is different than than the key size parameter /// specified for Database.Create. /// ///
public Insert ( Transaction txn, byte key, byte record, int flags ) : void
txn Transaction An optional Transaction object
key byte The key of the new item
record byte The record of the new item
flags int Optional flags for this operation. Possible /// flags are: /// /// /// If the key already exists, the record is overwritten. /// Otherwise, the key is inserted. /// /// If the key already exists, a duplicate key is inserted. /// The key is inserted before the already existing duplicates. /// ///
Результат void

Insert() публичный Метод

Inserts a Database item
This is an overloaded function for Database.Insert(null, key, record, 0).
public Insert ( byte key, byte record ) : void
key byte
record byte
Результат void

Insert() публичный Метод

Inserts a Database item
This is an overloaded function for Database.Insert(null, key, record, flags).
public Insert ( byte key, byte record, int flags ) : void
key byte
record byte
flags int
Результат void

InsertRecNo() публичный Метод

Inserts a Database Item into a Record Number Database
This method wraps the native ups_db_insert function.
This function inserts a record as a new Database item.
/// /// /// if you tried to insert a key in a read-only Database /// ///
public InsertRecNo ( Transaction txn, byte record, int flags ) : byte[]
txn Transaction An optional Transaction object
record byte The record of the new item
flags int Optional flags for this operation.
Результат byte[]

InsertRecNo() публичный Метод

Inserts a Database Item into a Record Number Database
This is an overloaded function for Database.InsertRecNo(null, record, 0).
public InsertRecNo ( byte record ) : byte[]
record byte
Результат byte[]

InsertRecNo() публичный Метод

Inserts a Database Item into a Record Number Database
This is an overloaded function for Database.InsertRecNo(null, record, flags).
public InsertRecNo ( byte record, int flags ) : byte[]
record byte
flags int
Результат byte[]

RegisterCompare() публичный статический Метод

Registers a global compare function.
This method wraps the native ups_register_compare function.
public static RegisterCompare ( String name, CompareFunc foo ) : void
name String Descriptive name of the compare function
foo CompareFunc Delegate object
Результат void

RemoveCursor() публичный Метод

Removes a Cursor from the Cursor list
public RemoveCursor ( Cursor c ) : void
c Cursor
Результат void

SetCompareFunc() публичный Метод

Sets the comparison function
This method wraps the native ups_db_set_compare_func function.

The CompareFunc delegate compares two index keys. It returns -1 if the first key is smaller, +1 if the second key is smaller or 0 if both keys are equal.

If foo is null, upscaledb will use the default compare function (which is based on memcmp(3)).
public SetCompareFunc ( CompareFunc foo ) : void
foo CompareFunc The compare delegate, or null
Результат void

SetErrorHandler() публичный статический Метод

Sets the global error handler
This method wraps the native ups_set_error_handler function.

This handler will receive all debug messages that are emitted by upscaledb. You can install the default handler by setting eh to null.
public static SetErrorHandler ( ErrorHandler eh ) : void
eh ErrorHandler The delegate which is called whenever an /// error message is emitted; set to null to set the default /// error handler
Результат void