⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ufl.java

📁 High performance DB query
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* Generated By:JavaCC: Do not edit this line. UFL.java *//* * @(#)$Id: UFL.java,v 1.37 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.UFL;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.ExpressionConstant;import pier.expressions.ExpressionField;import pier.expressions.ExpressionFunction;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.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;public class UFL implements Parser, UFLConstants {    private static Logger logger = Logger.getLogger(UFL.class);    private static final double UFLVersion = 1.13;    private static final double minCompatibleUFLVersion = 1.08;    private PhysicalQueryPlan thePlan;    private InetSocketAddress sourceSocketAddress;    private int sourceID;    private String queryNS;    private HashMap opLookup;    private ArrayList children;    private ArrayList parents;    private int graphNum = 0;    /**     * 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[]{"UFL Version: ",                                String.valueOf(UFLVersion),                                " (Requested: ",                                String.valueOf(version),                                ")"}));        }        if (version < minCompatibleUFLVersion) {            if (Output.debuggingEnabled) {                logger.debug(new LogMessage(new Object[]{                           "Unable to parse old version"}));            }            return null;        }        if (version > UFLVersion) {            if (Output.debuggingEnabled) {                logger.debug(new LogMessage(new Object[]{                           "Unable to parse new version"}));            }            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"}));            }            throw new RuntimeException(e.getClass() + " " + e.getMessage());        }    }    /**     * Method getPredicateOp     *     * @param op     * @return     */    byte getPredicateOp(String op) {        if (op.equals("=") || op.equalsIgnoreCase("equals")) {            return 1;        }        if (op.equals("!=") || op.equals("<>")            || op.equalsIgnoreCase("notequals")) {            return -1;        }        if (op.equals(">") || op.equalsIgnoreCase("greaterthan")) {            return -3;        }        if (op.equals(">=") || op.equalsIgnoreCase("greaterthanequals")) {            return -2;        }        if (op.equals("<") || op.equalsIgnoreCase("lessthan")) {            return 2;        }        if (op.equals("<=") || op.equalsIgnoreCase("lessthanequals")) {            return 3;        }        throw new RuntimeException("Invalid predicate operator: " + op);    }    /**     * Method getValue     *     * @param entrySet     * @param key     * @param name     * @return     */    public String getValue(HashMap entrySet, String key, String name) {        Object value = entrySet.remove(key);        if (value == null) {            if (name != null) {                throw new RuntimeException("Object: " + name + " is missing key "                                           + key);            } else {                return null;            }        }        if (value instanceof String) {            return (String) value;        }        throw new RuntimeException("Object: " + name + " has element " + key                            + " of the wrong type, expected non-expression.");    }    /**     * Method getExpressionValue     *     * @param entrySet     * @param key     * @param name     * @return     */    public Expression getExpressionValue(HashMap entrySet, String key,        String name) {        Object value = entrySet.remove(key);        if (value == null) {            if (name != null) {                throw new RuntimeException("Object: " + name +                                            " is missing expression" + key);            } else {                return null;            }        }        if (value instanceof Expression) {            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;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -