当前位置: 首页>>代码示例>>C#>>正文


C# RiakObject.IntIndex方法代码示例

本文整理汇总了C#中RiakObject.IntIndex方法的典型用法代码示例。如果您正苦于以下问题:C# RiakObject.IntIndex方法的具体用法?C# RiakObject.IntIndex怎么用?C# RiakObject.IntIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RiakObject的用法示例。


在下文中一共展示了RiakObject.IntIndex方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InvalidFieldNamesAndTypes

 public void InvalidFieldNamesAndTypes()
 {
     id = new RiakObjectId("indexes", "mykey", "test value");
     var obj = new RiakObject("indexes", "mykey", "test value");
     var intIdx = obj.IntIndex("test-int-idx");
     Assert.Throws<FormatException>(() => intIdx.Add("invalid-value"));
 }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:7,代码来源:SecondaryIndexes.cs

示例2: RiakIndexNameManglingIsHandledAutomatically

        public void RiakIndexNameManglingIsHandledAutomatically()
        {
            var riakObject = new RiakObject(Bucket, Key, "value");
            riakObject.BinIndex("name").Set("jeremiah");
            riakObject.BinIndex("state_bin").Set("oregon");
            riakObject.IntIndex("age").Add(32);
            riakObject.IntIndex("cats_int").Add(2);

            riakObject.BinIndexes.Values.Select(v => v.RiakIndexName).Contains("name").ShouldBeFalse();
            riakObject.BinIndexes.Values.Select(v => v.RiakIndexName).Contains("name_bin").ShouldBeTrue();
            riakObject.BinIndexes.Values.Select(v => v.RiakIndexName).Contains("state").ShouldBeFalse();
            riakObject.BinIndexes.Values.Select(v => v.RiakIndexName).Contains("state_bin").ShouldBeFalse();
            riakObject.BinIndexes.Values.Select(v => v.RiakIndexName).Contains("state_bin_bin").ShouldBeTrue();

            riakObject.IntIndexes.Values.Select(v => v.RiakIndexName).Contains("age").ShouldBeFalse();
            riakObject.IntIndexes.Values.Select(v => v.RiakIndexName).Contains("age_int").ShouldBeTrue();
            riakObject.IntIndexes.Values.Select(v => v.RiakIndexName).Contains("cats").ShouldBeFalse();
            riakObject.IntIndexes.Values.Select(v => v.RiakIndexName).Contains("cats_int").ShouldBeFalse();
            riakObject.IntIndexes.Values.Select(v => v.RiakIndexName).Contains("cats_int_int").ShouldBeTrue();
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:20,代码来源:RiakObjectTests.cs

示例3: RiakIndexingSupportsMultipleValuesCorrectly

        public void RiakIndexingSupportsMultipleValuesCorrectly()
        {
            var riakObject = new RiakObject(Bucket, Key, "value");

            riakObject.BinIndex("jobs").Set("dogsbody");
            riakObject.BinIndex("jobs").Values.Count.ShouldEqual(1);

            riakObject.BinIndex("jobs").Add("toilet cleaner", "president", "juggler");
            riakObject.BinIndex("jobs").Values.Count.ShouldEqual(4);

            riakObject.BinIndex("jobs").Remove("dogsbody", "juggler");
            riakObject.BinIndex("jobs").Values.Count.ShouldEqual(2);

            riakObject.BinIndex("jobs").Set("general", "engineer", "cook");
            riakObject.BinIndex("jobs").Values.Count.ShouldEqual(3);
            riakObject.BinIndex("jobs").Values.Contains("general").ShouldBeTrue();

            riakObject.BinIndex("jobs").Clear();
            riakObject.BinIndex("jobs").Values.Count.ShouldEqual(0);

            riakObject.BinIndex("jobs").Delete();
            riakObject.BinIndexes.ContainsKey("jobs").ShouldBeFalse();

            riakObject.IntIndex("years").Set(10);
            riakObject.IntIndex("years").Values.Count.ShouldEqual(1);

            riakObject.IntIndex("years").Add(20, 40, 999);
            riakObject.IntIndex("years").Values.Count.ShouldEqual(4);

            riakObject.IntIndex("years").Remove(40, 999);
            riakObject.IntIndex("years").Values.Count.ShouldEqual(2);

            riakObject.IntIndex("years").Set(51, 52, 53);
            riakObject.IntIndex("years").Values.Count.ShouldEqual(3);
            riakObject.IntIndex("years").Values.Contains(52).ShouldBeTrue();

            riakObject.IntIndex("years").Clear();
            riakObject.IntIndex("years").Values.Count.ShouldEqual(0);

            riakObject.IntIndex("years").Delete();
            riakObject.IntIndexes.ContainsKey("years").ShouldBeFalse();
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:42,代码来源:RiakObjectTests.cs

示例4: SecondaryIndexesAreForcedToLowerCase

        public void SecondaryIndexesAreForcedToLowerCase()
        {
            var obj = new RiakObject(Bucket, Key);

            obj.BinIndex("UPPERCASE").Set("foo");
            obj.IntIndex("MixedCase").Set(10);

            obj.BinIndexes.ContainsKey("uppercase").ShouldBeTrue();
            obj.IntIndexes.ContainsKey("mixedcase").ShouldBeTrue();

            obj.BinIndex("UPPERCASE").Values.First().ShouldEqual("foo");
            obj.BinIndex("uppercase").Values.First().ShouldEqual("foo");
            obj.IntIndex("MixedCase").Values.First().ShouldEqual(10);
            obj.IntIndex("mixedcase").Values.First().ShouldEqual(10);
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:15,代码来源:RiakObjectTests.cs

示例5: QueryingByIntIndexReturnsAListOfKeys

        public void QueryingByIntIndexReturnsAListOfKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, Guid.NewGuid().ToString(), "{\"value\":\"this is an object\"}");
                o.IntIndex("age").Set(32, 20);

                Client.Put(o);
            }

            var mr = new RiakMapReduceQuery()
                .Inputs(RiakIndex.Match(Bucket, "age", 32));

            var result = Client.MapReduce(mr);
            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);

            var keys = result.Value.PhaseResults.SelectMany(x => x.GetObjectIds()).ToList();

            keys.Count().ShouldEqual(10);

            foreach (var key in keys)
            {
                key.Bucket.ShouldNotBeNullOrEmpty();
                key.Key.ShouldNotBeNullOrEmpty();
            }
        }
