📄 pierosl.java
字号:
/* Generated By:JavaCC: Do not edit this line. PierOSL.java *//* * @(#)$Id: PierOSL.java,v 1.41 2005/07/18 04:03:36 huebsch Exp $ * * Copyright (c) 2001-2003 Regents of the University of California. * All rights reserved. * * This file is distributed under the terms in the attached BERKELEY-LICENSE * file. If you do not find these files, copies can be found by writing to: * Computer Science Division, Database Group, Universite of California, * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License * * Copyright (c) 2003 Intel Corporation. All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find these files, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704. Attention: Intel License Inquiry. */package pier.parsers.PierOSL;import java.lang.reflect.Constructor;import java.net.InetSocketAddress;import java.util.ArrayList;import java.util.HashMap;import org.apache.log4j.Logger;import pier.expressions.Expression;import pier.expressions.ExpressionField;import pier.expressions.ExpressionFunction;import pier.expressions.ExpressionConstant;import pier.operators.Bloom;import pier.operators.Cache;import pier.operators.DupElim;import pier.operators.Eddy;import pier.operators.FlowControl;import pier.operators.Get;import pier.operators.GroupBy;import pier.operators.Join;import pier.operators.Null;import pier.operators.Operator;import pier.operators.Projection;import pier.operators.Put;import pier.operators.Queue;import pier.operators.Result;import pier.operators.Scan;import pier.operators.Selection;import pier.operators.Tee;import pier.operators.Union;import pier.parsers.ParseException;import pier.parsers.Parser;import pier.parsers.SimpleCharStream;import pier.parsers.Token;import pier.parsers.TokenMgrError;import pier.predicate.ConjunctivePredicateSet;import pier.predicate.DisjunctivePredicateSet;import pier.predicate.SimplePredicate;import pier.predicate.SimplePredicateAtomic;import pier.predicate.SimplePredicateSet;import pier.query.OperatorGraph;import pier.query.OperatorGraphEntry;import pier.query.QueryPlan;import pier.query.QueryTag;import pier.query.PhysicalQueryPlan;import services.Output;import util.logging.LogMessage;/** * Class PierOSL * */public class PierOSL implements Parser, PierOSLConstants { private static Logger logger = Logger.getLogger(PierOSL.class); private static final double OSLVersion = 1.19; private static final double minCompatibleOSLVersion = 1.14; private static final int ERROR_VERSION_OLD = 1; private static final int ERROR_VERSION_NEW = 2; private static final int ERROR_LITERAL_CREATION = 3; private PhysicalQueryPlan thePlan; private InetSocketAddress sourceSocketAddress; private int sourceID; private String queryNS; private int errorCode = 0; private int opGraphNum = 0; private int opNum; private int graphNum = 0; private OperatorGraph curGraph; private Operator curOp; private HashMap opLookup; private ArrayList children; private ArrayList parents; /** * Method parse * * @param language * @param version * @param sourceSocketAddress * @param sourceID * @return * @throws ParseException */ public QueryPlan parse( String language, double version, InetSocketAddress sourceSocketAddress, int sourceID) throws ParseException { if (Output.debuggingEnabled) { logger.debug(new LogMessage( new Object[]{"Pier OSL Version: ", String.valueOf(OSLVersion), " (Requested: ", String.valueOf(version), ")"})); } if (version < minCompatibleOSLVersion) { if (Output.debuggingEnabled) { logger.debug(new LogMessage(new Object[]{ "Unable to parse old version"})); } errorCode = ERROR_VERSION_OLD; return null; } if (version > OSLVersion) { if (Output.debuggingEnabled) { logger.debug(new LogMessage(new Object[]{ "Unable to parse new version"})); } errorCode = ERROR_VERSION_NEW; return null; } this.sourceSocketAddress = sourceSocketAddress; this.sourceID = sourceID; thePlan = new PhysicalQueryPlan(); doInput(); return thePlan; } /** * Method makeTypedObject * * @param type * @param value * @return */ Object makeTypedObject(String type, String value) { try { Class parameterTypes[] = new Class[1]; parameterTypes[0] = Class.forName("java.lang.String"); Class valueClass = Class.forName(type); Constructor valueConstructor = valueClass.getConstructor(parameterTypes); Object parameterValues[] = new Object[1]; parameterValues[0] = value; return valueConstructor.newInstance(parameterValues); } catch (Exception e) { if (Output.debuggingEnabled) { logger.debug(new LogMessage(new Object[]{ "Unable to create literal object"})); } errorCode = ERROR_LITERAL_CREATION; throw new RuntimeException(e.getClass() + " " + e.getMessage()); } } /** * 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); } } } } } } final public void doInput() throws ParseException { QueryTag queryTag; queryTag = new QueryTag(sourceSocketAddress, sourceID, (byte) 0); this.queryNS = queryTag.getQueryNS(); label_1: while (true) { graphNum++; doOpGraph(); switch (jj_nt.kind) { case OPGRAPHSTART: ; break; default: jj_la1[0] = jj_gen; break label_1; } } jj_consume_token(END); } final public void doOpGraph() throws ParseException { String optionalRID = null; String ns = null, rid = null, graphName, duration; QueryTag queryTag; opNum = 0; opLookup = new HashMap(); children = new ArrayList(); parents = new ArrayList(); jj_consume_token(OPGRAPHSTART); switch (jj_nt.kind) { case BASICTEXTCHARS: case LITERALSTART: ns = doLiteralTextString(); break; default: jj_la1[1] = jj_gen; ; } jj_consume_token(GRAPHSEP); switch (jj_nt.kind) { case BASICTEXTCHARS: case LITERALSTART: rid = doLiteralTextString(); break; default: jj_la1[2] = jj_gen; ; } jj_consume_token(GRAPHSEP); duration = doTextString(); jj_consume_token(GRAPHSEP); graphName = doLiteralTextString(); if (rid != null) optionalRID = rid; queryTag = new QueryTag(sourceSocketAddress, sourceID, (byte) graphNum); this.queryNS = queryTag.getQueryNS(); curGraph = new OperatorGraph(ns, optionalRID, Long.parseLong(duration), queryTag); label_2: while (true) { switch (jj_nt.kind) { case OPSTART: ; break; default: jj_la1[3] = jj_gen; break label_2; } jj_consume_token(OPSTART); doOperator(); } jj_consume_token(OPGRAPHEND); fixOpGraphLinks(curGraph); if (Output.debuggingEnabled) {logger.debug(new LogMessage(new Object[] {"Processed OpGraph: #", String.valueOf(opGraphNum), "\n", curGraph}));} thePlan.addOpGraph(curGraph); opGraphNum++; } final public void doOperator() throws ParseException { String opname; HashMap opOptions = null; ArrayList opChildren = null; ArrayList opParents = null; opname = doTextString(); jj_consume_token(OPSEP); token_source.SwitchTo(PierOSLConstants.OPNAME); switch (jj_nt.kind) { case BLOOM: jj_consume_token(BLOOM); jj_consume_token(OPSEP); doOpBloom(); break; case CACHE: jj_consume_token(CACHE); jj_consume_token(OPSEP); doOpCache(); break; case DUPELIM: jj_consume_token(DUPELIM); jj_consume_token(OPSEP); doOpDupElim(); break; case EDDY: jj_consume_token(EDDY); jj_consume_token(OPSEP); doOpEddy(); break; case FLOW: jj_consume_token(FLOW); jj_consume_token(OPSEP); doOpFlowControl(); break; case GET: jj_consume_token(GET); jj_consume_token(OPSEP); doOpGet(); break; case GROUPBY: jj_consume_token(GROUPBY); jj_consume_token(OPSEP); doOpGroupBy(); break; case JOIN: jj_consume_token(JOIN); jj_consume_token(OPSEP); doOpJoin(); break; case NULL: jj_consume_token(NULL); jj_consume_token(OPSEP); doOpNull(); break; case PROJECTION: jj_consume_token(PROJECTION); jj_consume_token(OPSEP); doOpProjection(); break; case PUT: jj_consume_token(PUT); jj_consume_token(OPSEP); doOpPut(); break; case QUEUE: jj_consume_token(QUEUE); jj_consume_token(OPSEP); doOpQueue(); break; case RESULT: jj_consume_token(RESULT); jj_consume_token(OPSEP); doOpResult(); break; case SCAN: jj_consume_token(SCAN); jj_consume_token(OPSEP); doOpScan(); break; case SELECTION: jj_consume_token(SELECTION); jj_consume_token(OPSEP); doOpSelection(); break; case TEE: jj_consume_token(TEE); jj_consume_token(OPSEP); doOpTee(); break; case UNION: jj_consume_token(UNION); jj_consume_token(OPSEP); doOpUnion(); break; default: jj_la1[4] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(OPSEP); opOptions = doHashMap();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -