use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestSTree method testRemoveAll.
@Test
public void testRemoveAll() throws TeiidComponentException {
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("y");
e2.setType(String.class);
List<ElementSymbol> elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 1);
for (int i = 20000; i > 0; i--) {
assertNull(map.insert(Arrays.asList(i, String.valueOf(i)), InsertMode.NEW, -1));
assertEquals(20000 - i + 1, map.getRowCount());
}
for (int i = 20000; i > 0; i--) {
assertNotNull(String.valueOf(i), map.remove(Arrays.asList(i)));
}
assertEquals(0, map.getRowCount());
assertNull(map.insert(Arrays.asList(1, String.valueOf(1)), InsertMode.NEW, -1));
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestTupleBuffer method testForwardOnly.
@Test
public void testForwardOnly() throws Exception {
// $NON-NLS-1$
ElementSymbol x = new ElementSymbol("x");
x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
List<ElementSymbol> schema = Arrays.asList(x);
// $NON-NLS-1$
TupleBuffer tb = BufferManagerFactory.getStandaloneBufferManager().createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR);
tb.setForwardOnly(true);
tb.addTuple(Arrays.asList(1));
TupleBatch batch = tb.getBatch(1);
assertTrue(!batch.getTerminationFlag());
assertEquals(1, batch.getBeginRow());
try {
tb.getBatch(1);
// $NON-NLS-1$
fail("expected exception");
} catch (AssertionError e) {
}
tb.addTuple(Arrays.asList(1));
tb.close();
batch = tb.getBatch(2);
assertTrue(batch.getTerminationFlag());
assertEquals(2, batch.getBeginRow());
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestTupleBuffer method testTruncatePartial.
@Test
public void testTruncatePartial() throws Exception {
// $NON-NLS-1$
ElementSymbol x = new ElementSymbol("x");
x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
List<ElementSymbol> schema = Arrays.asList(x);
// $NON-NLS-1$
TupleBuffer tb = BufferManagerFactory.getStandaloneBufferManager().createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR);
tb.setBatchSize(64);
for (int i = 0; i < 65; i++) {
tb.addTuple(Arrays.asList(1));
}
TupleBatch batch = tb.getBatch(1);
assertTrue(!batch.getTerminationFlag());
assertEquals(65, tb.getManagedRowCount());
tb.truncateTo(3);
assertEquals(3, tb.getManagedRowCount());
assertEquals(3, tb.getRowCount());
batch = tb.getBatch(3);
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestTupleBuffer method testTruncateMultiple.
@Test
public void testTruncateMultiple() throws Exception {
// $NON-NLS-1$
ElementSymbol x = new ElementSymbol("x");
x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
List<ElementSymbol> schema = Arrays.asList(x);
// $NON-NLS-1$
TupleBuffer tb = BufferManagerFactory.getStandaloneBufferManager().createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR);
tb.setBatchSize(16);
for (int i = 0; i < 131; i++) {
tb.addTuple(Arrays.asList(1));
}
tb.truncateTo(17);
assertEquals(17, tb.getManagedRowCount());
assertEquals(17, tb.getRowCount());
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestBufferManagerImpl method testProcessorBatchSize.
@Test
public void testProcessorBatchSize() {
BufferManager bm = BufferManagerFactory.createBufferManager();
int processorBatchSize = bm.getProcessorBatchSize();
List<ElementSymbol> elements = new ArrayList<ElementSymbol>();
ElementSymbol a = new ElementSymbol("a");
a.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// we use a somewhat high estimate of string size
ElementSymbol b = new ElementSymbol("b");
b.setType(DataTypeManager.DefaultDataClasses.STRING);
elements.add(a);
// fixed/small
assertEquals(processorBatchSize * 8, bm.getProcessorBatchSize(elements));
elements.add(b);
// small
assertEquals(processorBatchSize * 4, bm.getProcessorBatchSize(elements));
elements.add(b);
// moderately small
assertEquals(processorBatchSize * 2, bm.getProcessorBatchSize(elements));
elements.add(b);
elements.add(b);
// "normal"
assertEquals(processorBatchSize, bm.getProcessorBatchSize(elements));
elements.addAll(Collections.nCopies(28, b));
// large
assertEquals(processorBatchSize / 2, bm.getProcessorBatchSize(elements));
elements.addAll(Collections.nCopies(100, b));
// huge
assertEquals(processorBatchSize / 4, bm.getProcessorBatchSize(elements));
elements.addAll(Collections.nCopies(375, b));
// extreme
assertEquals(processorBatchSize / 8, bm.getProcessorBatchSize(elements));
}
Aggregations