public void testDebugLog() { AnalysisRecord rec = new AnalysisRecord(false, true); assertTrue(rec.recordDebug()); rec.println("a"); //$NON-NLS-1$ rec.println("b"); //$NON-NLS-1$ String log = rec.getDebugLog(); assertEquals("a\nb\n", log); //$NON-NLS-1$ }
public void recordDebugAnnotation(String annotation, Object modelID, String resolution, AnalysisRecord record, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { if (record != null && record.recordAnnotations()) { boolean current = this.modified; this.modified = true; record.addAnnotation(Annotation.RELATIONAL_PLANNER, annotation + (modelID != null?" " + (metadata!=null?metadata.getName(modelID):modelID):""), resolution + " " + this.nodeToString(false), Priority.LOW); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ this.modified = current; } }
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(); } } }
/** * Add an annotation. This can only be used if {@link #recordAnnotations} * returns true. * @param annotation Annotation to add */ public void addAnnotation(Annotation annotation) { this.annotations.add(annotation); if (this.recordDebug()) { this.println(annotation.toString()); } }
boolean debug = analysisRecord.recordDebug(); if(debug) { analysisRecord.println("\n============================================================================"); //$NON-NLS-1$ analysisRecord.println("USER COMMAND:\n" + command); //$NON-NLS-1$ } finally { CommandContext.popThreadLocalContext(); String debugLog = analysisRecord.getDebugLog(); if(debugLog != null && debugLog.length() > 0) { LogManager.log(requestMsg.getShowPlan()==ShowPlan.DEBUG?MessageLevel.INFO:MessageLevel.TRACE, LogConstants.CTX_QUERY_PLANNER, debugLog); if (analysisRecord.recordAnnotations() && analysisRecord.getAnnotations() != null && !analysisRecord.getAnnotations().isEmpty()) { LogManager.logDetail(LogConstants.CTX_QUERY_PLANNER, analysisRecord.getAnnotations());
@Test public void testMultiAccessPatternWithCriteria() throws Exception { String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); AnalysisRecord record = new AnalysisRecord(true, true); TestOptimizer.helpPlanCommand(TestOptimizer.helpGetCommand(sql, metadata), metadata, TestOptimizer.getGenericFinder(false), record, new String[] { "SELECT g_0.e2, g_0.e1 FROM pm5.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", //$NON-NLS-1$ "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$ "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ assertTrue(record.getAnnotations().toString().contains("access pattern not satisfied by join")); }
public void testAnnotations() { AnalysisRecord rec = new AnalysisRecord(true, false); assertTrue(rec.recordAnnotations()); Annotation ann1 = new Annotation("cat", "ann", "res", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Annotation ann2 = new Annotation("cat2", "ann2", "res2", Priority.HIGH); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ rec.addAnnotation(ann1); rec.addAnnotation(ann2); Collection<Annotation> annotations = rec.getAnnotations(); assertEquals(2, annotations.size()); assertTrue(annotations.contains(ann1)); assertTrue(annotations.contains(ann2)); }
streamingPath = StreamingUtils.getStreamingPath(xQueryString, namespaceMap); } catch (IllegalArgumentException e) { if (record.recordAnnotations()) { record.addAnnotation(XQUERY_PLANNING, "Invalid streaming path " + xQueryString + " "+ e.getMessage(), "Document streaming will not be used", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parentRoot = map.getContextDocumentRoot(); } catch (IllegalStateException e) { if (record.recordAnnotations()) { record.addAnnotation(XQUERY_PLANNING, "Multiple context items exist " + xQueryString, "Document projection will not be used", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ if (record.recordAnnotations()) { record.addAnnotation(XQUERY_PLANNING, "No context item reference was found in the XQuery " + xQueryString, "Document projection will not be used", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ if (columns != null && !columns.isEmpty()) { if (finalNodes.size() != 1) { if (record.recordAnnotations()) { record.addAnnotation(XQUERY_PLANNING, "multiple return items exist " + xQueryString, "Document projection will not be used", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ if (record.recordAnnotations()) { record.addAnnotation(XQUERY_PLANNING, "There are unknown dependencies (most likely a user defined function) in " + xQueryString, "Document projection will not be used", Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ if (record.recordAnnotations()) { StringBuilder sb = null; if (record.recordDebug()) { sb = new StringBuilder(); showArcs(sb, parentRoot, 0); record.addAnnotation(XQUERY_PLANNING, "Projection conditions met for " + xQueryString, "Document projection will be used" + (sb != null ? "\n" +sb.toString():""), Priority.MEDIUM); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public void helpTestValidJoin(PlanNode joinNode, PlanNode accessNode, boolean expectedValid) throws QueryMetadataException, TeiidComponentException { RuleChooseDependent rule = new RuleChooseDependent(); RuleChooseJoinStrategy.chooseJoinStrategy(joinNode, metadata); boolean isValid = rule.isValidJoin(joinNode, accessNode, AnalysisRecord.createNonRecordingRecord()); assertEquals("Valid join check is wrong ", expectedValid, isValid); //$NON-NLS-1$ }
private AnalysisRecord getAnalysisRecord() { if (this.analysisRecord == null) { this.analysisRecord = new AnalysisRecord(requestMsg.getShowPlan() != ShowPlan.OFF, requestMsg.getShowPlan() == ShowPlan.DEBUG); } return this.analysisRecord; }
public PlanNode getDescriptionProperties() { PlanNode props = super.getDescriptionProperties(); AnalysisRecord.addLanaguageObjects(props, PROP_CRITERIA, Arrays.asList(this.criteria)); return props; }
public PlanNode getDescriptionProperties() { PlanNode props = new PlanNode(this.getClass().getSimpleName()); props.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(getOutputElements())); return props; }
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG); } finally { if(DEBUG) { System.out.println(analysisRecord.getDebugLog());
public void addAnnotation(String category, String annotation, String resolution, Priority priority) { addAnnotation(new Annotation(category, annotation, resolution, priority)); }
private static void debugDocumentInfo(String msgTag, XMLPlannerEnvironment planEnv) { planEnv.analysisRecord.println("\n"+msgTag+":============================================================================"); //$NON-NLS-1$ //$NON-NLS-2$ planEnv.analysisRecord.println("MAPPING DOCUMENT:\n" + MappingNode.toStringNodeTree(planEnv.mappingDoc)); //$NON-NLS-1$ }
boolean debug = analysisRecord.recordDebug(); if(debug) { analysisRecord.println("\n============================================================================"); //$NON-NLS-1$ analysisRecord.println("USER COMMAND:\n" + command); //$NON-NLS-1$ } finally { CommandContext.popThreadLocalContext(); String debugLog = analysisRecord.getDebugLog(); if(debugLog != null && debugLog.length() > 0) { LogManager.log(requestMsg.getShowPlan()==ShowPlan.DEBUG?MessageLevel.INFO:MessageLevel.TRACE, LogConstants.CTX_QUERY_PLANNER, debugLog); if (analysisRecord.recordAnnotations() && analysisRecord.getAnnotations() != null && !analysisRecord.getAnnotations().isEmpty()) { LogManager.logDetail(LogConstants.CTX_QUERY_PLANNER, analysisRecord.getAnnotations());
/** * Add an annotation. This can only be used if {@link #recordAnnotations} * returns true. * @param annotation Annotation to add */ public void addAnnotation(Annotation annotation) { this.annotations.add(annotation); if (this.recordDebug()) { this.println(annotation.toString()); } }
@Test public void testPlanNodeAnnotation() throws Exception { PlanNode pn = new PlanNode(); TransformationMetadata metadata = RealMetadataFactory.example1Cached(); Object modelID = metadata.getMetadataStore().getSchema("pm1"); AnalysisRecord record = new AnalysisRecord(true, true); pn.recordDebugAnnotation("hello", modelID, "world", record, metadata); assertEquals("[LOW [Relational Planner] hello pm1 - world Unknown: 0(groups=[]]", record.getAnnotations().toString()); }
CreateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr) throws QueryParserException, QueryResolverException, TeiidComponentException, QueryMetadataException { QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(TriggerEvent.UPDATE, procedure); ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr); QueryResolver.resolveCommand(userCommand, metadata); return (CreateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, AnalysisRecord.createNonRecordingRecord()); }
private AnalysisRecord getAnalysisRecord() { if (this.analysisRecord == null) { this.analysisRecord = new AnalysisRecord(requestMsg.getShowPlan() != ShowPlan.OFF, requestMsg.getShowPlan() == ShowPlan.DEBUG); } return this.analysisRecord; }