开发者ID:TWith2Sugars,项目名称:CorrugatedIron,代码行数:26,代码来源:RiakIndexTests.cs

示例6: IntRangeQueriesReturnMultipleKeys

        public void IntRangeQueriesReturnMultipleKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, Guid.NewGuid().ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("age").Set(25 + i);

                Client.Put(o);
            }

            var mr = new RiakMapReduceQuery()
                .Inputs(RiakIndex.Range(Bucket, "age", 27, 30));

            var result = Client.MapReduce(mr);
            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            result.Value.PhaseResults.SelectMany(x => x.GetObjectIds()).Count().ShouldEqual(4);

            // TODO write tests verifying results
        }
开发者ID:TWith2Sugars,项目名称:CorrugatedIron,代码行数:19,代码来源:RiakIndexTests.cs

示例7: IntIndexGetReturnsListOfKeys

        public void IntIndexGetReturnsListOfKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, i.ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("age").Add(32);

                Client.Put(o);
            }

            var result = Client.IndexGet(Bucket, "age", 32);
            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            result.Value.Count.ShouldEqual(10);

            foreach (var v in result.Value)
            {
                var key = int.Parse(v);
                key.ShouldBeLessThan(10);
                key.ShouldBeGreaterThan(-1);
            }
        }
开发者ID:TWith2Sugars,项目名称:CorrugatedIron,代码行数:21,代码来源:RiakIndexTests.cs

示例8: IndexesAreSavedWithAnObject

        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");
            o.BinIndex("tacos").Set("are great!");
            o.IntIndex("age").Set(12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            var ro = result.Value;

            ro.BinIndexes.Count.ShouldEqual(1);
            ro.IntIndexes.Count.ShouldEqual(1);
        }
开发者ID:TWith2Sugars,项目名称:CorrugatedIron,代码行数:16,代码来源:RiakIndexTests.cs

示例9: Test2iOperations

        public void Test2iOperations()
        {
            const string indexName = "num";
            const string key1 = "key1";
            const string key2 = "key2";

            var obj1 = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key1), Value);
            obj1.IntIndex(indexName).Add(1);

            var obj2 = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key2), Value);
            obj2.IntIndex(indexName).Add(2);

            Client.Put(obj1, new RiakPutOptions().SetDw(3));
            Client.Put(obj2, new RiakPutOptions().SetDw(3));

            // fetch 2i
            var indexId = new RiakIndexId(TestBucketType, TestBucket, indexName);
            var indexResult = Client.GetSecondaryIndex(indexId, 1, 2, new RiakIndexGetOptions().SetReturnTerms(true));

            indexResult.IsSuccess.ShouldBeTrue();
            var keyTerms = indexResult.Value.IndexKeyTerms.ToList();
            var keys = keyTerms.Select(t => t.Key).ToList();
            var terms = keyTerms.Select(t => t.Term).ToList();

            keys.ShouldContain(key1);
            keys.ShouldContain(key2);

            terms.ShouldContain("1");
            terms.ShouldContain("2");
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:30,代码来源:BucketTypeTests.cs

