C# Class Upscaledb.Environment

A Database Environment class
Inheritance: IDisposable
Exibir arquivo Open project: cruppstahl/upscaledb Class Usage Examples

Public Methods

Method Description
Begin ( ) : Transaction

Begins a new Transaction

Begin ( int flags ) : Transaction

Begins a new Transaction

This method wraps the native ups_txn_begin function.

Close ( ) : void

Closes the Environment

This method wraps the native ups_env_close function.

Create ( String fileName, int flags ) : void

Creates a new Environment

This is an overloaded function for Create(fileName, flags, 0, null).

Create ( String fileName, int flags, int mode ) : void

Creates a new Environment

This is an overloaded function for Create(fileName, flags, mode, null).

Create ( String fileName, int flags, int mode, Parameter parameters ) : void

Creates a new Database

This method wraps the native ups_env_create function.
A Database Environment is a collection of Databases, which are all stored in one physical file (or in-memory). Per default, up to 16 Databases can be stored in one file ( on how to store even more Databases).
Each Database is identified by a positive 16bit value (except 0 and values at or above 0xf000). Databases in an Environment can be created with Environment.CreateDatabase(short) or opened with Environment.OpenDatabase(short).

Create ( string fileName ) : void

Creates a new Environment

This is an overloaded function for Create(fileName, 0, 0, null).

CreateDatabase ( short name ) : Database

Creates a new Database in this Environment

This is an overloaded function for CreateDatabase(name, 0, null).

CreateDatabase ( short name, int flags ) : Database

Creates a new Database in this Environment

This is an overloaded function for CreateDatabase(name, flags, null).

CreateDatabase ( short name, int flags, Parameter parameters ) : Database

Creates a new Database in this Environment

This method wraps the native ups_env_create_db function.

Dispose ( ) : void

Closes the Environment

Environment ( ) : System

Default Constructor

Environment ( IntPtr ptr ) : System

Default Constructor which sets the handle

This constructor is used by Database.GetEnvironment()

EraseDatabase ( short name ) : void

Deletes a Database from this Environment

This method wraps the native ups_env_erase_db function.

Flush ( ) : void

Flushes the Environment

This method wraps the native ups_env_flush function.
This function flushes the Database cache and writes the whole file to disk.
Since In-Memory Environments do not have a file on disk, the function will have no effect and will return successfully.

GetDatabaseNames ( ) : short[]

Returns the names of all Databases in this Environment

This method wraps the native ups_env_get_database_names function.
This function returns the names of all Databases and the number of Databases in an Environment.

GetHandle ( ) : IntPtr

Returns the Environment handle

Open ( String fileName, int flags ) : void

Opens an existing Environment

This is an overloaded function for Open(fileName, flags, null).

Open ( String fileName, int flags, Parameter parameters ) : void

Opens an existing Environment

This method wraps the native ups_env_open function.

Open ( string fileName ) : void

Opens an existing Environment

This is an overloaded function for Open(fileName, 0, null).

OpenDatabase ( short name ) : Database

Opens a Database in this Environment

This is an overloaded function for OpenDatabase(name, 0).

OpenDatabase ( short name, int flags ) : Database

Opens a Database in this Environment

This is an overloaded function for OpenDatabase(name, flags, null).

OpenDatabase ( short name, int flags, Parameter parameters ) : Database

Opens a Database in this Environment

This method wraps the native ups_env_open_db function.

RenameDatabase ( short oldName, short newName ) : void

Renames a Database in this Environment

This method wraps the native ups_env_rename_db function.

SelectRange ( String query, Cursor begin, Cursor end ) : Result

Protected Methods

Method Description
Dispose ( bool all ) : void

Closes the Environment

Private Methods

Method Description
AppendNullParameter ( Parameter parameters ) : Upscaledb.Parameter[]

Method Details

Begin() public method

Begins a new Transaction
public Begin ( ) : Transaction
return Transaction

Begin() public method

Begins a new Transaction
This method wraps the native ups_txn_begin function.
public Begin ( int flags ) : Transaction
flags int
return Transaction

Close() public method

Closes the Environment
This method wraps the native ups_env_close function.
public Close ( ) : void
return void

Create() public method

Creates a new Environment
This is an overloaded function for Create(fileName, flags, 0, null).
public Create ( String fileName, int flags ) : void
fileName String
flags int
return void

Create() public method

