Esempio n. 1
0
  @Test
  public void testForwardOnly() throws Exception {
    ElementSymbol x = new ElementSymbol("x"); // $NON-NLS-1$
    x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    List<ElementSymbol> schema = Arrays.asList(x);
    TupleBuffer tb =
        BufferManagerFactory.getStandaloneBufferManager()
            .createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR); // $NON-NLS-1$
    tb.setForwardOnly(true);
    tb.addTuple(Arrays.asList(1));
    TupleBatch batch = tb.getBatch(1);
    assertTrue(!batch.getTerminationFlag());
    assertEquals(1, batch.getBeginRow());
    try {
      tb.getBatch(1);
      fail("expected exception"); // $NON-NLS-1$
    } catch (AssertionError e) {

    }
    tb.addTuple(Arrays.asList(1));
    tb.close();
    batch = tb.getBatch(2);
    assertTrue(batch.getTerminationFlag());
    assertEquals(2, batch.getBeginRow());
  }
Esempio n. 2
0
 /**
  * Create a new iterator for this buffer
  *
  * @return
  */
 public TupleBufferTupleSource createIndexedTupleSource(final boolean singleUse) {
   if (singleUse) {
     setForwardOnly(true);
   }
   return new TupleBufferTupleSource(singleUse);
 }