c# - 如何更新超表中的数据

标签 c# hypertable

我已经编写了一些 C# 代码来将数据存储到超表数据库中。但是我不知道如何更新数据。 以下是我所做的:

Hypertable b = new Hypertable();
b.Write("1", "value1");//this line is for writing to database
b.Write("1", "value111");//this line is for updating the value whose key = "1"

我的 Write 函数是:

public override bool Write(string key, string value)
{
    try
    {
        using (IContext context = Context.Create(connectionString))
        using (IClient client = context.CreateClient())
        {
            using (INamespace ns = client.OpenNamespace("Test", OpenDispositions.OpenAlways | OpenDispositions.CreateIntermediate))
            {
                using (ITable table = ns.OpenTable(tableName))
                {
                    using (ITableMutator mutator = table.CreateMutator())
                    {
                        Key _key = new Key { Row = key, ColumnFamily = "vvalue" };
                        mutator.Set(_key, Encoding.UTF8.GetBytes(value));
                    }
                }
            }
        }
        return true;
    }
    catch (Exception e)
    {
        Console.WriteLine("Hypertable--Write--{0}", e.Message);
        return false;
    }
}


所以我的更新只是用相同的键但不同的值再次写入。但是在更新后我读取了那个键和值,它应该显示新的键和值(键=“1”和值=“value111”)但它没有,它只显示旧的键和值(key = "1"and value = "value1")
我不知道为什么会这样。任何提示将不胜感激。谢谢。

最佳答案

您可以尝试将 mutator.Flush() 添加到最里面的 using block 中,尽管当 mutator 超出范围时它应该自动调用...

关于c# - 如何更新超表中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12292095/

相关文章:

Hadoop超立方体

c# - AspNetCoreModuleV2问题.NET Core 3.0

c# - MVC 5 多个 HtmlHelper.ValidationSummary 在一页上

go - 时间刻度数据库不创建超表

HBase 对比 Hyptertable 对比 Lucene

postgresql - Google Go 数据存储接口(interface)

java - Java中Hypertable中的Select语句

c# - 数据网格中的主键始终为零

c# - 使用 Linq asp.net c# 在 InsertOnSubmit() 的两个不同表中插入数据

c# - 如何获取 Stream 的底层文件句柄?