Creates a new Environment
This is an overloaded function for Create(fileName, flags, mode, null).
public Create ( String fileName, int flags, int mode ) : void
fileName String
flags int
mode int
return void

Create() public method

Creates a new Database
This method wraps the native ups_env_create function.
A Database Environment is a collection of Databases, which are all stored in one physical file (or in-memory). Per default, up to 16 Databases can be stored in one file ( on how to store even more Databases).
Each Database is identified by a positive 16bit value (except 0 and values at or above 0xf000). Databases in an Environment can be created with Environment.CreateDatabase(short) or opened with Environment.OpenDatabase(short).
/// /// /// if an invalid combination of flags was specified /// /// if the value for UPS_PARAM_MAX_DATABASES is too /// high (either decrease it or increase the page size) /// /// if the file could not be opened or reading/writing failed /// /// if memory could not be allocated /// /// if the page size is not a multiple of 1024 /// /// if the key size is too large (at least 4 keys must /// fit in a page) /// /// if another process has locked the file /// ///
public Create ( String fileName, int flags, int mode, Parameter parameters ) : void
fileName String The file name of the Environment file. If /// the file already exists, it is overwritten. Can be null if you /// create an In-Memory Environment.
flags int Optional flags for this operation, combined /// with bitwise OR. Possible flags are: /// /// /// Immediately write modified pages to the disk. This /// slows down all Database operations, but may save the /// Database integrity in case of a system crash.
/// /// Creates an In-Memory Environment. No file will be created, /// and the Databases are lost after the Environment /// is closed. The parameter can /// be null. Do NOT use in combination with /// a cache size other than 0.
/// /// Do not use memory mapped files for I/O. By default, /// upscaledb checks if it can use mmap, since mmap is faster /// than read/write. For performance reasons, this flag should /// not be used.
/// /// Enables Transactions for this Database.
///
///
mode int File access rights for the new file. This is /// the mode parameter for creat(2). Ignored on /// Microsoft Windows.
parameters Parameter An array of /// structures. The following parameters are available:
/// /// /// The size of the Database cache, in bytes. The default size /// is defined in src/config.h as UPS_DEFAULT_CACHESIZE /// - usually 2 MB.
/// /// The size of a file page, in bytes. It is recommended not /// to change the default size. The default size depends on /// hardware and operating system. Page sizes must be 1024 or a /// multiple of 2048.
/// /// The number of maximum Databases in this Environment; /// default: 16. ///
///
return void

Create() public method

Creates a new Environment
This is an overloaded function for Create(fileName, 0, 0, null).
public Create ( string fileName ) : void
fileName string
return void

CreateDatabase() public method

Creates a new Database in this Environment
This is an overloaded function for CreateDatabase(name, 0, null).
public CreateDatabase ( short name ) : Database
name short
return Database

CreateDatabase() public method

Creates a new Database in this Environment
This is an overloaded function for CreateDatabase(name, flags, null).
public CreateDatabase ( short name, int flags ) : Database
name short
flags int
return Database

CreateDatabase() public method

Creates a new Database in this Environment
This method wraps the native ups_env_create_db function.
/// /// /// if an invalid combination of flags was specified /// /// if a Database with this name already exists in this /// Environment /// /// if memory could not be allocated /// /// if the key size is too large (at least 4 keys must /// fit in a page) /// /// if the maximum number of Databases per Environment /// was already created /// ///
public CreateDatabase ( short name, int flags, Parameter parameters ) : Database
name short The name of the Database. If a Database /// with this name already exists, /// is thrown. /// Database names from 0xf000 to 0xffff and 0 are reserved.
flags int Optional flags for creating the Database, /// combined with bitwise OR. Possible values are: /// /// /// Creates an "auto-increment" Database. Keys in Record /// Number Databases are automatically assigned an incrementing /// 64bit value. /// ///
parameters Parameter An array of /// structures. The following parameters are available:
/// /// /// The size of the keys in the B+Tree index. The default size /// is 21 bytes.
///
///
return Database

Dispose() public method

Closes the Environment
public Dispose ( ) : void
return void

Dispose() protected method

Closes the Environment
protected Dispose ( bool all ) : void
all bool
return void

Environment() public method

Default Constructor
public Environment ( ) : System
return System

Environment() public method

Default Constructor which sets the handle
This constructor is used by Database.GetEnvironment()
public Environment ( IntPtr ptr ) : System
ptr System.IntPtr
return System

