📄 ufl.jj
字号:
return (Expression) value; } throw new RuntimeException("Object: " + name + " has element " + key + " of the wrong type, expected expression"); } /** * Method fixOpGraphLinks * * @param theGraph */ public void fixOpGraphLinks(OperatorGraph theGraph) { fixOpGraphLinks(theGraph, true); fixOpGraphLinks(theGraph, false); } /** * Method fixOpGraphLinks * * @param theGraph * @param doChildren */ public void fixOpGraphLinks(OperatorGraph theGraph, boolean doChildren) { ArrayList theLinks = doChildren ? children : parents; for (int i = 0; i < theGraph.numOperators(); i++) { OperatorGraphEntry entry = theGraph.getOperator(i); ArrayList opLinks = (ArrayList) theLinks.get(i); if (opLinks != null) { for (int j = 0; j < opLinks.size(); j++) { String link = (String) opLinks.get(j); if (link != null) { Object lookupVal = opLookup.get(link); if (lookupVal != null) { int opNum = ((Integer) lookupVal).intValue(); if (doChildren) { entry.setChild(j, opNum); } else { entry.setParent(j, opNum); } } else { throw new RuntimeException( "Invalid child/parent specification on operator " + i + " and source " + link); } } } } } } /** * Method convertAggOperators * * @param raw * @return */ ArrayList convertAggOperators(ArrayList raw) { ArrayList converted = new ArrayList(); for (int i = 0; i < raw.size(); i++) { String curItem = (String) raw.get(i); if (curItem.compareToIgnoreCase("COUNT") == 0) { converted.add(new Integer(GroupBy.AGG_COUNT)); } if (curItem.compareToIgnoreCase("SUM") == 0) { converted.add(new Integer(GroupBy.AGG_SUM)); } if (curItem.compareToIgnoreCase("MAX") == 0) { converted.add(new Integer(GroupBy.AGG_MAX)); } if (curItem.compareToIgnoreCase("MIN") == 0) { converted.add(new Integer(GroupBy.AGG_MIN)); } if (curItem.compareToIgnoreCase("AVG") == 0) { converted.add(new Integer(GroupBy.AGG_AVG)); } if (curItem.compareToIgnoreCase("CONCAT") == 0) { converted.add(new Integer(GroupBy.AGG_CONCAT)); } } return converted; }}PARSER_END(UFL)<DEFAULT> SKIP :{ < " " | "\t" | "\n" | "\r" >}<DEFAULT> TOKEN :{ <OPGRAPHOBJ: "%optree" | "%opgraph" >| <OPOBJ: "%operator" >| <PREDOBJ: "%predicate" >| <END: "#" >| <OBJNAMESTART: "(" >| <OBJNAMEEND: ")" >| <OBJSTART: "{" >| <OBJEND: "}" >| <KEYARRAYSTART: "[" >| <KEYARRAYEND: "]" >| <KEYVALDELIM: "=" >| <CASTSEP: "::" >| <PARAMSEP: "," >| <FIELDREF: "$" >}<LITERALS> TOKEN:{ <LITERALTEXT: ( ~["\"", "\\"] )+ >| <LITERALESCAPE: "\\" > : LITERALESCAPES| <LITERALEND: ~["\\"] > : DEFAULT}<LITERALESCAPES> TOKEN:{ <ESCAPEUNICODE: "u" ["0"-"9","A"-"F","a"-"f"] ["0"-"9","A"-"F","a"-"f"] ["0"-"9","A"-"F","a"-"f"] ["0"-"9","A"-"F","a"-"f"] ("$")? > : LITERALS| <ESCAPEQID: "qi" ("$")? > : LITERALS| <ESCAPEQTAG: "qt" ("$")? > : LITERALS| <ESCAPEQADDR: "qa" ("$")? > : LITERALS| <ESCAPESLASH: "\\" ("$")? > : LITERALS| <ESCAPEQUOTE: "\"$" > : LITERALS| <ESCAPENEWLINE: "n" ("$")? > : LITERALS}<*> TOKEN :{ <BASICTEXTCHARS: ( ["a"-"z", "A"-"Z"] | ["0"-"9", "."] | ["*", "-", "_", "/"] )+ >| <LITERALSTART: "\"" > : LITERALS| <UNKNOWN: ~[" "] >}void doInput() :{ QueryTag queryTag;}{ { queryTag = new QueryTag(sourceSocketAddress, sourceID, (byte) 0); } { queryNS = queryTag.getQueryNS(); } ( { graphNum++; } doOpGraphObj() )+ (<END>)?}void doOpGraphObj() :{ HashMap settings = new HashMap(); Operator curOp; OperatorGraph curGraph = null; int opNum = 0; QueryTag queryTag; String graphName;}{ { opLookup = new HashMap(); } { children = new ArrayList(); } { parents = new ArrayList(); } <OPGRAPHOBJ> <OBJNAMESTART> graphName=doLiteralTextString() <OBJNAMEEND> <OBJSTART> (doKeyValEntry(settings))* { queryTag = new QueryTag(sourceSocketAddress, sourceID, (byte) graphNum); curGraph = new OperatorGraph(getValue(settings, "ns", null), getValue(settings, "rid", null), Long.parseLong(getValue(settings, "duration", graphName)), queryTag); } ( curOp = doOperator(opNum++) { curGraph.addOperator(curOp); } )* <OBJEND> { fixOpGraphLinks(curGraph); } { if (Output.debuggingEnabled) {logger.debug(new LogMessage(new Object[] {"Processed OpGraph:\n", curGraph})); } } { thePlan.addOpGraph(curGraph); }}Operator doOperator(int opNum) :{ String name; HashMap settings = new HashMap(); Object predicate = null; Operator theOperator = null;}{ <OPOBJ> <OBJNAMESTART> name=doTextString() <OBJNAMEEND> <OBJSTART> (doKeyValEntry(settings) | predicate=doPredicate())* <OBJEND> { String type = getValue(settings, "type", name); } { String implementation = getValue(settings, "implementation", name); int executorNum = 0; if (implementation.equalsIgnoreCase("DYNAMIC")) executorNum = Operator.DYNAMIC_LOADER; if (type.equalsIgnoreCase("BLOOM")) { if (implementation.equalsIgnoreCase("BLOOMCOLLECTOR")) executorNum = Operator.SPEC_BLOOMCOLLECTOR; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); theOperator = new Bloom(executorNum, getValue(settings, "sendns", name), getValue(settings, "sendrid", null), getValue(settings, "deliverns", name), getValue(settings, "filtername", name)); } if (type.equalsIgnoreCase("CACHE")) { if (implementation.equalsIgnoreCase("MEMCACHE")) executorNum = Operator.SPEC_MEMCACHE; if (implementation.equalsIgnoreCase("MEMUPDATECACHE")) executorNum = Operator.SPEC_MEMUPDATECACHE; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); theOperator = new Cache(executorNum); } if (type.equalsIgnoreCase("DUPELIM")) { if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.DUPELIM_BASIC; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); theOperator = new DupElim(executorNum); } if (type.equalsIgnoreCase("EDDY")) { if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.EDDY_BASIC; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); HashMap sourceMap = (HashMap) settings.remove("sourcemap"); if (sourceMap == null) getValue(settings, "sourcemap", name); HashMap doneMap = (HashMap) settings.remove("donemap"); if (doneMap == null) getValue(settings, "donemap", name); String policy = getValue(settings, "policy", name); int routingPolicy = 0; if (policy.equals("BASIC")) routingPolicy = Eddy.BASIC_ROUTING; if (policy.equals("RANDOM")) routingPolicy = Eddy.RANDOM_ROUTING; if (policy.equals("QL")) routingPolicy = Eddy.QL_ROUTING; if (routingPolicy == 0) throw new RuntimeException("Operator " + name + " has invalid policy specification " + policy); theOperator = new Eddy(executorNum, sourceMap, doneMap, routingPolicy, Boolean.valueOf(getValue(settings, "pullset", name)).booleanValue(), Boolean.valueOf(getValue(settings, "pullstream", name)).booleanValue()); } if (type.equalsIgnoreCase("FLOWCONTROL")) { if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.FLOWCONTROL_BASIC; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); theOperator = new FlowControl(executorNum, Boolean.valueOf(getValue(settings, "pullset", name)).booleanValue(), Boolean.valueOf(getValue(settings, "pullstream", name)).booleanValue()); } if (type.equalsIgnoreCase("GET")) { if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.GET_BASIC; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); theOperator = new Get(executorNum, getValue(settings, "getns", name)); } if (type.equalsIgnoreCase("GROUPBY")) { if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.GROUPBY_BASIC; if (implementation.equalsIgnoreCase("DUAL")) executorNum = Operator.GROUPBY_DUAL; if (implementation.equalsIgnoreCase("LEARNED")) executorNum = Operator.GROUPBY_LEARNED; if (implementation.equalsIgnoreCase("TREE")) executorNum = Operator.GROUPBY_TREE; if (executorNum == 0) throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation); ArrayList groupByExpressions = (ArrayList) settings.remove("groupbyexpressions"); if (groupByExpressions == null) groupByExpressions = new ArrayList(); ArrayList aggregateExpressions = (ArrayList) settings.remove("aggregateexpressions"); if (aggregateExpressions == null) aggregateExpressions = new ArrayList(); ArrayList aggregateOps = (ArrayList) settings.remove("aggregateops"); if (aggregateOps == null) aggregateOps = new ArrayList(); theOperator = new GroupBy(executorNum, groupByExpressions, aggregateExpressions, convertAggOperators(aggregateOps), getValue(settings, "sendns", name), Boolean.valueOf(getValue(settings, "last", name)).booleanValue()); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -