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

📄 ufl.jj

📁 High performance DB query
💻 JJ
📖 第 1 页 / 共 3 页
字号:
        if (type.equalsIgnoreCase("JOIN")) {            if (implementation.equalsIgnoreCase("SYMMETRICHASH")) executorNum = Operator.JOIN_SYMMETRICHASH;            if (implementation.equalsIgnoreCase("INDEX")) executorNum = Operator.JOIN_INDEX;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Join(executorNum, (SimplePredicateAtomic) predicate, getValue(settings, "resulttable", name));        }        if (type.equalsIgnoreCase("NULL")) {            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Null(executorNum);        }        if (type.equalsIgnoreCase("PROJECTION")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.PROJECT_BASIC;            if (implementation.equalsIgnoreCase("NEW")) executorNum = Operator.PROJECT_NEW;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            ArrayList expressionList = (ArrayList) settings.remove("expressionlist");            if (expressionList == null)                throw new RuntimeException("Operator " + name + " must have an expressionList");            ArrayList renameList = (ArrayList) settings.remove("renamelist");            theOperator = new Projection(executorNum, expressionList, renameList, getValue(settings, "tablename", name));        }        if (type.equalsIgnoreCase("PUT")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.PUT_BASIC;            if (implementation.equalsIgnoreCase("DHT")) executorNum = Operator.PUT_DHT;            if (implementation.equalsIgnoreCase("EDDY")) executorNum = Operator.PUT_EDDY;            if (implementation.equalsIgnoreCase("BLOOM")) executorNum = Operator.PUT_BLOOM;            if (implementation.equalsIgnoreCase("DHTMESSAGE")) executorNum = Operator.PUT_DHTMESSAGE;            if (implementation.equalsIgnoreCase("IP")) executorNum = Operator.PUT_IP;            if (implementation.equalsIgnoreCase("TREE")) executorNum = Operator.PUT_TREE;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            ArrayList expressionList = (ArrayList) settings.remove("expressionlist");                        if (expressionList == null)                throw new RuntimeException("Operator " + name + " must have an expressionList");            theOperator = new Put(executorNum, getValue(settings, "rehashns", name), expressionList);        }        if (type.equalsIgnoreCase("QUEUE")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.QUEUE_BASIC;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Queue(executorNum);        }        if (type.equalsIgnoreCase("RESULT")) {            if (implementation.equalsIgnoreCase("NETSEND")) executorNum = Operator.RESULT_NETSEND;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            InetSocketAddress destination = null;            String ip = getValue(settings, "ip", null);            String port = getValue(settings, "port", null);            if ((ip != null) && (port != null))                destination = new InetSocketAddress(ip, Integer.parseInt(port));            theOperator = new Result(executorNum, destination, Integer.parseInt(getValue(settings, "batching", name)), Integer.parseInt(getValue(settings, "queryid", name)));        }        if (type.equalsIgnoreCase("SCAN")) {            if (implementation.equalsIgnoreCase("DHT")) executorNum = Operator.SCAN_DHT;            if (implementation.equalsIgnoreCase("JDBC")) executorNum = Operator.SCAN_JDBC;            if (implementation.equalsIgnoreCase("GANGLIA")) executorNum = Operator.SCAN_GANGLIA;            if (implementation.equalsIgnoreCase("DHTMESSAGE")) executorNum = Operator.SCAN_DHTMESSAGE;            if (implementation.equalsIgnoreCase("PLSENSOR")) executorNum = Operator.SCAN_CSV;            if (implementation.equalsIgnoreCase("CSV")) executorNum = Operator.SCAN_CSV;            if (implementation.equalsIgnoreCase("IP")) executorNum = Operator.SCAN_IP;            if (implementation.equalsIgnoreCase("TREE")) executorNum = Operator.SCAN_TREE;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Scan(executorNum, getValue(settings, "source", name));        }        if (type.equalsIgnoreCase("SELECTION")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.SELECT_BASIC;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Selection(executorNum, (SimplePredicate) predicate);        }        if (type.equalsIgnoreCase("TEE")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.TEE_BASIC;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Tee(executorNum);        }        if (type.equalsIgnoreCase("UNION")) {            if (implementation.equalsIgnoreCase("BASIC")) executorNum = Operator.UNION_BASIC;            if (executorNum == 0)                throw new RuntimeException("Operator " + name + " has invalid implementation specification " + implementation);            theOperator = new Union(executorNum);            }        if (theOperator == null)            throw new RuntimeException("Operator " + name + " has invalid type " + type);        HashMap queryOptions = (HashMap) settings.remove("options");        if (queryOptions != null)            theOperator.setQueryOptions(queryOptions);            opLookup.put(name, new Integer(opNum));            children.add(settings.remove("sources"));            parents.add(settings.remove("parents"));        return theOperator;    }}Object doPredicate() :{    String name;    Object subPredicate = null;    ArrayList subPredicates = new ArrayList();    HashMap settings = new HashMap();}{    <PREDOBJ> <OBJNAMESTART> name=doTextString() <OBJNAMEEND> <OBJSTART> (doKeyValEntry(settings) |    subPredicate = doPredicate()    { subPredicates.add(subPredicate); }    )* <OBJEND>    {        String type = getValue(settings, "type", name);        if (type.equalsIgnoreCase("AND")) {            ConjunctivePredicateSet theSet = new ConjunctivePredicateSet();            for (int i=0; i<subPredicates.size(); i++) {                 Object subEntry = subPredicates.get(i);                 if (!(subEntry instanceof SimplePredicate))                     throw new RuntimeException("Embedded predicate object (" + name + ") is not of correct type (AND/OR/ATOMIC)");                 theSet.addPredicate((SimplePredicate) subEntry);            }            return theSet;        }        if (type.equalsIgnoreCase("OR")) {            DisjunctivePredicateSet theSet = new DisjunctivePredicateSet();            for (int i=0; i<subPredicates.size(); i++) {                 Object subEntry = subPredicates.get(i);                 if (!(subEntry instanceof SimplePredicate))                     throw new RuntimeException("Embedded predicate object (" + name + ") is not of correct type (AND/OR/ATOMIC)");                 theSet.addPredicate((SimplePredicate) subEntry);            }            return theSet;        }        if (type.equalsIgnoreCase("ATOMIC")) {            Expression leftExpression = getExpressionValue(settings, "leftexpression", null);            Expression rightExpression = getExpressionValue(settings, "rightexpression", null);            return new SimplePredicateAtomic(leftExpression, rightExpression, getPredicateOp(getValue(settings, "op", name)));        }        throw new RuntimeException("Unknown predicate object (" + name + ") type (" + type + ")");    }}void doKeyValEntry(HashMap entrySet) :{    Token isArr = null;    String key, subscript = null;    Object value;}{    key=doTextString() (isArr=<KEYARRAYSTART> (subscript=doTextString())? <KEYARRAYEND>)? <KEYVALDELIM> (LOOKAHEAD(doExpression())value=doExpression() | value=doLiteralTextString())    {        key = key.toLowerCase();        if (isArr == null)            entrySet.put(key, value);        else {            Object values = entrySet.get(key);            int pos;            try {                pos = Integer.parseInt(subscript);            } catch(NumberFormatException e) {                pos = -1;            }            if ((pos != -1) || (subscript == null)) {                if (values == null) {                    values = new ArrayList();                    entrySet.put(key, values);                }                if (!(values instanceof ArrayList)) {                    ((HashMap) values).put(subscript, value);                } else {                    ArrayList valueArray = (ArrayList) values;                    if (subscript == null) {                        valueArray.add(value);                    } else {                        valueArray.ensureCapacity(pos+1);                        while (valueArray.size() < (pos+1))                            valueArray.add(null);                        valueArray.set(pos, value);                    }                }            } else {                if (values == null) {                    values = new HashMap();                    entrySet.put(key, values);                }                if (!(values instanceof HashMap))                    throw new RuntimeException("Key already used in non-hashmap manner: " + key);                ((HashMap) values).put(subscript, value);            }        }    }}Expression doExpression():{    String name, type;    Expression subExpression;    ArrayList parameters = new ArrayList();}{    (LOOKAHEAD(doLiteralTextString() <OBJNAMESTART>) ( name=doLiteralTextString() <OBJNAMESTART>    (subExpression = doExpression()    { parameters.add(subExpression); }    (<PARAMSEP> subExpression = doExpression()    { parameters.add(subExpression); }    )*)? <OBJNAMEEND>    { return new ExpressionFunction(name, parameters); }    ) | (    name=doLiteralTextString() <CASTSEP> type=doTextString()    { return new ExpressionConstant(makeTypedObject(type, name)); }    ) | (    <FIELDREF> name=doLiteralTextString()    { return new ExpressionField(name); }    ))}String doTextString():{    Token text;}{    text=<BASICTEXTCHARS>    { return text.image; }}String doLiteralTextString():{    Token text;    String curStr, escaped;    int curState;}{    (( text=<BASICTEXTCHARS>    { return text.image; }    ) | ( <LITERALSTART>    { curStr = new String(); }    (( text=<LITERALTEXT>    { curStr += text.image; }    ) | ( <LITERALESCAPE> escaped=doLiteralEscape()    { curStr += escaped; }    ))* <LITERALEND>    { return curStr; }    ))}String doLiteralEscape():{    Token token;}{    (token=<ESCAPEUNICODE>    { int x = Integer.parseInt(token.image.substring(1,4),16); return new String(new Character((char) x).toString()); }    | <ESCAPEQID>    { return "" + sourceID; }    | <ESCAPEQTAG>    { return queryNS; }    | <ESCAPEQADDR>    { return sourceSocketAddress.getAddress().toString().substring(1); }        | <ESCAPESLASH>    { return "\\"; }    | <ESCAPEQUOTE>    { return "\""; }    | <ESCAPENEWLINE>    { return "\n"; }    )}

⌨️ 快捷键说明

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