internal override CollectionEnumerator <TObj, ValueWithAddressIndexKey <TAttribute> > BuildEnumerator(bool descending) { var startKey = new ValueWithAddressIndexKey <TAttribute> { V = this.StartAt }; var endKey = new ValueWithAddressIndexKey <TAttribute> { V = this.EndAt }; BTreeWalkerRange <ValueWithAddressIndexKey <TAttribute> > range; if (!descending) { range = new BTreeWalkerRange <ValueWithAddressIndexKey <TAttribute> >(startKey, endKey); range.IncludeStartAt = this.IncludeStartAt; range.IncludeEndAt = this.IncludeEndAt; } else { //start and end are reversed range = new BTreeWalkerRange <ValueWithAddressIndexKey <TAttribute> >(endKey, startKey); range.IncludeStartAt = this.IncludeEndAt; range.IncludeEndAt = this.IncludeStartAt; } return(this.IndexedValue.BuildEnumerator(range, descending)); }
internal override ValueWithAddressIndexKey <TValue> ReadValue(BinaryFormatter formatter) { var result = new ValueWithAddressIndexKey <TValue>(); result.A = formatter.ReadInt64(); result.V = this.ValueSerializer.ReadValue(formatter); return(result); }
public void Compares_On_Address_When_Size_Is_Equal() { var key1 = new ValueWithAddressIndexKey <int> { V = 1, A = 1 }; var key2 = new ValueWithAddressIndexKey <int> { V = 1, A = 2 }; Assert.IsTrue(key1.CompareTo(key2) < 0); }
public void Compares_On_Value_First() { var key1 = new ValueWithAddressIndexKey <int> { V = 1, A = 2 }; var key2 = new ValueWithAddressIndexKey <int> { V = 2, A = 1 }; Assert.IsTrue(key1.CompareTo(key2) < 0); }
internal override IEnumerable <object> GetKeys(object o, long address) { var value = base.ValueFunction((TObj)o).FirstOrDefault(); var indexKey = new ValueWithAddressIndexKey <TAttribute> { V = value, A = 0 //Makes entries unique }; return(new object[] { indexKey }); }
internal CollectionEnumerator <TObj, ValueWithAddressIndexKey <TAttribute> > EqualsInternal(IEnumerable <TAttribute> values) { var ranges = values.Select((value) => { var key = new ValueWithAddressIndexKey <TAttribute> { V = value }; return(new BTreeWalkerRange <ValueWithAddressIndexKey <TAttribute> >(key, key)); }); return(BuildEnumerator(ranges)); }
public void Compares_DateTimes_With_Millisecond_Precision() { var date = new DateTime(2017, 01, 01); var datePlus1Tick = new DateTime(date.Ticks + 1); var key1 = new ValueWithAddressIndexKey <DateTime> { V = date, A = 1 }; var key2 = new ValueWithAddressIndexKey <DateTime> { V = datePlus1Tick, A = 1 }; Assert.AreEqual(0, key1.CompareTo(key2)); }
public void Can_Be_Serialized() { var key = new ValueWithAddressIndexKey <int> { A = 10, V = 20 }; var serializer = new BsonSerializer <ValueWithAddressIndexKey <int> >(); var deserialized = serializer.Deserialize( serializer.Serialize(key) ); Assert.AreEqual(key.A, deserialized.A); Assert.AreEqual(key.V, deserialized.V); }
public void Considers_Equal_When_Address_Missing() { var key1 = new ValueWithAddressIndexKey <int> { V = 1, A = 1 }; var key2 = new ValueWithAddressIndexKey <int> { V = 1 }; Assert.AreEqual(0, key1.CompareTo(key2)); Assert.AreEqual(0, key2.CompareTo(key1)); Assert.IsTrue(key1.Equals(key2)); Assert.IsTrue(key2.Equals(key1)); }
internal override CollectionEnumerator <TObj, ValueWithAddressIndexKey <TAttribute> > BuildEnumerator(bool descending) { var startKey = new ValueWithAddressIndexKey <TAttribute> { V = (TAttribute)this.Value }; var range = new BTreeWalkerRange <ValueWithAddressIndexKey <TAttribute> >(); if (!descending) { range.SetStartAt(startKey); range.IncludeStartAt = this.OrEqual; } else { range.SetEndAt(startKey); range.IncludeEndAt = this.OrEqual; } return(this.IndexedValue.BuildEnumerator(range, descending)); }
internal override void WriteValue(BinaryFormatter formatter, ValueWithAddressIndexKey <TValue> value) { formatter.WriteInt64(value.A); this.ValueSerializer.WriteValue(formatter, value.V); }