I have written some C# code to store data into hypertable database. However I don't know how to update the data.
Below is what I have done:
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"
and my Write function is:
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;
}
}
So my update is simply write again with the same key but different value. However after updating I do a read of that key and value, it is supposed to show the new key and value (key = "1" and value = "value111") but it doesn't, it just shows the old key and value (key = "1" and value = "value1")
I don't know why this happens. Any tips will be appreciated. Thanks.