1

I am searching for a connector/library that will allow me to connect to Hypertable DB. I've installed Hypertable on my windows machine, but I don't know how to connect to it. I'm using ASP.NET 4.5 C# in Visual Studio.

I tried this one: http://ht4n.softdev.ch/index.php/getting-started-in-5min

But I have no idea how to use it. Imported the ht4d.dll to the 'bin' folder, but don't know what else should I do.

Thanks.

Liron Harel
  • 10,819
  • 26
  • 118
  • 217

3 Answers3

1

first make sure that the installation success. make sure you have a PATH system environment variable point to the hypertable installation folder on my system is in :

 C:\Program Files\Hypertable

after that try from the cmd the command "hypertable" you need to get a hypertable welcome message.

i also download the ht4n connector and i created a console application for test it i create a reference to the ht4n.dll

and this is the code i used and it was connected successfully:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hypertable;

namespace HypertableTest1
{
class Program
{
    static void Main(string[] args)
    {

        //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

        var connectionString = "Provider=Hyper;Uri=net.tcp://localhost";

        using (var context = Context.Create(connectionString))
        using (var client = context.CreateClient())
        {
            // use the client
            //client.CreateNamespace("CSharp");

            if (!client.NamespaceExists("/CSharp"))
                client.CreateNamespace("/CSharp");

            INamespace csNamespace = client.OpenNamespace("CSharp");    
            csNamespace.CreateTable("MyFirstTable", "");
            IList<Cell> c = csNamespace.Query("");
        }

        Console.ReadLine();
    }
}
}
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
ygaradon
  • 2,198
  • 2
  • 21
  • 27
1

Necromancing here
ht4n is annoying.

First, it comes under the GNU General Public License v3 (not the LGPL), and a commercial, closed source license. Basically, no further than that.

Then it is written in C++.NET, which, while faster than Thrift, creates a platform dependency on Windows (mono doesn't support C++.NET).
And because it is written in C++.NET, it comes with those annyoing separate 32/64-bit dll-versions, that only ever run on a x86 (32/64) processor on Windows.
If you want one and not the other, you have to recompile...
Both these issues combined, it's not only stupid and commercial license-mobbing, it also defeats the idea of a VM-language like .NET.



Since my Chrubuntu Chromebook uses Linux (with ARM processor) and C++.NET doesn't work there, I've ported the Java Thrift-Client to C#.

You can find it > here <.
Comes with a nice example program btw.

Basically

ThriftClient client = null;
long ns = -1;

try
{
    client = ThriftClient.create("localhost", 38080);

    if (!client.namespace_exists("test"))
    {
        System.Console.WriteLine("Namespace test does not exist");
        client.create_namespace("test");
    }

    ns = client.namespace_open("test");

    System.Console.WriteLine(client.hql_query(ns, "show tables").ToString());


    client.namespace_close(ns);
} // End Try
catch (System.Exception e)
{
    System.Console.WriteLine (e.Message);
    System.Console.Error.WriteLine (e.StackTrace);

    try
    {
        if (client != null && ns != -1)
            client.namespace_close(ns);
    } 
    catch (System.Exception ex)
    {
        System.Console.WriteLine (ex.Message);
        System.Console.Error.WriteLine("Problem closing namespace \"test\" - " + e.Message);
    }
    System.Environment.Exit(1);
} // End Catch

The Thrift-Client works anywhere, with any number of bits.
And - best of all - from this point on, you can use all the Java Thrift-samples/tutorials with minimal changes.

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
0

Hypertable exposes the high-level API through an Apache Thrift service stack, therefore client libaries can be generated for many different languages - including C#:

  • Download Apache Thrift, including the thrift compiler
  • Download the Hypertable IDL files Client.thrift and Hql.thrift from here
  • Run the thrift compiler thrift-0.9.2 --gen csharp Client.thrift Hql.thrift
  • Pack all together

For the Hypertable serialized API you'll need a SerializedCellReader/SerializedCellWriter, everything together is available for download here.

Andy
  • 1
  • 1