Exemple #1
0
        public void Can_Update_A_Hll()
        {
            string key = Guid.NewGuid().ToString();

            SaveHll(key);

            var add_3 = new RiakString("add_3");
            var adds  = new HashSet <string> {
                add_3
            };

            var update = new UpdateHll.Builder(adds)
                         .WithBucketType(BucketType)
                         .WithBucket(Bucket)
                         .WithKey(key)
                         .WithReturnBody(true)
                         .WithTimeout(TimeSpan.FromMilliseconds(20000))
                         .Build();

            RiakResult rslt = client.Execute(update);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            HllResponse response = update.Response;

            Assert.AreEqual(3, response.Cardinality);
        }
Exemple #2
0
        public void Riak_Can_Generate_Key()
        {
            HllResponse r = SaveHll();

            Assert.True(EnumerableUtil.NotNullOrEmpty((string)r.Key));
            Log.DebugFormat("Riak Generated Key: {0}", r.Key);
        }
Exemple #3
0
        public void Fetching_An_Unknown_Hll_Results_In_Not_Found()
        {
            var fetch = new FetchHll.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(Guid.NewGuid().ToString())
                        .Build();

            RiakResult rslt = client.Execute(fetch);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);
            HllResponse response = fetch.Response;

            Assert.IsTrue(response.NotFound);
        }
Exemple #4
0
        public void Should_Construct_HllResponse_From_DtUpdateResp()
        {
            var key = new RiakString("riak_generated_key");

            var updateResp = new DtUpdateResp();

            updateResp.key       = key;
            updateResp.hll_value = 42;

            var update = new UpdateHll.Builder(DefaultAdds)
                         .WithBucketType(BucketType)
                         .WithBucket(Bucket)
                         .Build();

            update.OnSuccess(updateResp);

            HllResponse response = update.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(42, response.Value);
        }
Exemple #5
0
        public void Fetching_A_Hll_Produces_Expected_Values()
        {
            string key = Guid.NewGuid().ToString();

            SaveHll(key);

            var fetch = new FetchHll.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(key)
                        .Build();

            RiakResult rslt = client.Execute(fetch);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            HllResponse response = fetch.Response;

            Assert.IsNotNull(response);

            Assert.IsNull(response.Context);
            Assert.AreEqual(2, response.Cardinality);
        }
Exemple #6
0
        private HllResponse SaveHll(string key = null)
        {
            var updateBuilder = new UpdateHll.Builder(DefaultAdds)
                                .WithBucketType(BucketType)
                                .WithBucket(Bucket)
                                .WithTimeout(TimeSpan.FromMilliseconds(20000));

            if (!string.IsNullOrEmpty(key))
            {
                updateBuilder.WithKey(key);
            }

            UpdateHll  cmd  = updateBuilder.Build();
            RiakResult rslt = client.Execute(cmd);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            HllResponse response = cmd.Response;

            Keys.Add(response.Key);
            Assert.IsNull(response.Context);
            return(response);
        }