public static void AssertBinEqual(Key key, Record record, String binName, Object expected) { AssertRecordFound(key, record); object received = record.GetValue(binName); if (received == null || !received.Equals(expected)) { Assert.Fail("Data mismatch: Expected " + expected + ". Received " + received); } }
public bool AssertBinEqual(Key key, Record record, string binName, object expected) { if (!AssertRecordFound(key, record)) { return false; } object received = record.GetValue(binName); if (received == null || !received.Equals(expected)) { monitor.SetError("Data mismatch: Expected " + expected + ". Received " + received); } return true; }
public void scanTweetsCallback(Key key, Record record) { Console.WriteLine(record.GetValue("tweet")); }
private void ValidateBin(Key key, Bin bin, Record record) { object received = record.GetValue(bin.name); string expected = bin.value.ToString(); if (received != null && received.Equals(expected)) { console.Info("Bin matched: namespace={0} set={1} key={2} bin={3} value={4} generation={5} expiration={6}", key.ns, key.setName, key.userKey, bin.name, received, record.generation, record.expiration); } else { console.Error("Put/Get mismatch: Expected {0}. Received {1}.", expected, received); } }
public Security(Record record) { ticker = (string)record.GetValue("ticker"); // Convert price double from byte[]. byte[] priceBytes = (byte[])record.GetValue("price"); price = BitConverter.ToDouble(priceBytes, 0); }
public void OnRecord(Key key, Record record) { if (parent.AssertRecordFound(key, record)) { Object value = record.GetValue(binName); parent.AssertNotNull(value); } }
public virtual void OnRecord(Key key, Record record) { Log.Level level = Log.Level.ERROR; object value = null; if (record != null) { level = Log.Level.INFO; value = record.GetValue(parent.binName); } parent.console.Write(level, "Record: namespace={0} set={1} key={2} bin={3} value={4}", key.ns, key.setName, ByteUtil.BytesToHexString(key.digest), parent.binName, value); }
private bool FilterBinByRange(Record record, String bin, Value low, Value high) { if (record == null) return false; object value = record.GetValue (bin); if (value is IList) { //TODO return false; } else if (value is IDictionary) { IDictionary dict = (IDictionary)value; object keyValue = dict["key"]; if (keyValue == null) return false; return FilterRange (keyValue, low, high); } else { return FilterRange (value, low, high); } }
private string EventToString(Record eventRecord) { // Note: If we want to get a list of all the records to iterate through rather than just the count, // we get the maximum sequence from the count, iterate through the keys from 2->Max Sequence (as we // already have record 1), form a list of keys then do a batch read. This code is provided for clarity String user = eventRecord.GetString("user-id"); String dateStr = eventRecord.GetString ("day"); List<Object> events = (List<Object>) eventRecord.GetValue ("events"); int count = eventRecord.GetInt ("total-records"); if (count < 0) { // Another thread has this record locked. Either retry or throw an exception throw new AerospikeException ("Record locked"); } // TODO: We really need to obtain a lock to the record by setting total-records to -1 whilst we read it. // This is similar to the code in AddEvent, and probably should be put into a common routine. Otherwise // we risk the collection changing whilst we're still using it. List<Key> keyList = new List<Key> (); for (int i = 2; i <= GetSequenceNumberFromRecordNumber (count); i++) { keyList.Add (new Key ("test", "user-events", FormKeyString (user, dateStr, i))); } Key[] keys = keyList.ToArray (); Record[] records = client.Get (null, keys); foreach (Record record in records) { if (record != null) { List<Object> theseEvents = (List<Object>)record.GetValue ("events"); events.AddRange(theseEvents); } } String result = eventRecord.GetString ("user-id") + ":" + eventRecord.GetString ("day") + ":" + eventRecord.GetInt ("sequence") + ":" + events.Count; return result; }
private void JoinRecords(BatchPolicy policy, Record record, Join[] joins) { if (record == null) { return; } foreach (Join join in joins) { List<object> keyList = (List<object>)record.GetValue(join.leftKeysBinName); if (keyList != null) { Key[] keyArray = new Key[keyList.Count]; int count = 0; foreach (object obj in keyList) { Value value = Value.Get(obj); keyArray[count++] = new Key(join.rightNamespace, join.rightSetName, value); } Record[] records; if (join.rightBinNames == null || join.rightBinNames.Length == 0) { records = Get(policy, keyArray); } else { records = Get(policy, keyArray, join.rightBinNames); } record.bins[join.leftKeysBinName] = records; } } }