use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class EvaluatorIterator method init.
@Override
public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
try {
GroupSymbol gs = null;
String query = options.get(QUERYSTRING);
TransformationMetadata tm = createTransformationMetadata(options.get(DDL));
this.criteria = QueryParser.getQueryParser().parseCriteria(query);
this.elementsInExpression = ElementCollectorVisitor.getElements(this.criteria, false);
for (ElementSymbol es : this.elementsInExpression) {
gs = es.getGroupSymbol();
ResolverUtil.resolveGroup(gs, tm);
}
ResolverVisitor.resolveLanguageObject(this.criteria, tm);
this.evaluatorUtil = new EvaluatorUtil(gs);
} catch (QueryParserException e) {
throw new IOException(e);
} catch (ClassNotFoundException e) {
throw new IOException(e);
} catch (QueryResolverException e) {
throw new IOException(e);
} catch (TeiidComponentException e) {
throw new IOException(e);
}
CommandContext cc = new CommandContext();
this.evaluator = new Evaluator(this.evaluatorUtil.getElementMap(), null, cc);
}
use of org.teiid.query.util.CommandContext 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.util.CommandContext 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);
}
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestFunction method testCurrentDate.
// case 2458
@Test
public void testCurrentDate() throws Exception {
Date curDate = (Date) FunctionMethods.currentDate(new CommandContext());
Calendar cal1 = Calendar.getInstance();
cal1.setTime(curDate);
assertEquals(cal1.get(Calendar.HOUR_OF_DAY), 0);
assertEquals(cal1.get(Calendar.MINUTE), 0);
assertEquals(cal1.get(Calendar.SECOND), 0);
assertEquals(cal1.get(Calendar.MILLISECOND), 0);
}
use of org.teiid.query.util.CommandContext in project teiid by teiid.
the class TestFunction method testRand.
@Test
public void testRand() throws Exception {
Double d = (Double) FunctionMethods.rand(new CommandContext(), new Integer(100));
assertEquals(new Double(0.7220096548596434), d);
FunctionMethods.rand(new CommandContext());
}
Aggregations