use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestTupleSourceCache method testNodeId.
@Test
public void testNodeId() throws Exception {
TupleSourceCache tsc = new TupleSourceCache();
HardcodedDataManager pdm = new HardcodedDataManager() {
@Override
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
assertEquals(1, parameterObject.nodeID);
return Mockito.mock(TupleSource.class);
}
};
CommandContext context = TestProcessor.createCommandContext();
BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
Command command = new Insert();
RegisterRequestParameter parameterObject = new RegisterRequestParameter("z", 1, 1);
parameterObject.info = new RegisterRequestParameter.SharedAccessInfo();
tsc.getSharedTupleSource(context, command, "x", parameterObject, bufferMgr, pdm);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestDataTierManager method testCheckForUpdatesWithBatched.
@Test
public void testCheckForUpdatesWithBatched() throws Exception {
helpSetupDataTierManager();
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
AtomicRequestMessage request = helpSetupRequest("delete from bqt1.smalla", 1, metadata);
Command command = helpGetCommand("insert into bqt1.smalla (stringkey) values ('1')", metadata);
BatchedUpdateCommand bac = new BatchedUpdateCommand(Arrays.asList(request.getCommand(), command));
request.setCommand(bac);
DataTierTupleSource dtts = new DataTierTupleSource(request, workItem, connectorManager.registerRequest(request), dtm, limit);
pullTuples(dtts, 2);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestDataTierManager method testCaching.
@Test
public void testCaching() throws Exception {
assertEquals(0, connectorManager.getExecuteCount().get());
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
CacheDirective cd = new CacheDirective();
this.connectorManager.cacheDirective = cd;
helpSetupDataTierManager();
Command command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
RegisterRequestParameter rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
TupleSource ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(1, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
assertFalse(((CachingTupleSource) ts).dtts.errored);
assertNull(((CachingTupleSource) ts).dtts.scope);
ts.closeSource();
assertEquals(1, this.rm.getRsCache().getCachePutCount());
assertEquals(1, this.rm.getRsCache().getTotalCacheEntries());
// same session, should be cached
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertFalse(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(1, connectorManager.getExecuteCount().get());
assertTrue(rrp.doNotCache);
// switch sessions
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
this.context.getSession().setSessionId("different");
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(9, pullTuples(ts, 9));
assertEquals(2, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
// should force read all
ts.closeSource();
assertFalse(((CachingTupleSource) ts).dtts.errored);
assertNull(((CachingTupleSource) ts).dtts.scope);
assertEquals(2, this.rm.getRsCache().getCachePutCount());
assertEquals(2, this.rm.getRsCache().getTotalCacheEntries());
// proactive invalidation, removes immediately
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
cd.setInvalidation(Invalidation.IMMEDIATE);
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(3, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestDataTierManager method helpGetCommand.
private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
return command;
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestPreparedPlanCache method helpPutPreparedPlans.
// ====Help methods====//
private void helpPutPreparedPlans(SessionAwareCache<PreparedPlan> cache, DQPWorkContext session, int start, int count) {
for (int i = 0; i < count; i++) {
Command dummy;
try {
dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + (start + i));
} catch (QueryParserException e) {
throw new RuntimeException(e);
}
CacheID id = new CacheID(session, pi, dummy.toString());
PreparedPlan pPlan = new PreparedPlan();
cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null);
pPlan.setCommand(dummy);
pPlan.setPlan(new RelationalPlan(new ProjectNode(i)), new CommandContext());
AnalysisRecord analysisRecord = new AnalysisRecord(true, false);
pPlan.setAnalysisRecord(analysisRecord);
ArrayList<Reference> refs = new ArrayList<Reference>();
refs.add(new Reference(1));
pPlan.setReferences(refs);
}
}
Aggregations