Ejemplo n.º 1
0
  private void helpTestNextBatch(int tupleBatchSize, Mode mode) throws Exception {

    ProjectIntoNode node = new ProjectIntoNode(2);

    TupleSource tupleSource = new FakeDataTupleSource(NUM_ROWS);
    RelationalNode child = new FakeRelationalNode(1, tupleSource, tupleBatchSize);
    node.addChild(child);
    node.setIntoGroup(new GroupSymbol("myGroup")); // $NON-NLS-1$
    ElementSymbol elementSymbol_1 = new ElementSymbol("myGroup.myElement1"); // $NON-NLS-1$
    ElementSymbol elementSymbol_2 = new ElementSymbol("myGroup.myElement2"); // $NON-NLS-1$
    elementSymbol_1.setType(Integer.class);
    elementSymbol_2.setType(String.class);
    List<ElementSymbol> elements = Arrays.asList(elementSymbol_1, elementSymbol_2);
    node.setIntoElements(elements);
    child.setElements(elements);
    node.setMode(mode);
    node.setModelName("myModel"); // $NON-NLS-1$

    CommandContext context = new CommandContext();
    BufferManager bm = BufferManagerFactory.getTestBufferManager(tupleBatchSize, tupleBatchSize);
    ProcessorDataManager dataManager = new FakePDM(tupleBatchSize);

    child.initialize(context, bm, dataManager);
    node.initialize(context, bm, dataManager);
    node.open();

    TupleBatch batch = null;
    // Do the remaining batches
    while (true) {
      try {
        batch = node.nextBatch();
        break;
      } catch (BlockedException e) {
        // Normal
      }
    }
    assertNotNull(batch);
    List[] tuples = batch.getAllTuples();
    assertEquals(1, tuples.length);
    Object[] columns = tuples[0].toArray();
    assertNotNull(columns);
    assertEquals(1, columns.length);
    // Should have inserted all rows
    assertEquals(new Integer(NUM_ROWS), columns[0]);
  }