Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }