use of org.teiid.query.processor.RegisterRequestParameter 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.processor.RegisterRequestParameter 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.processor.RegisterRequestParameter in project teiid by teiid.
the class TestSubqueryPushdown method testSubqueryProducingBuffer.
@Test
public void testSubqueryProducingBuffer() throws Exception {
TransformationMetadata tm = RealMetadataFactory.example1Cached();
String sql = "SELECT e1, (select e2 from pm2.g1 where e1 = pm1.g1.e1 order by e2 limit 1) from pm1.g1 limit 1";
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager(tm) {
@Override
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
if (command.toString().equals("SELECT g_0.e2 FROM pm2.g1 AS g_0 WHERE g_0.e1 = 'a'")) {
return new TupleSource() {
@Override
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
throw new TeiidProcessingException("something's wrong");
}
@Override
public void closeSource() {
}
};
}
return super.registerRequest(context, command, modelName, parameterObject);
}
};
hdm.addData("SELECT g_0.e1 FROM g1 AS g_0", Arrays.asList("a"));
hdm.setBlockOnce(true);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(tm);
try {
TestProcessor.helpProcess(plan, cc, hdm, new List[] { Arrays.asList(2) });
fail();
} catch (TeiidProcessingException e) {
assert (e.getMessage().contains("something's wrong"));
}
}
use of org.teiid.query.processor.RegisterRequestParameter in project teiid by teiid.
the class AccessNode method registerRequest.
private void registerRequest(Command atomicCommand) throws TeiidComponentException, TeiidProcessingException {
if (shouldEvaluate) {
projection = null;
minimizeProject(atomicCommand);
}
int limit = -1;
if (getParent() instanceof LimitNode) {
LimitNode parent = (LimitNode) getParent();
if (parent.getLimit() > 0) {
limit = parent.getLimit() + parent.getOffset();
}
}
RegisterRequestParameter param = new RegisterRequestParameter(connectorBindingId, getID(), limit);
param.info = info;
param.fetchSize = this.getBatchSize();
RowBasedSecurityHelper.checkConstraints(atomicCommand, getEvaluator(Collections.emptyMap()));
tupleSources.add(getDataManager().registerRequest(getContext(), atomicCommand, modelName, param));
if (tupleSources.size() > 1) {
reserved += getBufferManager().reserveBuffers(schemaSize, BufferReserveMode.FORCE);
}
}
use of org.teiid.query.processor.RegisterRequestParameter in project teiid by teiid.
the class TupleSourceCache method getSharedTupleSource.
public TupleSource getSharedTupleSource(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject, BufferManager bufferMgr, ProcessorDataManager pdm) throws TeiidComponentException, TeiidProcessingException {
if (sharedStates == null) {
sharedStates = new HashMap<Integer, SharedState>();
}
SharedState state = sharedStates.get(parameterObject.info.id);
if (state == null) {
state = new SharedState();
state.expectedReaders = parameterObject.info.sharingCount;
RegisterRequestParameter param = new RegisterRequestParameter(parameterObject.connectorBindingId, parameterObject.nodeID, -1);
param.fetchSize = parameterObject.fetchSize;
param.copyStreamingLobs = true;
state.ts = pdm.registerRequest(context, command, modelName, param);
if (param.doNotCache) {
return state.ts;
}
state.tb = bufferMgr.createTupleBuffer(command.getProjectedSymbols(), context.getConnectionId(), TupleSourceType.PROCESSOR);
state.id = parameterObject.info.id;
sharedStates.put(parameterObject.info.id, state);
}
return new SharedTupleSource(state);
}
Aggregations