Ejemplo n.º 1
0
  @Test
  public void testRowNumberArbitrary() throws Exception {
    List<Page> input =
        rowPagesBuilder(SINGLE_LONG)
            .row(1)
            .row(3)
            .row(5)
            .row(7)
            .pageBreak()
            .row(2)
            .row(4)
            .row(6)
            .row(8)
            .build();

    InMemoryWindowOperatorFactory operatorFactory =
        new InMemoryWindowOperatorFactory(
            0, ImmutableList.of(SINGLE_LONG), 0, ints(0), ROW_NUMBER, ints(), ints(), bools(), 10);
    Operator operator = operatorFactory.createOperator(driverContext);

    MaterializedResult expected =
        resultBuilder(FIXED_INT_64, FIXED_INT_64)
            .row(1, 1)
            .row(3, 2)
            .row(5, 3)
            .row(7, 4)
            .row(2, 5)
            .row(4, 6)
            .row(6, 7)
            .row(8, 8)
            .build();

    assertOperatorEquals(operator, input, expected);
  }
Ejemplo n.º 2
0
  @Test(
      expectedExceptions = IllegalStateException.class,
      expectedExceptionsMessageRegExp = "Task exceeded max memory size of 10B")
  public void testMemoryLimit() throws Exception {
    List<Page> input =
        rowPagesBuilder(SINGLE_LONG, SINGLE_DOUBLE)
            .row(1, 0.1)
            .row(2, 0.2)
            .pageBreak()
            .row(-1, -0.1)
            .row(4, 0.4)
            .build();

    Session session = new Session("user", "source", "catalog", "schema", "address", "agent");
    DriverContext driverContext =
        new TaskContext(
                new TaskId("query", "stage", "task"),
                executor,
                session,
                new DataSize(10, Unit.BYTE))
            .addPipelineContext(true, true)
            .addDriverContext();

    InMemoryWindowOperatorFactory operatorFactory =
        new InMemoryWindowOperatorFactory(
            0,
            ImmutableList.of(SINGLE_LONG, SINGLE_DOUBLE),
            0,
            ints(1),
            ROW_NUMBER,
            ints(),
            ints(0),
            bools(true),
            10);

    Operator operator = operatorFactory.createOperator(driverContext);

    toPages(operator, input);
  }
Ejemplo n.º 3
0
  @Test
  public void testRowNumberPartition() throws Exception {
    TupleInfo sourceTupleInfo = new TupleInfo(VARIABLE_BINARY, FIXED_INT_64, DOUBLE, BOOLEAN);

    List<Page> input =
        rowPagesBuilder(sourceTupleInfo)
            .row("b", -1, -0.1, true)
            .row("a", 2, 0.3, false)
            .row("a", 4, 0.2, true)
            .pageBreak()
            .row("b", 5, 0.4, false)
            .row("a", 6, 0.1, true)
            .build();

    InMemoryWindowOperatorFactory operatorFactory =
        new InMemoryWindowOperatorFactory(
            0,
            ImmutableList.of(sourceTupleInfo),
            0,
            ints(0),
            ROW_NUMBER,
            ints(0),
            ints(1),
            bools(true),
            10);

    Operator operator = operatorFactory.createOperator(driverContext);

    MaterializedResult expected =
        resultBuilder(VARIABLE_BINARY, FIXED_INT_64, DOUBLE, BOOLEAN, FIXED_INT_64)
            .row("a", 2, 0.3, false, 1)
            .row("a", 4, 0.2, true, 2)
            .row("a", 6, 0.1, true, 3)
            .row("b", -1, -0.1, true, 1)
            .row("b", 5, 0.4, false, 2)
            .build();

    assertOperatorEquals(operator, input, expected);
  }
Ejemplo n.º 4
0
  @Test
  public void testRowNumber() throws Exception {
    List<Page> input =
        rowPagesBuilder(SINGLE_LONG, SINGLE_DOUBLE)
            .row(2, 0.3)
            .row(4, 0.2)
            .row(6, 0.1)
            .pageBreak()
            .row(-1, -0.1)
            .row(5, 0.4)
            .build();

    InMemoryWindowOperatorFactory operatorFactory =
        new InMemoryWindowOperatorFactory(
            0,
            ImmutableList.of(SINGLE_LONG, SINGLE_DOUBLE),
            0,
            ints(1, 0),
            ROW_NUMBER,
            ints(),
            ints(0),
            bools(true),
            10);

    Operator operator = operatorFactory.createOperator(driverContext);

    MaterializedResult expected =
        resultBuilder(DOUBLE, FIXED_INT_64, FIXED_INT_64)
            .row(-0.1, -1, 1)
            .row(0.3, 2, 2)
            .row(0.2, 4, 3)
            .row(0.4, 5, 4)
            .row(0.1, 6, 5)
            .build();

    assertOperatorEquals(operator, input, expected);
  }