Exemplo n.º 1
0
  @Test
  public void testCollectWithPartitionedColumns() throws Throwable {
    Routing routing =
        docSchemaInfo.getTableInfo(PARTITIONED_TABLE_NAME).getRouting(WhereClause.MATCH_ALL, null);
    TableIdent tableIdent = new TableIdent(Schemas.DEFAULT_SCHEMA_NAME, PARTITIONED_TABLE_NAME);
    CollectPhase collectNode =
        getCollectNode(
            Arrays.<Symbol>asList(
                new Reference(
                    new ReferenceInfo(
                        new ReferenceIdent(tableIdent, "id"),
                        RowGranularity.DOC,
                        DataTypes.INTEGER)),
                new Reference(
                    new ReferenceInfo(
                        new ReferenceIdent(tableIdent, "date"),
                        RowGranularity.SHARD,
                        DataTypes.TIMESTAMP))),
            routing,
            WhereClause.MATCH_ALL);

    Bucket result = collect(collectNode);
    for (Row row : result) {
      System.out.println("Row:" + Arrays.toString(row.materialize()));
    }

    assertThat(result, containsInAnyOrder(isRow(1, 0L), isRow(2, 1L)));
  }
  private CollectPhase createCollectNode(
      Planner.Context plannerContext, boolean keepContextForFetcher) {
    TableInfo tableInfo = docSchemaInfo.getTableInfo("characters");

    ReferenceInfo docIdRefInfo = tableInfo.getReferenceInfo(new ColumnIdent("_docid"));
    Symbol docIdRef = new Reference(docIdRefInfo);
    List<Symbol> toCollect = ImmutableList.of(docIdRef);

    CollectPhase collectNode =
        new CollectPhase(
            UUID.randomUUID(),
            plannerContext.nextExecutionPhaseId(),
            "collect",
            tableInfo.getRouting(WhereClause.MATCH_ALL, null),
            toCollect,
            ImmutableList.<Projection>of());
    collectNode.maxRowGranularity(RowGranularity.DOC);
    collectNode.keepContextForFetcher(keepContextForFetcher);
    plannerContext.allocateJobSearchContextIds(collectNode.routing());

    return collectNode;
  }