public void Delete_One_Row() { var delete = new Delete.Builder() .WithTable(Table) .WithKey(KeyToDelete) .Build(); RiakResult rslt = client.Execute(delete); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); Assert.IsFalse(delete.Response.NotFound); var get = new Get.Builder() .WithTable(Table) .WithKey(KeyToDelete) .Build(); rslt = client.Execute(get); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); Assert.IsTrue(get.Response.NotFound); var store = new Store.Builder() .WithTable(Table) .WithRow(RowToRestore) .Build(); rslt = client.Execute(store); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); }
/* * NB: MUST use 18.3 since R16 will generate floats as strings * T = {tsputreq,<<"GeoCheckin">>,[],[ * {false,12.34,32,1449000732345,<<"foobar">>}, * {true,56.78,54,1449000737345,<<"bazbat">>}]}. * rp(term_to_binary(T)). * <<131,104,4,100,0,8,116,115,112,117,116,114,101,113,109,0, * 0,0,10,71,101,111,67,104,101,99,107,105,110,106,108,0,0, * 0,2,104,5,100,0,5,102,97,108,115,101,70,64,40,174,20, * 122,225,71,174,97,32,110,6,0,185,134,44,95,81,1,109,0,0, * 0,6,102,111,111,98,97,114,104,5,100,0,4,116,114,117,101, * 70,64,76,99,215,10,61,112,164,97,54,110,6,0,65,154,44, * 95,81,1,109,0,0,0,6,98,97,122,98,97,116,106>> */ protected static Store BuildStoreReq() { var cmd = new Store.Builder() .WithTable(Table) .WithColumns(Columns) .WithRows(Rows) .Build(); return(cmd); }
public override void TestFixtureSetUp() { var cmd = new Store.Builder() .WithTable(Table) .WithColumns(Columns) .WithRows(Rows) .Build(); RiakResult rslt = client.Execute(cmd); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); }
Store _Store(params object[] rows) { var b = new Store.Builder() .WithTable(Name) .WithColumns(Columns); foreach (var item in rows) { b.WithRow(Serializer.Serialize(item)); } return(b.Build()); }
private async Task InsertMessagesIntoDatabase(string table, List <Message> allMessages) { IRiakEndPoint cluster = RiakCluster.FromConfig("riakConfig"); IRiakClient client = cluster.CreateClient(); while (allMessages.Count() > 0) { List <Message> messages = allMessages.Take(80).ToList(); allMessages.RemoveRange(0, messages.Count()); var rows = new List <Row>(); foreach (Message message in messages) { var cells = new Cell[] { new Cell("LT"), new Cell(message.SerialNo), new Cell(message.DeviceName), new Cell(message.Timestamp), new Cell(message.Value) }; rows.Add(new Row(cells)); } var columns = new Column[] { new Column("Country", ColumnType.Varchar), new Column("SerialNo", ColumnType.Varchar), new Column("DeviceName", ColumnType.Varchar), new Column("Time", ColumnType.Timestamp), new Column("Value", ColumnType.Double) }; var cmd = new Store.Builder() .WithTable(table) .WithColumns(columns) .WithRows(rows) .Build(); RiakResult rslt = client.Execute(cmd); if (!rslt.IsSuccess) { throw new Exception("Connection to Riak was not successful. AllMessages: " + allMessages.Count()); } } }
private void InsertMessageIntoDatabase(string table, Message message) { IRiakEndPoint cluster = RiakCluster.FromConfig("riakConfig"); IRiakClient client = cluster.CreateClient(); var cells = new Cell[] { new Cell("LT"), new Cell(message.SerialNo), new Cell(message.DeviceName), new Cell(message.Timestamp), new Cell(message.Value) }; var rows = new Row[] { new Row(cells) }; var columns = new Column[] { new Column("Country", ColumnType.Varchar), new Column("SerialNo", ColumnType.Varchar), new Column("DeviceName", ColumnType.Varchar), new Column("Time", ColumnType.Timestamp), new Column("Value", ColumnType.Double) }; var cmd = new Store.Builder() .WithTable(table) .WithColumns(columns) .WithRows(rows) .Build(); RiakResult rslt = client.Execute(cmd); if (!rslt.IsSuccess) { throw new Exception("Connection to Riak was not successful."); } }
public void Test_List_Key_With_Blob_Key_Cell() { const string TableName = "BLURB"; var testColumns = new List<Column> { new Column("blurb", ColumnType.Blob), new Column("time", ColumnType.Timestamp) }; Row testRow = new Row( new List<Cell> { new Cell(new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }, ColumnType.Blob), new Cell(1443806900000, true) }); // Store the key var cmd = new Store.Builder() .WithTable(TableName) .WithColumns(testColumns) .WithRows(new List<Row> { testRow }) .Build(); RiakResult rslt = client.Execute(cmd); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); // List the single key var listedKeys = new List<Row>(); Action<ListKeysResponse> cb = qr => { listedKeys.AddRange(qr.Value); }; var listKeysCommand = new ListKeys.Builder() .WithTable(TableName) .WithCallback(cb) .Build(); RiakResult listKeysResult = client.Execute(listKeysCommand); Assert.IsTrue(listKeysResult.IsSuccess, listKeysResult.ErrorMessage); ListKeysResponse listKeysResponse = listKeysCommand.Response; Assert.IsFalse(listKeysResponse.NotFound); Assert.AreEqual(1, listedKeys.Count); var keyCells = listedKeys[0].Cells.ToList(); Assert.AreEqual(2, keyCells.Count); // List keys should return the BLOB column as a VARCHAR Assert.AreEqual(ColumnType.Varchar, keyCells[0].ValueType); Assert.AreEqual(ColumnType.Timestamp, keyCells[1].ValueType); // Get the single row var getCmd = new Get.Builder() .WithTable(TableName) .WithKey(listedKeys[0]) .Build(); RiakResult getResult = client.Execute(getCmd); Assert.IsTrue(getResult.IsSuccess, getResult.ErrorMessage); GetResponse getResponse = getCmd.Response; var getRows = getResponse.Value.ToArray(); Assert.AreEqual(1, getRows.Length); var getCells = getRows[0].Cells.ToArray(); Assert.AreEqual(2, getCells.Length); Assert.AreEqual(ColumnType.Blob, getCells[0].ValueType); Assert.AreEqual(ColumnType.Timestamp, getCells[1].ValueType); }
public void Delete_One_Row() { var delete = new Delete.Builder() .WithTable(Table) .WithKey(KeyToDelete) .Build(); RiakResult rslt = client.Execute(delete); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); Assert.IsFalse(delete.Response.NotFound); var get = new Get.Builder() .WithTable(Table) .WithKey(KeyToDelete) .Build(); rslt = client.Execute(get); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); Assert.IsTrue(get.Response.NotFound); var store = new Store.Builder() .WithTable(Table) .WithRow(RowToRestore) .Build(); rslt = client.Execute(store); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); }
public override void TestFixtureSetUp() { var cmd = new Store.Builder() .WithTable(Table) .WithColumns(Columns) .WithRows(Rows) .Build(); RiakResult rslt = client.Execute(cmd); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); }
/* * NB: MUST use 18.3 since R16 will generate floats as strings T = {tsputreq,<<"GeoCheckin">>,[],[ {false,12.34,32,1449000732345,<<"foobar">>}, {true,56.78,54,1449000737345,<<"bazbat">>}]}. rp(term_to_binary(T)). <<131,104,4,100,0,8,116,115,112,117,116,114,101,113,109,0, 0,0,10,71,101,111,67,104,101,99,107,105,110,106,108,0,0, 0,2,104,5,100,0,5,102,97,108,115,101,70,64,40,174,20, 122,225,71,174,97,32,110,6,0,185,134,44,95,81,1,109,0,0, 0,6,102,111,111,98,97,114,104,5,100,0,4,116,114,117,101, 70,64,76,99,215,10,61,112,164,97,54,110,6,0,65,154,44, 95,81,1,109,0,0,0,6,98,97,122,98,97,116,106>> */ protected static Store BuildStoreReq() { var cmd = new Store.Builder() .WithTable(Table) .WithColumns(Columns) .WithRows(Rows) .Build(); return cmd; }
public void Test_List_Key_With_Blob_Key_Cell() { const string TableName = "BLURB"; var testColumns = new List <Column> { new Column("blurb", ColumnType.Blob), new Column("time", ColumnType.Timestamp) }; Row testRow = new Row( new List <Cell> { new Cell(new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }, ColumnType.Blob), new Cell(1443806900000, true) }); // Store the key var cmd = new Store.Builder() .WithTable(TableName) .WithColumns(testColumns) .WithRows(new List <Row> { testRow }) .Build(); RiakResult rslt = client.Execute(cmd); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); // List the single key var listedKeys = new List <Row>(); Action <ListKeysResponse> cb = qr => { listedKeys.AddRange(qr.Value); }; var listKeysCommand = new ListKeys.Builder() .WithTable(TableName) .WithCallback(cb) .Build(); RiakResult listKeysResult = client.Execute(listKeysCommand); Assert.IsTrue(listKeysResult.IsSuccess, listKeysResult.ErrorMessage); ListKeysResponse listKeysResponse = listKeysCommand.Response; Assert.IsFalse(listKeysResponse.NotFound); Assert.AreEqual(1, listedKeys.Count); var keyCells = listedKeys[0].Cells.ToList(); Assert.AreEqual(2, keyCells.Count); // List keys should return the BLOB column as a VARCHAR Assert.AreEqual(ColumnType.Varchar, keyCells[0].ValueType); Assert.AreEqual(ColumnType.Timestamp, keyCells[1].ValueType); // Get the single row var getCmd = new Get.Builder() .WithTable(TableName) .WithKey(listedKeys[0]) .Build(); RiakResult getResult = client.Execute(getCmd); Assert.IsTrue(getResult.IsSuccess, getResult.ErrorMessage); GetResponse getResponse = getCmd.Response; var getRows = getResponse.Value.ToArray(); Assert.AreEqual(1, getRows.Length); var getCells = getRows[0].Cells.ToArray(); Assert.AreEqual(2, getCells.Length); Assert.AreEqual(ColumnType.Blob, getCells[0].ValueType); Assert.AreEqual(ColumnType.Timestamp, getCells[1].ValueType); }