public void SetPartitionKey(PartitionKey key, T value) { int length = _partitionKeyReadFuncs.Length; if (length > 0) { var values = new object[length]; for (int i = 0; i < length; i++) { values[i] = _partitionKeyReadFuncs[i](value); } key.Set(_partitionKeyTypes, values); } }
public void SingleTokenValue() { /* id1 | token_id1 -----+---------------------- 1 | -4069959284402364209 */ var key = new PartitionKey(); key.Set(CqlType.Int, 1); var calculatedToken = new MurmurToken(); calculatedToken.Parse(key.GetValue()); var tokenFromCassandra = new MurmurToken(); tokenFromCassandra.Parse("-4069959284402364209"); Assert.AreEqual(tokenFromCassandra, calculatedToken); }
public void CompositeTokenValueFromClass() { /* id1 | id2 | token_id1__id2 -----+-----+---------------------- 10 | 20 | -9026262514124674157 */ var key = new PartitionKey(); key.Set(new CompositeKeyType { Id1 = 10, Id2 = "20", Val="test"}); var calculatedToken = new MurmurToken(); calculatedToken.Parse(key.GetValue()); var tokenFromCassandra = new MurmurToken(); tokenFromCassandra.Parse("-9026262514124674157"); Assert.AreEqual(tokenFromCassandra, calculatedToken); }
public void CompositeTokenValue2() { /* id1 | id2 | token_id1__id2 -----+-----+---------------------- 1 | 2 | 4093852821103061060 */ var key = new PartitionKey(); key.Set(new[] { CqlType.Int, CqlType.Text }, new object[] { 1, "2" }); var calculatedToken = new MurmurToken(); calculatedToken.Parse(key.GetValue()); var tokenFromCassandra = new MurmurToken(); tokenFromCassandra.Parse("4093852821103061060"); Assert.AreEqual(tokenFromCassandra, calculatedToken); }
public void CompositeTokenValue1() { /* id1 | id2 | token_id1__id2 -----+-----+---------------------- 10 | 20 | -9026262514124674157 */ var key = new PartitionKey(); key.Set(new[] {CqlType.Int, CqlType.Text}, new object[] {10, "20"}); var calculatedToken = new MurmurToken(); calculatedToken.Parse(key.GetValue()); var tokenFromCassandra = new MurmurToken(); tokenFromCassandra.Parse("-9026262514124674157"); Assert.AreEqual(tokenFromCassandra, calculatedToken); }