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)); } }
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)); } }
internal void Populate(RpbIndexReq request) { if (ReturnTerms.HasValue) { request.return_terms = ReturnTerms.Value; } if (Stream.HasValue) { request.stream = Stream.Value; } if (MaxResults.HasValue) { request.max_results = (uint)MaxResults.Value; } if (!string.IsNullOrEmpty(Continuation)) { request.continuation = Continuation.ToRiakString(); } request.timeout = (uint)Timeout; if (!string.IsNullOrEmpty(TermRegex)) { request.term_regex = TermRegex.ToRiakString(); } if (PaginationSort.HasValue) { request.pagination_sort = PaginationSort.Value; } }
private RiakResult <IList <string> > IndexGetEquals(string bucket, string indexName, string value) { var message = new RpbIndexReq { bucket = bucket.ToRiakString(), index = indexName.ToRiakString(), key = value.ToRiakString(), qtype = RpbIndexReq.IndexQueryType.eq }; var result = UseConnection(conn => conn.PbcWriteRead <RpbIndexReq, RpbIndexResp>(message)); if (result.IsSuccess) { return(RiakResult <IList <string> > .Success(result.Value.keys.Select(k => k.FromRiakString()).ToList())); } return(RiakResult <IList <string> > .Error(result.ResultCode, result.ErrorMessage, result.NodeOffline)); }
private Task <RiakResult <IList <string> > > IndexGetRange(string bucket, string indexName, string minValue, string maxValue) { var message = new RpbIndexReq { bucket = bucket.ToRiakString(), index = indexName.ToRiakString(), qtype = RpbIndexReq.IndexQueryType.range, range_min = minValue.ToRiakString(), range_max = maxValue.ToRiakString() }; return(UseConnection(conn => conn.PbcWriteRead <RpbIndexReq, RpbIndexResp>(message)) .ContinueWith((Task <RiakResult <RpbIndexResp> > finishedTask) => { var result = finishedTask.Result; if (result.IsSuccess) { return RiakResult <IList <string> > .Success(result.Value.keys.Select(k => k.FromRiakString()).ToList()); } return RiakResult <IList <string> > .Error(result.ResultCode, result.ErrorMessage, result.NodeOffline); })); }
internal void Populate(RpbIndexReq request) { if (ReturnTerms.HasValue) { request.return_terms = ReturnTerms.Value; } if (Stream.HasValue) { request.stream = Stream.Value; } if (MaxResults.HasValue) { request.max_results = MaxResults.Value; } if (!string.IsNullOrEmpty(Continuation)) { request.continuation = Continuation.ToRiakString(); } }