Exemplo n.º 1
0
  @Test
  public void testStreaming() throws Exception {
    ImmutableList<Symbol> toCollect = ImmutableList.<Symbol>of(new Value(DataTypes.STRING));
    UUID jobId = UUID.randomUUID();
    CollectPhase cn =
        new CollectPhase(
            jobId,
            0,
            "cn",
            new Routing(),
            RowGranularity.DOC,
            toCollect,
            ImmutableList.<Projection>of(),
            WhereClause.MATCH_ALL,
            DistributionInfo.DEFAULT_MODULO);

    BytesStreamOutput out = new BytesStreamOutput();
    cn.writeTo(out);

    BytesStreamInput in = new BytesStreamInput(out.bytes());
    CollectPhase cn2 = CollectPhase.FACTORY.create();
    cn2.readFrom(in);
    assertThat(cn, equalTo(cn2));

    assertThat(cn.toCollect(), is(cn2.toCollect()));
    assertThat(cn.executionNodes(), is(cn2.executionNodes()));
    assertThat(cn.jobId(), is(cn2.jobId()));
    assertThat(cn.executionPhaseId(), is(cn2.executionPhaseId()));
    assertThat(cn.maxRowGranularity(), is(cn2.maxRowGranularity()));
    assertThat(cn.distributionInfo(), is(cn2.distributionInfo()));
  }
Exemplo n.º 2
0
 private Bucket getBucket(CollectPhase collectNode)
     throws InterruptedException, ExecutionException {
   CollectingProjector cd = new CollectingProjector();
   JobExecutionContext.Builder builder = jobContextService.newBuilder(collectNode.jobId());
   JobCollectContext jobCollectContext =
       new JobCollectContext(
           collectNode.jobId(), collectNode, operation, RAM_ACCOUNTING_CONTEXT, cd);
   builder.addSubContext(collectNode.executionPhaseId(), jobCollectContext);
   JobExecutionContext context = jobContextService.createContext(builder);
   cd.startProjection(jobCollectContext);
   operation.collect(collectNode, cd, jobCollectContext);
   return cd.result().get();
 }