public void QueryingIntegerRangeWithReturnTerms()
        {
            ids = PutObjectsWithIndexValues();

            var idxId   = new RiakIndexId("indexes", "people", "field2");
            var options = new RiakIndexGetOptions();

            options.SetReturnTerms(true);
            var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);

            CheckResult(rslt);
            Assert.AreEqual(3, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value, printTerms: true);
        }
        public void Pagination()
        {
            ids = PutObjectsWithIndexValues();

            var idxId   = new RiakIndexId("indexes", "people", "field2");
            var options = new RiakIndexGetOptions();

            options.SetMaxResults(2);
            var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);

            CheckResult(rslt);
            Assert.AreEqual(2, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value);

            options.SetContinuation(rslt.Continuation);
            rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);
            CheckResult(rslt);
            Assert.AreEqual(1, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value);
        }
Пример #3
0
 private static bool ReturnTerms(RiakIndexGetOptions options)
 {
     return(options.ReturnTerms != null && options.ReturnTerms.Value);
 }
Пример #4
0
 public Task <Either <RiakException, RiakIndexResult> > IndexGet(string bucket, string indexName, string value, RiakIndexGetOptions options = null)
 {
     return(IndexGetEquals(bucket, indexName.ToBinaryKey(), value, options));
 }
Пример #5
0
 public Task <Either <RiakException, RiakIndexResult> > IndexGet(string bucket, string indexName, BigInteger value, RiakIndexGetOptions options = null)
 {
     return(IndexGetEquals(bucket, indexName.ToIntegerKey(), value.ToString(), options));
 }
Пример #6
0
 public Task <RiakResult <RiakStreamedIndexResult> > StreamIndexGet(string bucket, string indexName, string minValue, string maxValue, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => _client.StreamIndexGet(bucket, indexName, minValue, maxValue, options)));
 }
Пример #7
0
 public Task <RiakResult <RiakIndexResult> > IndexGet(string bucket, string indexName, string value, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => _client.IndexGet(bucket, indexName, value, options)));
 }
        public void Pagination()
        {
            ids = PutObjectsWithIndexValues();

            var idxId = new RiakIndexId("indexes", "people", "field2");
            var options = new RiakIndexGetOptions();
            options.SetMaxResults(2);
            var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);
            CheckResult(rslt);
            Assert.AreEqual(2, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value);

            options.SetContinuation(rslt.Continuation);
            rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);
            CheckResult(rslt);
            Assert.AreEqual(1, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value);
        }
Пример #9
0
 public Task <Either <RiakException, RiakStreamedIndexResult> > StreamIndexGet(string bucket, string indexName, string minValue, string maxValue, RiakIndexGetOptions options = null)
 {
     return(StreamIndexGetRange(bucket, indexName.ToBinaryKey(), minValue, maxValue, options));
 }
 /// <inheritdoc/>
 public Task <RiakResult <RiakStreamedIndexResult> > StreamGetSecondaryIndex(RiakIndexId index, string min, string max, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => client.StreamGetSecondaryIndex(index, min, max, options)));
 }
 /// <inheritdoc/>
 public Task <RiakResult <RiakStreamedIndexResult> > StreamGetSecondaryIndex(RiakIndexId index, BigInteger value, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => client.StreamGetSecondaryIndex(index, value, options)));
 }
 /// <inheritdoc/>
 public Task <RiakResult <RiakIndexResult> > GetSecondaryIndex(RiakIndexId index, BigInteger min, BigInteger max, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => client.GetSecondaryIndex(index, min, max, options)));
 }
 /// <inheritdoc/>
 public Task <RiakResult <RiakIndexResult> > GetSecondaryIndex(RiakIndexId index, string value, RiakIndexGetOptions options = null)
 {
     return(Task.Factory.StartNew(() => client.GetSecondaryIndex(index, value, options)));
 }
Пример #14
0
        private async Task <Either <RiakException, RiakIndexResult> > IndexGetEquals(string bucket, string indexName, string value, RiakIndexGetOptions options = null)
        {
            var message = new RpbIndexReq
            {
                bucket = bucket.ToRiakString(),
                index  = indexName.ToRiakString(),
                key    = value.ToRiakString(),
                qtype  = RpbIndexReq.IndexQueryType.eq
            };

            options = options ?? new RiakIndexGetOptions();
            options.Populate(message);

            try
            {
                var result = await _connection.PbcWriteRead <RpbIndexReq, RpbIndexResp>(_endPoint, message).ConfigureAwait(false);

                var includeTerms    = ReturnTerms(options);
                var riakIndexResult = new RiakIndexResult(includeTerms, result);

                return(new Either <RiakException, RiakIndexResult>(riakIndexResult));
            }
            catch (RiakException riakException)
            {
                return(new Either <RiakException, RiakIndexResult>(riakException));
            }
        }
