use of org.teiid.client.plan.PlanNode in project teiid by teiid.
the class RequestWorkItem method setAnalysisRecords.
private void setAnalysisRecords(ResultsMessage response) {
if (analysisRecord != null) {
if (requestMsg.getShowPlan() != ShowPlan.OFF) {
if (processor != null) {
PlanNode node = processor.getProcessorPlan().getDescriptionProperties();
node.addProperty(AnalysisRecord.PROP_DATA_BYTES_SENT, String.valueOf(dataBytes.get()));
if (planningEnd != 0) {
node.addProperty(AnalysisRecord.PROP_PLANNING_TIME, String.valueOf(planningEnd - planningStart));
}
response.setPlanDescription(node);
}
if (analysisRecord.getAnnotations() != null && !analysisRecord.getAnnotations().isEmpty()) {
response.setAnnotations(analysisRecord.getAnnotations());
analysisRecord.getAnnotations().clear();
}
}
if (requestMsg.getShowPlan() == ShowPlan.DEBUG) {
response.setDebugLog(analysisRecord.getDebugLog());
analysisRecord.stopDebugLog();
}
}
}
use of org.teiid.client.plan.PlanNode in project teiid by teiid.
the class DQPCore method logMMCommand.
void logMMCommand(RequestWorkItem workItem, Event status, Long rowCount, Long cpuTime) {
if ((status != Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) || (status == Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE))) {
return;
}
RequestMessage msg = workItem.requestMsg;
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID rID = workItem.requestID;
String txnID = null;
TransactionContext tc = workItem.getTransactionContext();
if (tc != null && tc.getTransactionType() != Scope.NONE) {
txnID = tc.getTransactionId();
}
String appName = workContext.getAppName();
// Log to request log
CommandLogMessage message = null;
if (status == Event.NEW) {
message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), appName, workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), msg.getCommandString(), cpuTime);
} else {
QueryProcessor qp = workItem.getProcessor();
PlanNode plan = null;
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE) && qp != null) {
plan = qp.getProcessorPlan().getDescriptionProperties();
}
message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, status, plan);
}
LogManager.log(status == Event.PLAN ? MessageLevel.TRACE : MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
}
use of org.teiid.client.plan.PlanNode in project teiid by teiid.
the class TestGroupingNode method testDescriptionProperties.
@Test
public void testDescriptionProperties() {
GroupingNode node = getExampleGroupingNode();
SymbolMap outputMapping = new SymbolMap();
outputMapping.addMapping(new ElementSymbol("agg0"), new AggregateSymbol("count", false, null));
node.setOutputMapping(outputMapping);
PlanNode pn = node.getDescriptionProperties();
assertTrue(pn.toString().contains("agg0=count(*)"));
}
use of org.teiid.client.plan.PlanNode in project teiid by teiid.
the class StatementImpl method executeShow.
ResultsFuture<Boolean> executeShow(Matcher match) throws SQLException {
String show = match.group(1);
show = unescapeId(show);
if (show.equalsIgnoreCase("PLAN")) {
// $NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
PlanNode plan = driverConnection.getCurrentPlanDescription();
String connDebugLog = driverConnection.getDebugLog();
if (plan != null || connDebugLog != null) {
ArrayList<Object> row = new ArrayList<Object>(3);
if (plan != null) {
row.add(DataTypeTransformer.getClob(plan.toString()));
row.add(new SQLXMLImpl(plan.toXml()));
} else {
row.add(null);
row.add(null);
}
row.add(DataTypeTransformer.getClob(connDebugLog));
records.add(row);
}
createResultSet(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
records, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { "PLAN_TEXT", "PLAN_XML", "DEBUG_LOG" }, new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.XML, DataTypeManager.DefaultDataTypes.CLOB });
return booleanFuture(true);
}
if (show.equalsIgnoreCase("ANNOTATIONS")) {
// $NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
Collection<Annotation> annos = driverConnection.getAnnotations();
for (Annotation annotation : annos) {
ArrayList<Object> row = new ArrayList<Object>(4);
row.add(annotation.getCategory());
row.add(annotation.getPriority().name());
row.add(annotation.getAnnotation());
row.add(annotation.getResolution());
records.add(row);
}
createResultSet(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
records, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "CATEGORY", "PRIORITY", "ANNOTATION", "RESOLUTION" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
return booleanFuture(true);
}
if (show.equalsIgnoreCase("ALL")) {
// $NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
for (String key : driverConnection.getExecutionProperties().stringPropertyNames()) {
ArrayList<Object> row = new ArrayList<Object>(4);
row.add(key);
row.add(driverConnection.getExecutionProperties().get(key));
records.add(row);
}
createResultSet(// $NON-NLS-1$ //$NON-NLS-2$
records, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "NAME", "VALUE" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
return booleanFuture(true);
}
if (show.equalsIgnoreCase("transaction isolation level")) {
// $NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
ArrayList<Object> row = new ArrayList<Object>(1);
switch(driverConnection.getTransactionIsolation()) {
case Connection.TRANSACTION_READ_COMMITTED:
// $NON-NLS-1$
row.add("READ COMMITTED");
break;
case Connection.TRANSACTION_READ_UNCOMMITTED:
// $NON-NLS-1$
row.add("READ UNCOMMITTED");
break;
case Connection.TRANSACTION_REPEATABLE_READ:
// $NON-NLS-1$
row.add("REPEATABLE READ");
break;
case Connection.TRANSACTION_SERIALIZABLE:
// $NON-NLS-1$
row.add("SERIALIZABLE");
break;
default:
// $NON-NLS-1$
row.add("UNKNOWN");
}
records.add(row);
createResultSet(// $NON-NLS-1$
records, // $NON-NLS-1$
new String[] { "TRANSACTION ISOLATION" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
return booleanFuture(true);
}
List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getExecutionProperty(show)));
createResultSet(records, new String[] { show }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
return booleanFuture(true);
}
use of org.teiid.client.plan.PlanNode in project teiid by teiid.
the class IfInstruction method getDescriptionProperties.
public PlanNode getDescriptionProperties() {
// $NON-NLS-1$
PlanNode props = new PlanNode("IF");
props.addProperty(PROP_CRITERIA, this.condition.toString());
props.addProperty(PROP_THEN, this.ifProgram.getDescriptionProperties());
if (elseProgram != null) {
props.addProperty(PROP_ELSE, this.elseProgram.getDescriptionProperties());
}
return props;
}
Aggregations