EraseDatabase() public method

Deletes a Database from this Environment
This method wraps the native ups_env_erase_db function.
/// /// /// if a Database with this name does not exist /// /// if the Database with the new name is still open /// ///
public EraseDatabase ( short name ) : void
name short The name of the Database which is deleted. /// If a Database with this name does not exist, the function will throw /// .
return void

Flush() public method

Flushes the Environment
This method wraps the native ups_env_flush function.
This function flushes the Database cache and writes the whole file to disk.
Since In-Memory Environments do not have a file on disk, the function will have no effect and will return successfully.
public Flush ( ) : void
return void

GetDatabaseNames() public method

Returns the names of all Databases in this Environment
This method wraps the native ups_env_get_database_names function.
This function returns the names of all Databases and the number of Databases in an Environment.
public GetDatabaseNames ( ) : short[]
return short[]

GetHandle() public method

Returns the Environment handle
public GetHandle ( ) : IntPtr
return System.IntPtr

Open() public method

Opens an existing Environment
This is an overloaded function for Open(fileName, flags, null).
public Open ( String fileName, int flags ) : void
fileName String
flags int
return void

Open() public method

Opens an existing Environment
This method wraps the native ups_env_open function.
/// /// /// if an invalid combination of flags was specified /// /// if the file does not exist /// /// if the file could not be opened or reading/writing failed /// /// if the Database version is not compatible with the library /// version /// /// if memory could not be allocated /// /// if another process has locked the file /// ///
public Open ( String fileName, int flags, Parameter parameters ) : void
fileName String The file name of the Environment file.
flags int Optional flags for this operation, combined /// with bitwise OR. Possible flags are: /// /// /// Opens the file for reading only. Operations which need /// write access (i.e. Database.Insert) /// will return . ///
/// /// Immediately write modified pages to the disk. This /// slows down all Database operations, but may save the /// Database integrity in case of a system crash.
/// /// Do not use memory mapped files for I/O. By default, /// upscaledb checks if it can use mmap, since mmap is faster /// than read/write. For performance reasons, this flag should /// not be used.
/// /// Automatically recover the Database, if necessary. This /// flag imples . ///
/// /// Enables Transactions for this Database.
///
///
parameters Parameter An array of /// structures. The following parameters are available:
/// /// /// The size of the Database cache, in bytes. The default size /// is defined in src/config.h as UPS_DEFAULT_CACHESIZE /// - usually 2 MB.
///
///
return void

Open() public method

Opens an existing Environment
This is an overloaded function for Open(fileName, 0, null).
public Open ( string fileName ) : void
fileName string
return void

OpenDatabase() public method

Opens a Database in this Environment
This is an overloaded function for OpenDatabase(name, 0).
public OpenDatabase ( short name ) : Database
name short
return Database

OpenDatabase() public method

Opens a Database in this Environment
This is an overloaded function for OpenDatabase(name, flags, null).
public OpenDatabase ( short name, int flags ) : Database
name short
flags int
return Database

OpenDatabase() public method

Opens a Database in this Environment
This method wraps the native ups_env_open_db function.
/// /// /// if an invalid combination of flags was specified /// /// if a Database with this name does not exist /// /// if this Database was already opened /// /// if memory could not be allocated /// /// if another process has locked the file /// ///
public OpenDatabase ( short name, int flags, Parameter parameters ) : Database
name short The name of the Database. If a Database /// with this name does not exist, the function will throw /// .
flags int Optional flags for this operation, combined /// with bitwise OR. Possible flags are: /// /// /// Opens the database for reading. /// ///
parameters Parameter An array of /// structures. The following parameters are available:
/// /// ///
return Database

RenameDatabase() public method

Renames a Database in this Environment
This method wraps the native ups_env_rename_db function.
/// /// /// if the new Database name is reserved /// /// if a Database with this name does not exist /// /// if a Database with the new name already exists /// /// if memory could not be allocated /// ///
public RenameDatabase ( short oldName, short newName ) : void
oldName short The old name of the Database. If a Database /// with this name does not exist, the function will throw /// .
newName short The new name of the Database. If a Database /// with this name already exists, the function will throw /// .
return void

SelectRange() public method

public SelectRange ( String query, Cursor begin, Cursor end ) : Result
query String
begin Cursor
end Cursor
return Result