Examples of QueryCompiler


Examples of com.salesforce.phoenix.compile.QueryCompiler

            return lastQueryPlan = connection.getQueryServices().getOptimizer().optimize(this, PhoenixStatement.this);
        }
       
        @Override
        public StatementPlan compilePlan() throws SQLException {
            return new QueryCompiler(PhoenixStatement.this).compile(this);
        }
View Full Code Here

Examples of com.salesforce.phoenix.compile.QueryCompiler

       
        @Override
        public ResultSetMetaData getResultSetMetaData() throws SQLException {
            if (resultSetMetaData == null) {
                // Just compile top level query without optimizing to get ResultSetMetaData
                QueryPlan plan = new QueryCompiler(PhoenixStatement.this).compile(this);
                resultSetMetaData = new PhoenixResultSetMetaData(connection, plan.getProjector());
            }
            return resultSetMetaData;
        }
View Full Code Here

Examples of com.salesforce.phoenix.compile.QueryCompiler

    public QueryPlan optimize(SelectStatement select, PhoenixStatement statement) throws SQLException {
        return optimize(select, statement, Collections.<PColumn>emptyList(), null);
    }

    public QueryPlan optimize(SelectStatement select, PhoenixStatement statement, List<? extends PDatum> targetColumns, ParallelIteratorFactory parallelIteratorFactory) throws SQLException {
        QueryCompiler compiler = new QueryCompiler(statement, targetColumns, parallelIteratorFactory);
        QueryPlan dataPlan = compiler.compile(select);
        if (!useIndexes || select.getFrom().size() > 1) {
            return dataPlan;
        }
        // Get the statement as it's been normalized now
        // TODO: the recompile for the index tables could skip the normalize step
View Full Code Here

Examples of com.salesforce.phoenix.compile.QueryCompiler

        String tableName = '"' + index.getTableName().getString() + '"';
        List<? extends TableNode> tables = Collections.singletonList(FACTORY.namedTable(alias, FACTORY.table(schemaName, tableName)));
        try {
            SelectStatement indexSelect = FACTORY.select(select, tables);           
            QueryCompiler compiler = new QueryCompiler(statement, targetColumns, parallelIteratorFactory);
            QueryPlan plan = compiler.compile(indexSelect);
            // Checking the index status and number of columns handles the wildcard cases correctly
            // We can't check the status earlier, because the index table may be out-of-date.
            if (plan.getTableRef().getTable().getIndexState() == PIndexState.ACTIVE && plan.getProjector().getColumnCount() == nColumns) {
                plans.add(plan);
                return true;
View Full Code Here

Examples of com.saxonica.codegen.QueryCompiler

                if (compile) {
                    if ("parse-error".equals(testCase.getAttributeValue(scenarioAtt))) {
                        continue;
                    }
                    QueryCompiler qc = new QueryCompiler(saConfig);
                    qc.setBaseURI(new File(absQueryName).toURI().toString());
                    String groupName = testCase.getParent().getAttributeValue(nameAtt);
                    groupName = lowercase(groupName);
                    if (groupName.equals(prevGroup)) {
                        groupsize++;
                        int tome = groupsize / 500;
                        if (tome != 0) {
                            groupName += tome;
                        }
                    } else {
                        groupsize = 0;
                        prevGroup = groupName;
                    }
                    queryName = lowercase(queryName);
                    qc.setClassName(makeClassName(groupName, queryName));
                    File dir = new File(saxonDir + "/java/");
                    dir.mkdir();
                    qc.setOutputDirectory(dir);
                    //qc.setClassPath(classPath);

                    try {

                        qc.compileQueryToJava(new FileInputStream(absQueryName), "utf8");
                        log.println("Java source code written "/* + qc.getJavaFile()*/);
                        String finaldir = dir + "/" + groupName;
                        if (!directories.contains(finaldir)) {
                            compileScript.write("%JAVA%\\bin\\javac -classpath %CLASSPATH% " + finaldir + "/*.java\n");
                            directories.add(finaldir);
                        }
                    } catch (XPathException err) {
                        log.println("Query compilation failed");
                        continue;
                    } catch (FileNotFoundException err) {
                        log.println("Query file not found");
                    } catch (Exception err2) {
                        err2.printStackTrace();
                        continue;
                    }
                    continue;


                } else {
                    if (runCompiled) {
                        if ("parse-error".equals(testCase.getAttributeValue(scenarioAtt))) {
                            continue;
                        }
                        QueryCompiler qc = new QueryCompiler(saConfig);
                        qc.setBaseURI(new File(absQueryName).toURI().toString());
                        String groupName = testCase.getParent().getAttributeValue(nameAtt);
                        groupName = lowercase(groupName);

                        if (groupName.equals(prevGroup)) {
                            groupsize++;
                            int tome = groupsize / 500;
                            if (tome != 0) {
                                groupName += tome;
                            }
                        } else {
                            groupsize = 0;
                            prevGroup = groupName;
                        }
                        queryName = lowercase(queryName);
                        qc.setClassName(makeClassName(groupName, queryName));
                        File dir = new File(saxonDir + "/java/");
                        dir.mkdir();
                        qc.setOutputDirectory(dir);

                        DynamicQueryContext dqc = new DynamicQueryContext(saConfig);
                        dqc.setParameterValue("zlsJJ", StringValue.EMPTY_STRING);
                        NodeInfo contextItemElement = getChildElement(testCase, contextItemNT);
                        if (contextItemElement != null) {
                            DocumentInfo contextNode = loadDocument(contextItemElement.getStringValue());
                            dqc.setContextItem(contextNode);
                        }

                        processInputDocuments(testCase, inputFileNT, variableAtt, dqc);

                        setQueryParameters(catalog, testCase, dqc, inputUriNT, variableAtt, collectionNT, idAtt);

                        NodeInfo defaultCollection = getChildElement(testCase, defaultCollectionNT);
                        if (defaultCollection != null) {
                            String docName = defaultCollection.getStringValue();
                            NodeInfo collectionElement = getCollectionElement(catalog, docName, collectionNT, idAtt);
                            CollectionURIResolver r =
                                            new XQTSCollectionURIResolver(catalog, collectionElement, true);
                            saConfig.setCollectionURIResolver(r);
                        }

                        processInputQueries(testCase, inputQueryNT, variableAtt, nameAtt, filePath, dqc);

                        String outputDir = saxonDir + "/results/" + filePath;
                        new File(outputDir).mkdirs();
                        outputFile = outputDir + "/" + testName + ".out";
                        File outputFileF = new File(outputFile);
                        outputFileF.createNewFile();
                        StreamResult result = new StreamResult(outputFileF);
                        try {
                            qc.runQuery(dqc, result, outputProps);
                        } catch (XPathException err) {
                            if (!err.hasBeenReported()) {
                                log.println(err.getMessage());
                            }
                            processError(err, testCase, testName, filePath + queryName + ".xq", expectedErrorNT, specVersionAtt);
View Full Code Here

Examples of org.apache.phoenix.compile.QueryCompiler

    public QueryPlan optimize(PhoenixStatement statement, SelectStatement select) throws SQLException {
        return optimize(statement, select, FromCompiler.getResolverForQuery(select, statement.getConnection()), Collections.<PColumn>emptyList(), null);
    }

    public QueryPlan optimize(PhoenixStatement statement, SelectStatement select, ColumnResolver resolver, List<? extends PDatum> targetColumns, ParallelIteratorFactory parallelIteratorFactory) throws SQLException {
        QueryCompiler compiler = new QueryCompiler(statement, select, resolver, targetColumns, parallelIteratorFactory, new SequenceManager(statement));
        QueryPlan dataPlan = compiler.compile();
        return optimize(dataPlan, statement, targetColumns, parallelIteratorFactory);
    }
View Full Code Here

Examples of org.apache.phoenix.compile.QueryCompiler

        try {
            SelectStatement indexSelect = FACTORY.select(select, tables);
            ColumnResolver resolver = FromCompiler.getResolverForQuery(indexSelect, statement.getConnection());
            // Check index state of now potentially updated index table to make sure it's active
            if (PIndexState.ACTIVE.equals(resolver.getTables().get(0).getTable().getIndexState())) {
                QueryCompiler compiler = new QueryCompiler(statement, indexSelect, resolver, targetColumns, parallelIteratorFactory, dataPlan.getContext().getSequenceManager());
                QueryPlan plan = compiler.compile();
                // Checking number of columns handles the wildcard cases correctly, as in that case the index
                // must contain all columns from the data table to be able to be used.
                if (plan.getTableRef().getTable().getIndexState() == PIndexState.ACTIVE && plan.getProjector().getColumnCount() == nColumns) {
                    return plan;
                }
View Full Code Here

Examples of org.apache.phoenix.compile.QueryCompiler

        @Override
        public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException {
            SelectStatement select = SubselectRewriter.flatten(this, stmt.getConnection());
            ColumnResolver resolver = FromCompiler.getResolverForQuery(select, stmt.getConnection());
            select = StatementNormalizer.normalize(select, resolver);
            QueryPlan plan = new QueryCompiler(stmt, select, resolver).compile();
            plan.getContext().getSequenceManager().validateSequences(seqAction);
            return plan;
        }
View Full Code Here

Examples of org.apache.phoenix.compile.QueryCompiler

            return lastQueryPlan = connection.getQueryServices().getOptimizer().optimize(this, PhoenixStatement.this);
        }
       
        @Override
        public StatementPlan compilePlan() throws SQLException {
            return new QueryCompiler(PhoenixStatement.this).compile(this);
        }
View Full Code Here

Examples of org.apache.phoenix.compile.QueryCompiler

       
        @Override
        public ResultSetMetaData getResultSetMetaData() throws SQLException {
            if (resultSetMetaData == null) {
                // Just compile top level query without optimizing to get ResultSetMetaData
                QueryPlan plan = new QueryCompiler(PhoenixStatement.this).compile(this);
                resultSetMetaData = new PhoenixResultSetMetaData(connection, plan.getProjector());
            }
            return resultSetMetaData;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.