public async Task <RiakStreamedMapReduceResult> StreamMapReduce(RiakMapReduceQuery query) { var request = query.ToMessage(); var response = _connection .PbcWriteStreamRead <RpbMapRedReq, RpbMapRedResp>(_endPoint, request, r => !r.done); return(new RiakStreamedMapReduceResult(response)); }
public void BuildingMapReducePhaseWithVaueTypeArgumentProducesCorrectResult() { var query = new RiakMapReduceQuery() .Inputs("animals") .ReduceJs(c => c.Name("Riak.reduceSlice").Keep(true).Argument("slartibartfast")); var request = query.ToMessage(); request.request.ShouldEqual(MrJobWithValueTypeArgument.ToRiakString()); }
public void BuildingMapReducePhaseWithObjectArgumentProducesCorrectResult() { var query = new RiakMapReduceQuery() .Inputs("animals") .ReduceJs(c => c.Name("Riak.reduceSlice").Keep(true).Argument(new { reduce_phase_only_1 = true })); var request = query.ToMessage(); request.request.ShouldEqual(MrJobWithObjectArgument.ToRiakString()); }
public void BuildingComplexMapReduceJobsWithTheApiProducesTheCorrectCommand() { var query = new RiakMapReduceQuery() .Inputs("animals") .MapJs(m => m.Source("function(o) { if (o.key.indexOf('spider') != -1) return [1]; return []; }")) .ReduceJs(r => r.Name("Riak.reduceSum").Keep(true)); var request = query.ToMessage(); request.request.ShouldEqual(ComplexMrJobText.ToRiakString()); }
public void BuildingSimpleMapReduceJobsWithTimeoutProducesTheCorrectCommand() { var query = new RiakMapReduceQuery(100200) .Inputs("animals") .MapJs(m => m.Source("function(v) { return [v]; }").Keep(true)); var request = query.ToMessage(); request.content_type.ShouldEqual(MrContentType.ToRiakString()); request.request.ShouldEqual(MrJobWithTimeoutText.ToRiakString()); }
public void BuildingSimpleMapReduceJobsWithTheApiProducesByteArrays() { var query = new RiakMapReduceQuery() .Inputs("animals") .MapJs(m => m.Source("function(v) { return [v]; }").Keep(true)); var request = query.ToMessage(); request.content_type.ShouldEqual(MrContentType.ToRiakString()); request.request.ShouldEqual(MrJobText.ToRiakString()); }
public void QueryingDollarKeyDoesNotAppendBinIndexSuffix() { var query = new RiakMapReduceQuery() .Inputs(RiakIndex.Range(new RiakIndexId("animals", "$key"), "0", "zzzzz")); var request = query.ToMessage(); var requestString = request.request.FromRiakString(); requestString.Contains("$key").ShouldBeTrue(); requestString.Contains("$key_bin").ShouldBeFalse(); }
public void BuildingMapReducePhaseWithArgumentsArrayProducesCorrectResult() { var query = new RiakMapReduceQuery { ContentType = MrContentType } .Inputs("animals") .ReduceJs(c => c.Name("Riak.reduceSlice").Keep(true).Argument(new [] { 1, 10 })); var request = query.ToMessage(); request.request.ShouldEqual(MrJobWithArgumentsArray.ToRiakString()); }
public RiakResult <RiakStreamedMapReduceResult> StreamMapReduce(RiakMapReduceQuery query) { var request = query.ToMessage(); var response = UseDelayedConnection((conn, onFinish) => conn.PbcWriteStreamRead <RpbMapRedReq, RpbMapRedResp>(request, r => r.IsSuccess && !r.Value.Done, onFinish)); if (response.IsSuccess) { return(RiakResult <RiakStreamedMapReduceResult> .Success(new RiakStreamedMapReduceResult(response.Value))); } return(RiakResult <RiakStreamedMapReduceResult> .Error(response.ResultCode, response.ErrorMessage)); }
public RiakResult <RiakMapReduceResult> MapReduce(RiakMapReduceQuery query) { var request = query.ToMessage(); var response = UseConnection(conn => conn.PbcWriteRead <RpbMapRedReq, RpbMapRedResp>(request, r => r.IsSuccess && !r.Value.done)); if (response.IsSuccess) { return(RiakResult <RiakMapReduceResult> .Success(new RiakMapReduceResult(response.Value))); } return(RiakResult <RiakMapReduceResult> .Error(response.ResultCode, response.ErrorMessage, response.NodeOffline)); }
public void BuildingComplexMapReduceJobsWithFiltersProducesTheCorrectCommand() { #pragma warning disable 618 var query = new RiakMapReduceQuery() .Inputs("animals") .Filter(f => f.Matches("spider")) .MapJs(m => m.Source("function(o) { return [1]; }")) .ReduceJs(r => r.Name("Riak.reduceSum").Keep(true)); #pragma warning restore 618 var request = query.ToMessage(); request.request.ShouldEqual(ComplexMrJobWithFilterText.ToRiakString()); }
public Task <RiakResult <RiakMapReduceResult> > MapReduce(RiakMapReduceQuery query) { var request = query.ToMessage(); return(UseConnection(conn => conn.PbcWriteRead <RpbMapRedReq, RpbMapRedResp>(request, r => r.IsSuccess && !r.Value.done)) .ContinueWith((Task <RiakResult <IEnumerable <RiakResult <RpbMapRedResp> > > > finishedTask) => { var result = finishedTask.Result; if (result.IsSuccess) { return RiakResult <RiakMapReduceResult> .Success(new RiakMapReduceResult(result.Value)); } return RiakResult <RiakMapReduceResult> .Error(result.ResultCode, result.ErrorMessage, result.NodeOffline); })); }
public void BuildingComplexMapReduceJobsWithFiltersProducesTheCorrectCommand() { var query = new RiakMapReduceQuery { ContentType = MrContentType } .Inputs("animals") //.Filter(new Matches<string>("spider")) .Filter(f => f.Matches("spider")) .MapJs(m => m.Source("function(o) { return [1]; }")) .ReduceJs(r => r.Name("Riak.reduceSum").Keep(true)); var request = query.ToMessage(); request.request.ShouldEqual(ComplexMrJobWithFilterText.ToRiakString()); }