Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed small typo.

The StorageEngine implementation provides scheme functionality, which can be used to obtain meta-information about the tables and virtual files inside the database instance.

There are several IStorageEngine methods and properties

Highlight c sharp
IDescriptor this[string name] { get; }
IDescriptor Find(long id);
void Delete(string name);
void Rename(string name, string newName);
bool Exists(string name);
int Count { get; }
long DatabaseSize { get; }
int CacheSize { get; set; }

The usage of the scheme is shown in the following short examples. If we have a user table:

Highlight c sharp
    ITable<int, Tick> table = engine.OpenXTable<int, Tick>("table");

Obtaining a table’s IDescriptor can be done in the following ways:

  1. Via the this property of the storage engine instance:

    Highlight c sharp
        IDescriptor descriptor1 = engine["table"];
  2. Via the method IDescriptor Find(long id)

    Highlight c sharp
        IDescriptor descriptor2 = Find(id);

The specified id here is a unique number internally assigned on table creation. Each table and file in STSdb 4.0 has its unique id which is never changed. Even if a table is deleted and recreated again with the same name, key and record types, it will receive a brand new (incremental) id. These IDs are used by the engine, but are visible to the users. They can be used as unique table identifiers.

The engine also provides the following scheme methods and properties:

  1. Delete a table:

    Highlight c sharp
        engine.Delete("table");

    NOTE: After deleting a table, inserting records in it is still possible (while the user has the table reference). But when the storage engine is committed and disposed, the table will be deleted and it used space will be gradually recycled.

  2. Rename a table

    Highlight c sharp
        engine.Rename("table", "table_NewName");
  3. Check if a table exists

    Highlight c sharp
    	bool exists = engine.Exists("table");
  4. Obtain the number of tables and virtual files the storage engine holds

    Highlight c sharp
    	int tablesCount = engine.Count;
  5. Obtain the size of the database

    Highlight c sharp
    	long databaseSize = engine.Size;
  6. Obtain the cache capacity of the engine. The returned value represents the number of tree nodes that are kept in RAM:

    Highlight c sharp
        long databaseSize = engine.Size;

 

Next prev