use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testSearch.
@Test
public void testSearch() throws TeiidComponentException, TeiidProcessingException {
// due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("x");
e2.setType(Integer.class);
List elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 2);
int size = 1 << 16;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i, i), InsertMode.NEW, -1));
assertEquals(i + 1, map.getRowCount());
}
map.compact();
for (int i = 0; i < size; i++) {
TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
assertNotNull(tb.nextTuple());
assertNull(tb.nextTuple());
}
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testSearchWithRepeated.
@Test
public void testSearchWithRepeated() throws TeiidComponentException, TeiidProcessingException {
// due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("x");
e2.setType(Integer.class);
List<ElementSymbol> elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 2);
int size = 1 << 16;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i, i * 2), InsertMode.NEW, -1));
assertNull(map.insert(Arrays.asList(i, i * 2 + 1), InsertMode.NEW, -1));
assertEquals((i + 1) * 2, map.getRowCount());
}
map.compact();
for (int i = 0; i < size; i++) {
TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
for (int j = 0; j < 2; j++) {
assertNotNull(tb.nextTuple());
}
assertNull(tb.nextTuple());
}
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestLocalBufferService method testCheckMemPropertyGotSet.
@Test
public void testCheckMemPropertyGotSet() throws Exception {
BufferServiceImpl svc = new BufferServiceImpl();
svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
svc.setUseDisk(true);
svc.setInlineLobs(false);
svc.start();
// all the properties are set
// $NON-NLS-1$
assertTrue("Not Directory", svc.getBufferDirectory().isDirectory());
// $NON-NLS-1$
assertTrue("does not exist", svc.getBufferDirectory().exists());
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("does not end with one", svc.getBufferDirectory().getParent().endsWith("1"));
assertTrue(svc.isUseDisk());
assertFalse(svc.isInlineLobs());
BufferManagerImpl mgr = svc.getBufferManager();
SplittableStorageManager ssm = (SplittableStorageManager) ((BufferFrontedFileStoreCache) mgr.getCache()).getStorageManager();
assertTrue(((FileStorageManager) ssm.getStorageManager()).getDirectory().endsWith(svc.getBufferDirectory().getName()));
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class BaseQueryTest method doProcess.
protected void doProcess(QueryMetadataInterface metadata, String sql, CapabilitiesFinder capFinder, ProcessorDataManager dataManager, List[] expectedResults, boolean debug) throws Exception {
CommandContext context = createCommandContext();
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(context.getProcessorBatchSize());
context.setBufferManager(bm);
doProcess(metadata, sql, capFinder, dataManager, expectedResults, debug, context);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestProcessor method doProcess.
public static long doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, CommandContext context) throws Exception {
BufferManager bufferMgr = context.getBufferManager();
if (bufferMgr == null) {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(context.getProcessorBatchSize());
context.setBufferManager(bm);
bufferMgr = bm;
}
context.getNextRand(0);
if (context.getTempTableStore() == null) {
context.setTempTableStore(new TempTableStore(context.getConnectionId(), TransactionMode.ISOLATE_WRITES));
}
if (context.getGlobalTableStore() == null) {
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr, null, context.getMetadata());
context.setGlobalTableStore(gts);
}
if (!(dataManager instanceof TempTableDataManager)) {
SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
cache.setTupleBufferCache(bufferMgr);
dataManager = new TempTableDataManager(dataManager, bufferMgr, cache);
}
if (context.getQueryProcessorFactory() == null) {
context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bufferMgr, dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
}
TupleBuffer id = null;
long rowCount = 0;
try {
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
// processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
for (int i = 0; i < 100; i++) {
try {
id = collector.collectTuples();
break;
} catch (BlockedException e) {
}
}
if (id == null) {
fail("did not complete processing");
}
rowCount = id.getRowCount();
if (DEBUG) {
// $NON-NLS-1$
System.out.println("\nResults:\n" + id.getSchema());
TupleSource ts2 = id.createIndexedTupleSource();
for (int j = 0; j < rowCount; j++) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("" + j + ": " + ts2.nextTuple());
}
}
if (expectedResults != null) {
examineResults(expectedResults, bufferMgr, id);
}
} finally {
if (id != null) {
id.remove();
}
}
return rowCount;
}
Aggregations