Connecting to a datastore

The Hypertable context serves as the root object for working with a Hypertable server or any other supported datastores. You will create one instance of the context for each server or datastore you connect to. The easiest way to configure a connection is to use a connection string, which defines the provider to use for the connection and the connection endpoint.

 

The standard connection string format is:

Provider=name;Uri=net.tcp://hostname[:port];[(options;)]

or if using an embedded datastore provider:

Provider=name;Uri=file://[drive][/path]/filename;[(options;)]

 

Hypertable for .NET supports following in-built providers:

ProviderUriDescription
Hyper net.tcp://host[:port] Native Hypertable client protocol
Thrift net.tcp://host[:port] Hypertable Thrift API
SQLite file://[drive][/path]/filename Embedded key-value store, based on SQLite
Hamster file://[drive][/path]/filename Embedded key-value store, based on hamsterdb

 

For example, establish a context and create a client:

var connectionString = "Provider=Hyper;Uri=net.tcp://localhost";
using (var context = Context.Create(connectionString))
using (var client = context.CreateClient()) {
   // use the client
}

Alternative you can create a context by passing the options as a dictionary instead of a connection string. The example from above:

var properties = new Dictionary<string, object>
   {
      { "Ht4n.Provider", "Hyper" },
      { "Ht4n.Uri"     , "net.tcp://localhost" }
   };

using (var context = Context.Create(properties))
using (var client = context.CreateClient()) {
   // use the client
}

Or using the shorter aliases:

var properties = new Dictionary<string, object>
   {
      { "Provider", "Hyper" },
      { "Uri"     , "net.tcp://localhost" }
   };

using (var context = Context.Create(properties))
using (var client = context.CreateClient()) {
   // use the client
}

 

Configuration properties

The configuration properties contains all the options specified as key/value pairs, for example:

var provider = context.Properties["Ht4n.Provider"];

 

Below the list of the context related configuration properties:

OptionAliasTypeDefault
Ht4n.Provider Provider string Hyper
Ht4n.Uri Uri string net.tcp://localhost
Ht4n.ConnectionTimeout ConnectionTimeout int 30000 [ms]
Ht4n.ComposablePartCatalogs - ComposablePartCatalog -
Ht4n.ComposablePartCatalogs - IEnumerable<ComposablePartCatalog> -

 

SQLite related configuration properties:

OptionTypeDefault
Ht4n.SQLite.Filename string -
Ht4n.SQLite.CacheSizeMB int 64 [MB]
Ht4n.SQLite.PageSizeKB int 4 [KB]
Ht4n.SQLite.Synchronous bool false
Ht4n.SQLite.Index.Column bool false
Ht4n.SQLite.Index.ColumnFamily bool false
Ht4n.SQLite.Index.ColumnQualifier bool false
Ht4n.SQLite.Index.Timestamp bool false

 

Hamster related configuration properties:

OptionTypeDefault
Ht4n.Hamster.Filename string -
Ht4n.Hamster.EnableRecovery bool false
Ht4n.Hamster.EnableAutoRecovery bool false
Ht4n.Hamster.CacheSizeMB int 64 [MB]
Ht4n.Hamster.PageSizeKB int 64 [KB]

 

Connecting to multiple Hypertable instances using the native Hypertable client protocol

Running multiple Hypertable instances within a network requires unique location ids for all the range servers accross the Hypertable instances, which must be configured using

Hypertable.RangeServer.ProxyName=*

which creates an unique location id based on host name and port, or manually for each range server:

Hypertable.RangeServer.ProxyName=<unique rs proxy name>

Please notice, this property is required on database initialization, it's not possible to change the proxy name for a existing setup.