我正在寻找一个连接器/库,它将允许我连接到Hypertable DB。我已经在我的windows机器上安装了Hypertable,但我不知道如何连接它。我在Visual Studio中使用ASP.NET 4.5 C#。
我试过这个:http://ht4n.softdev.ch/index.php/getting-started-in-5min
但我不知道如何使用它。已将ht4d.dll导入到“bin”文件夹,但不知道还应该做什么。
谢谢。
发布于 2012-06-07 04:02:08
首先确保安装成功。确保您有一个PATH系统环境变量,指向我的系统上的hypertable安装文件夹:
C:\Program Files\Hypertable在此之后,尝试从cmd命令" hypertable“,您需要得到一个hypertable欢迎消息。
我还下载了ht4n连接器,并为测试它创建了一个控制台应用程序。我创建了一个对ht4n.dll的引用
这是我使用的代码,它连接成功:
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();
}
}
}发布于 2014-08-27 18:30:51
这里的亡灵法术
ht4n很烦人。
首先,它遵循GNU通用公共许可证v3 (而不是LGPL),以及一个商业的、封闭源代码的许可证。基本上,仅此而已。
然后它是用C++.NET编写的,虽然比Thrift快,但在Window上创建了一个平台依赖(mono不支持C++.NET)。
因为它是用C++.NET编写的,所以它附带了一些单独的32/64位动态链接库版本,这些版本只能在x86 (32/64)处理器上运行。
如果你想要一个而不是另一个,你必须重新编译...
这两个问题结合在一起,不仅是愚蠢的商业许可混乱,它还挫败了像.NET这样的VM语言的想法。
由于我的Chrubuntu Chromebook使用的是Linux (采用ARM处理器),而C++.NET不能在那里运行,所以我将Java Thrift-Client移植到了C#上。
你可以找到它> here <。
附带了一个很好的示例程序btw。
基本上
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 CatchThrift-Client可以在任何地方使用,具有任意数量的位。
最棒的是,从现在开始,您可以使用所有Java Thrift-samples/tutorials,只需最少的更改。
发布于 2015-04-09 03:37:41
Hypertable通过Apache Thrift服务堆栈公开高级API,因此可以为许多不同的语言生成客户端库-包括C#:
从here
对于Hypertable serialized API,您需要一个SerializedCellReader/SerializedCellWriter,所有这些都可以下载here。
https://stackoverflow.com/questions/10604058
复制相似问题