Пример #15
0
        /// <summary>
        /// Retrieve index results using the streaming interface.
        /// </summary>
        /// <param name="bucket">The bucket</param>
        /// <param name="indexName">The index</param>
        /// <param name="minValue">The start of the indexed range to search for</param>
        /// <param name="maxValue">The end of the indexed range to search for</param>
        /// <param name="options">The <see cref="RiakIndexGetOptions"/></param>
        /// <returns>A <see cref="RiakResult{T}"/> of <see cref="RiakStreamedIndexResult"/> containing an <see cref="IEnumerable{T}"/>
        /// of <see cref="RiakIndexKeyTerm"/></returns>
        /// <remarks>Make sure to fully enumerate the <see cref="IEnumerable{T}"/> of <see cref="RiakIndexKeyTerm"/>.</remarks>
        public RiakStreamedIndexResult StreamIndexGet(string bucket, string indexName, string minValue, string maxValue, RiakIndexGetOptions options = null)
        {
            var result = Async.StreamIndexGet(bucket, indexName, minValue, maxValue, options).ConfigureAwait(false).GetAwaiter().GetResult();

            if (result.IsLeft)
            {
                throw result.Left;
            }
            return(result.Right);
        }
Пример #16
0
 public Task <Either <RiakException, RiakStreamedIndexResult> > StreamIndexGet(string bucket, string indexName, BigInteger minValue, BigInteger maxValue, RiakIndexGetOptions options = null)
 {
     return(StreamIndexGetRange(bucket, indexName.ToIntegerKey(), minValue.ToString(), maxValue.ToString(), options));
 }
Пример #17
0
        /// <summary>
        /// Retrieve a indexed values
        /// </summary>
        /// <param name="bucket">The bucket</param>
        /// <param name="indexName">The index</param>
        /// <param name="value">The indexed value to search for</param>
        /// <param name="options">The <see cref="RiakIndexGetOptions"/></param>
        /// <returns>A <see cref="RiakResult{T}"/> of <see cref="RiakIndexResult"/></returns>
        public RiakIndexResult IndexGet(string bucket, string indexName, BigInteger value, RiakIndexGetOptions options = null)
        {
            var result = Async.IndexGet(bucket, indexName, value, options).ConfigureAwait(false).GetAwaiter().GetResult();

            if (result.IsLeft)
            {
                throw result.Left;
            }
            return(result.Right);
        }
Пример #18
0
        private async Task <Either <RiakException, RiakStreamedIndexResult> > StreamIndexGetRange(string bucket, string indexName, string minValue, string maxValue, RiakIndexGetOptions options = null)
        {
            var message = new RpbIndexReq
            {
                bucket    = bucket.ToRiakString(),
                index     = indexName.ToRiakString(),
                qtype     = RpbIndexReq.IndexQueryType.range,
                range_min = minValue.ToRiakString(),
                range_max = maxValue.ToRiakString(),
                stream    = true
            };

            options = options ?? new RiakIndexGetOptions();
            options.Populate(message);

            try
            {
                var result                  = _connection.PbcWriteStreamRead <RpbIndexReq, RpbIndexResp>(_endPoint, message, lbr => !lbr.done);
                var includeTerms            = ReturnTerms(options);
                var riakStreamedIndexResult = new RiakStreamedIndexResult(includeTerms, result);

                return(new Either <RiakException, RiakStreamedIndexResult>(riakStreamedIndexResult));
            }
            catch (RiakException riakException)
            {
                return(new Either <RiakException, RiakStreamedIndexResult>(riakException));
            }
        }
        public void QueryingIntegerRangeWithReturnTerms()
        {
            ids = PutObjectsWithIndexValues();

            var idxId = new RiakIndexId("indexes", "people", "field2");
            var options = new RiakIndexGetOptions();
            options.SetReturnTerms(true);
            var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options);
            CheckResult(rslt);
            Assert.AreEqual(3, rslt.Value.IndexKeyTerms.Count());
            PrintKeys(rslt.Value, printTerms: true);
        }