First I would like to congratulate Aerospike for their outstanding work. I’ve only started evaluating but so far I am very impressed. Despite that, and the excellent documentation, I am having a strange issue that I was hoping someone could help me with. I’m using the Vagrant VM for OSX and connecting to it from a VMWare Fusion VM on the same Mac; I had to play with the Vagrant default networking (disable port forwarding and enable bridging) but communication is working fine. I can write and read from the DB.
I’m uploading price data from a CSV to Aerospike as follows:
var ns = “test”; var set = “CL_Tick4”; var csvResource = “Z:\SSD\IQFeed\CL.txt”;
// Initialize policy. WritePolicy policy = new WritePolicy(); policy.timeout = 500; // 50 millisecond timeout.
// Establish connection the server AerospikeClient client = new AerospikeClient(“192.168.2.11”, 3000);
var streamReader = new StreamReader(csvResource); using (var streadmReader = new StreamReader(csvResource)) { string line = streamReader.ReadLine(); while (line != null) { var tokens = line.Split(‘,’); if (tokens.Count() == 10) { int objectID = int.Parse(tokens[6], NumberFormatInfo.InvariantInfo); Key key = new Key(ns, set, objectID); Bin TimeStamp = new Bin(“TimeStamp”, DateTime.Parse(tokens[0])); Bin Last = new Bin(“Last”, double.Parse(tokens[1])); Bin LastSize = new Bin(“LastSize”, int.Parse(tokens[2])); Bin TotalVolume = new Bin(“TotalVolume”, int.Parse(tokens[3])); Bin Bid = new Bin(“Bid”, double.Parse(tokens[4])); Bin Ask = new Bin(“Ask”, double.Parse(tokens[5])); Bin TickId = new Bin(“TickId”, int.Parse(tokens[6])); Bin BasisForLast = new Bin(“BasisForLast”, tokens[7]); Bin TradeMarketCenter = new Bin(“TradeMarketCtr”, int.Parse(tokens[8])); Bin TradeConditions = new Bin(“TradeCondition”, tokens[9]); client.Put(policy, key, TimeStamp, Last, LastSize, TotalVolume, Bid, Ask, TickId, BasisForLast, TradeMarketCenter, TradeConditions); } line = streamReader.ReadLine(); } }
This operating completes and the set appears to contain all the records… here’s what the output from AQL looks like for one row:
| 00 01 00 00 00 FF FF FF FF 01 00 00 00 00 00 00 00 04 01 00 00 00 0F 53 79 73 74 65 6D 2E 44 61 74 65 54 69 6D 65 02 00 00 00 05 74 69 63 6B 73 08 64 61 74 65 44 61 74 61 00 00 09 10 40 A9 B4 1F A9 FF D1 08 40 A9 B4 1F A9 FF D1 08 0B | 4632016955995198587 | 1 | 287595 | 4632012733870547927 | 4632014141245431480 | 14767640 | “C” | 36 | “01” |
This has me a little confused, as the output doesn’t resemble the input, however I’m assuming that Aerospike’s internal datatypes are going to be different from what I passed in. I’m using two examples to learn how to query the db from C#. The first is the Twitter sample application and the second is the Query example in the C# Client documentation. First, let me say, that if I upload the same data to Aerospike as text, without parsing to c# value types first, and run the twitter example, it works; I can return a price using the TickId as a secondary index.
If, however, I kill that index and create a new numeric one, and use the datatype parsed file and attempt to return an integer like this:
rs = client.Query(null, stmt); while (rs.Next()) { Record r = rs.Record; var result = Convert.ToDouble(r.GetValue(“last”)); Console.WriteLine(result); }
I get this:
Here’s 5634976’s Last:
0
If I modify that and don’t convert the value like this: rs = client.Query(null, stmt); while (rs.Next()) { Record r = rs.Record; Console.WriteLine(r.GetValue(“Last”)); }
I get 4631596150905016156
If, however, I use the examples to do a simple write of one record, using the name / age example, I get the age=25 with no issue. So I’m assuming that there is some issue with the way I am parsing the CSV and sending it up to Aerospike…
I hope that was enough information, if you require more clarification please let me know. Any assistance you can offer would be greatly appreciated.
Kind Regards
/W