示例10: StreamingIndexGetReturnsAllData

        public void StreamingIndexGetReturnsAllData()
        {
            var bucket = Bucket;

            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(bucket, Guid.NewGuid().ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("position").Set(i % 2);

                Client.Put(o, new RiakPutOptions().SetW(RiakConstants.QuorumOptions.All)
                                                  .SetDw(RiakConstants.QuorumOptions.All));
            }

            var results = Client.StreamIndexGet(bucket, "position", 0);;
            results.IndexKeyTerms.Count().ShouldEqual(5);
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:16,代码来源:RiakIndexTests.cs

示例11: IntRangeQueriesReturnMultipleKeys

        public void IntRangeQueriesReturnMultipleKeys()
        {
            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(Bucket, Guid.NewGuid().ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("age").Set(25 + i);

                Client.Put(o);
            }

            var result = Client.IndexGet(Bucket, "age", 27, 30);
            result.IndexKeyTerms.Count().ShouldEqual(4);

            // TODO write tests verifying results
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:15,代码来源:RiakIndexTests.cs

示例12: GettingKeysWithReturnTermsDoesAThing

        public void GettingKeysWithReturnTermsDoesAThing()
        {
            var bucket = Bucket;
            var keysAndTerms = new Dictionary<string, int>();

            for (var i = 0; i < 10; i++)
            {
                var o = new RiakObject(bucket, Guid.NewGuid().ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("sandwiches").Set(i);
                keysAndTerms.Add(o.Key, i);

                Client.Put(o);
            }

            var results = Client.IndexGet(bucket, "sandwiches", 2, 5, new RiakIndexGetOptions().SetReturnTerms(true).SetMaxResults(100).SetStream(false));

            results.IndexKeyTerms.Count().ShouldEqual(4);

            foreach (var indexResult in results.IndexKeyTerms)
            {
                keysAndTerms.Keys.ShouldContain(indexResult.Key);
                keysAndTerms[indexResult.Key].ShouldEqual(int.Parse(indexResult.Term));
            }
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:24,代码来源:RiakIndexTests.cs

示例13: GettingKeysWithContinuationDoesNotSetDone

        public void GettingKeysWithContinuationDoesNotSetDone()
        {
            var bucket = Bucket;

            for (var i = 0; i < 1000; i++)
            {
                var o = new RiakObject(bucket, Guid.NewGuid().ToString(), "{ value: \"this is an object\" }");
                o.IntIndex("position").Set(i);

                Client.Put(o);
            }

            var results = Client.IndexGet(bucket, "position", 10, 500, new RiakIndexGetOptions().SetMaxResults(10));

            results.IndexKeyTerms.Count().ShouldEqual(10);

            results.Done.ShouldNotEqual(true);
            results.Done.ShouldEqual(false);
            results.Continuation.ShouldNotBeNull();
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:20,代码来源:RiakIndexTests.cs

示例14: PutObjectsWithIndexValues

        private ICollection<RiakObjectId> PutObjectsWithIndexValues()
        {
            var ids = new List<RiakObjectId>();

            var larryId = new RiakObjectId("indexes", "people", "larry");
            var larry = new RiakObject(larryId, "My name is Larry",
                RiakConstants.ContentTypes.TextPlain);

            larry.BinIndex("field1").Set("val1");
            larry.IntIndex("field2").Set(1001);

            ids.Add(larryId);
            CheckResult(client.Put(larry));

            var moeId = new RiakObjectId("indexes", "people", "moe");
            var moe = new RiakObject(moeId, "My name is Moe",
                RiakConstants.ContentTypes.TextPlain);

            moe.BinIndex("Field1").Set("val2");
            moe.IntIndex("Field2").Set(1002);

            ids.Add(moeId);
            CheckResult(client.Put(moe));

            var curlyId = new RiakObjectId("indexes", "people", "curly");
            var curly = new RiakObject(curlyId, "My name is Curly",
                RiakConstants.ContentTypes.TextPlain);

            curly.BinIndex("FIELD1").Set("val3");
            curly.IntIndex("FIELD2").Set(1003);

            ids.Add(curlyId);
            CheckResult(client.Put(curly));

            var veronicaId = new RiakObjectId("indexes", "people", "veronica");
            var veronica = new RiakObject(veronicaId, "My name is Curly",
                RiakConstants.ContentTypes.TextPlain);

            veronica.BinIndex("FIELD1").Set(new string[] { "val4", "val4" });
            veronica.IntIndex("FIELD2").Set(new BigInteger[] {
                1004, 1005, 1006, 1004, 1004, 1007
            });

            ids.Add(veronicaId);
            CheckResult(client.Put(veronica));

            return ids;
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:48,代码来源:SecondaryIndexes.cs


注:本文中的RiakObject.IntIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。