Search in sources :

Example 11 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestGroupingNode method test3.

// Same as test2, but uses processor batch size smaller than number of groups
@Test
public void test3() throws Exception {
    BufferManagerImpl mgr = BufferManagerFactory.createBufferManager();
    mgr.setProcessorBatchSize(5);
    GroupingNode node = getExampleGroupingNode();
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "test", null, null, 1);
    List[] expected = new List[] { Arrays.asList(new Object[] { null, new Integer(1) }), Arrays.asList(new Object[] { new Integer(0), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(2), new Integer(2) }), Arrays.asList(new Object[] { new Integer(3), new Integer(1) }), Arrays.asList(new Object[] { new Integer(4), new Integer(2) }), Arrays.asList(new Object[] { new Integer(5), new Integer(1) }), Arrays.asList(new Object[] { new Integer(6), new Integer(2) }) };
    helpProcess(mgr, node, context, expected, null);
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) CommandContext(org.teiid.query.util.CommandContext) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 12 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestJoinNode method testDupRemoveUnderJoin.

@Test
public void testDupRemoveUnderJoin() throws Exception {
    // $NON-NLS-1$
    String sql = "select a.e1, b.e2 from pm1.g1 as a, (select distinct e1, e2 from pm2.g2) as b";
    ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
    HardcodedDataManager hdm = new HardcodedDataManager() {

        public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
            final TupleSource source = super.registerRequest(context, command, modelName, parameterObject);
            return new TupleSource() {

                private int block;

                @Override
                public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
                    if (block++ % 2 == 0) {
                        throw BlockedException.INSTANCE;
                    }
                    return source.nextTuple();
                }

                @Override
                public void closeSource() {
                    source.closeSource();
                }
            };
        }
    };
    List<?>[] rows = new List<?>[1];
    for (int i = 0; i < rows.length; i++) {
        rows[i] = Arrays.asList(String.valueOf(i));
    }
    hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
    rows = new List<?>[1025];
    for (int i = 0; i < rows.length; i++) {
        rows[i] = Arrays.asList(String.valueOf(i), i);
    }
    hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
    BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
    mgr.setTargetBytesPerRow(100);
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "test", null, null, 1);
    List<?>[] results = new List<?>[1025];
    for (int i = 0; i < results.length; i++) {
        results[i] = Arrays.asList("0", i);
    }
    TestProcessor.helpProcess(plan, context, hdm, results);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) Command(org.teiid.query.sql.lang.Command) TupleSource(org.teiid.common.buffer.TupleSource) ArrayList(java.util.ArrayList) List(java.util.List) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) Test(org.junit.Test)

Example 13 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestJoinNode method testPrefetchDistinct.

@Test
public void testPrefetchDistinct() throws Exception {
    // $NON-NLS-1$
    String sql = "select a.e1, b.e2 from pm1.g1 as a, (select e1, e2 from pm2.g2 union select e1, e2 from pm2.g2) as b";
    ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
    HardcodedDataManager hdm = new HardcodedDataManager() {

        public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
            final TupleSource source = super.registerRequest(context, command, modelName, parameterObject);
            return new TupleSource() {

                private int block;

                @Override
                public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
                    if (block++ % 2 == 0) {
                        throw BlockedException.INSTANCE;
                    }
                    return source.nextTuple();
                }

                @Override
                public void closeSource() {
                    source.closeSource();
                }
            };
        }
    };
    List<?>[] rows = new List<?>[2];
    for (int i = 0; i < rows.length; i++) {
        rows[i] = Arrays.asList(String.valueOf(i));
    }
    hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
    rows = new List<?>[2];
    for (int i = 0; i < rows.length; i++) {
        rows[i] = Arrays.asList(String.valueOf(i), i);
    }
    hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
    BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
    mgr.setTargetBytesPerRow(100);
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "test", null, null, 1);
    context.setBufferManager(mgr);
    TestProcessor.helpProcess(plan, context, hdm, new List<?>[] { Arrays.asList("0", 0), Arrays.asList("0", 1), Arrays.asList("1", 0), Arrays.asList("1", 1) });
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) Command(org.teiid.query.sql.lang.Command) TupleSource(org.teiid.common.buffer.TupleSource) ArrayList(java.util.ArrayList) List(java.util.List) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) Test(org.junit.Test)

Example 14 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestAggregateProcessing method testArrayAggOrderByPersistence.

@Test
public void testArrayAggOrderByPersistence() throws Exception {
    // Create query
    // $NON-NLS-1$
    String sql = "SELECT array_agg(e2 order by e1) from pm1.g1 group by e3";
    // Create expected results
    List[] expected = new List[] { Arrays.asList(new ArrayImpl(new Integer[] { 1, 0, 0, 2 })), Arrays.asList(new ArrayImpl(new Integer[] { 3, 1 })) };
    // Construct data manager with data
    FakeDataManager dataManager = new FakeDataManager();
    sampleData1(dataManager);
    // Plan query
    ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
    CommandContext cc = TestProcessor.createCommandContext();
    BufferManagerImpl impl = BufferManagerFactory.getTestBufferManager(0, 2);
    cc.setBufferManager(impl);
    // Run query
    helpProcess(plan, cc, dataManager, expected);
}
Also used : BigInteger(java.math.BigInteger) CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) ArrayImpl(org.teiid.core.types.ArrayImpl) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 15 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestEnginePerformance method oneTimeSetup.

@BeforeClass
public static void oneTimeSetup() throws TeiidComponentException {
    bm = new BufferManagerImpl();
    bm.setMaxProcessingKB(1 << 12);
    bm.setMaxReserveKB((1 << 18) - (1 << 16));
    bm.setMaxActivePlans(20);
    cache = new BufferFrontedFileStoreCache();
    cache.setMemoryBufferSpace(1 << 26);
    FileStorageManager fsm = new FileStorageManager();
    fsm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + "/data");
    cache.setStorageManager(fsm);
    cache.initialize();
    bm.setCache(cache);
    bm.initialize();
    es = Executors.newCachedThreadPool();
}
Also used : BufferFrontedFileStoreCache(org.teiid.common.buffer.impl.BufferFrontedFileStoreCache) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) FileStorageManager(org.teiid.common.buffer.impl.FileStorageManager) BeforeClass(org.junit.BeforeClass)

Aggregations

BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)34 Test (org.junit.Test)24 CommandContext (org.teiid.query.util.CommandContext)13 List (java.util.List)11 ArrayList (java.util.ArrayList)8 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)8 RequestMessage (org.teiid.client.RequestMessage)6 ResultsMessage (org.teiid.client.ResultsMessage)5 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)5 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)4 TupleSource (org.teiid.common.buffer.TupleSource)3 BufferFrontedFileStoreCache (org.teiid.common.buffer.impl.BufferFrontedFileStoreCache)3 FileStorageManager (org.teiid.common.buffer.impl.FileStorageManager)3 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)3 Command (org.teiid.query.sql.lang.Command)3 BufferServiceImpl (org.teiid.services.BufferServiceImpl)3 HashMap (java.util.HashMap)2 BlockedException (org.teiid.common.buffer.BlockedException)2 BufferManager (org.teiid.common.buffer.BufferManager)2 TupleBatch (org.teiid.common.buffer.TupleBatch)2