Examples of VoltCompilerException


Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        int size = Integer.parseInt(sizeString);
        // check valid length if varchar
        if (type == VoltType.STRING) {
            if ((size == 0) || (size > VoltType.MAX_VALUE_LENGTH)) {
                String msg = "VARCHAR Column " + name + " in table " + table.getTypeName() + " has unsupported length " + sizeString;
                throw m_compiler.new VoltCompilerException(msg);
            }
        }

        Column column = table.getColumns().add(name);
        // need to set other column data here (default, nullable, etc)
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        String name = attrs.getNamedItem("name").getNodeValue();
        String typeName = attrs.getNamedItem("type").getNodeValue();
        ConstraintType type = ConstraintType.valueOf(typeName);
        if (type == null) {
            throw this.m_compiler.new VoltCompilerException("Invalid constraint type '" + typeName + "'");
        }

        // The constraint is backed by an index, therefore we need to create it
        // TODO: We need to be able to use indexes for foreign keys. I am purposely
        //       leaving those out right now because HSQLDB just makes too many of them.
        Constraint catalog_const = null;
        if (attrs.getNamedItem("index") != null) {
            String indexName = attrs.getNamedItem("index") .getNodeValue();
            Index catalog_index = indexMap.get(indexName);
           
            if (catalog_index != null) {
                // If this is a foreign key, then we *do not* want to include an index for it
                // since we don't actually do anything to enforce these constraints
                if (type == ConstraintType.FOREIGN_KEY) {
                    boolean ret = table.getIndexes().remove(catalog_index);
                    LOG.debug("Removing foreign key index " + catalog_index.fullName() + " [" + ret + "]");
                    indexMap.remove(indexName);
                    catalog_index = null;
                }
                else {
                    // if the constraint name contains index type hints, exercise them (giant hack)
                    String constraintNameNoCase = name.toLowerCase();
                    if (constraintNameNoCase.contains("tree"))
                        catalog_index.setType(IndexType.BALANCED_TREE.getValue());
                    if (constraintNameNoCase.contains("array"))
                        catalog_index.setType(IndexType.ARRAY.getValue());
                }
            }

            catalog_const = table.getConstraints().add(name);
            if (catalog_index != null) {
                catalog_const.setIndex(catalog_index);
                catalog_index.setUnique(type == ConstraintType.UNIQUE || type == ConstraintType.PRIMARY_KEY);
            }
        } else {
            catalog_const = table.getConstraints().add(name);
        }
        catalog_const.setType(type.getValue());

        // Foreign Keys
        if (type == ConstraintType.FOREIGN_KEY) {
            String fkey_table_name = attrs.getNamedItem("foreignkeytable").getNodeValue();
            Table catalog_fkey_tbl = ((Database)table.getParent()).getTables().getIgnoreCase(fkey_table_name);
            if (catalog_fkey_tbl == null) {
                throw this.m_compiler.new VoltCompilerException("Invalid foreign key table '" + fkey_table_name + "'");
            }
            catalog_const.setForeignkeytable(catalog_fkey_tbl);

            // Column mappings
            NodeList children = node.getChildNodes();
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

            ParsedSelectStmt stmt = null;
            try {
                stmt = (ParsedSelectStmt) AbstractParsedStmt.parse(query, xmlquery, db);
            }
            catch (Exception e) {
                throw m_compiler.new VoltCompilerException(e.getMessage());
            }
            assert(stmt != null);

            // throw an error if the view isn't withing voltdb's limited worldview
            checkViewMeetsSpec(destTable.getTypeName(), stmt);
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        String msg = "Materialized view \"" + viewName + "\" ";

        if (stmt.tableList.size() != 1) {
            msg += "has " + String.valueOf(stmt.tableList.size()) + " sources. " +
            "Only one source view or source table is allowed.";
            throw m_compiler.new VoltCompilerException(msg);
        }

        if (displayColCount <= groupColCount) {
            msg += "has too few columns.";
            throw m_compiler.new VoltCompilerException(msg);
        }

        int i;
        for (i = 0; i < groupColCount; i++) {
            ParsedSelectStmt.ParsedColInfo gbcol = stmt.groupByColumns.get(i);
            ParsedSelectStmt.ParsedColInfo outcol = stmt.displayColumns.get(i);

            if (outcol.expression.getExpressionType() != ExpressionType.VALUE_TUPLE) {
                msg += "must have column at index " + String.valueOf(i) + " be " + gbcol.alias;
                throw m_compiler.new VoltCompilerException(msg);
            }

            TupleValueExpression expr = (TupleValueExpression) outcol.expression;
            if (expr.getColumnIndex() != gbcol.index) {
                msg += "must have column at index " + String.valueOf(i) + " be " + gbcol.alias;
                throw m_compiler.new VoltCompilerException(msg);
            }
        }

        AbstractExpression coli = stmt.displayColumns.get(i).expression;
        if ((coli.getExpressionType() != ExpressionType.AGGREGATE_COUNT) ||
                (coli.getLeft() != null) ||
                (coli.getRight() != null)) {
            msg += "is missing count(*) as the column after the group by columns, a materialized view requirement.";
            throw m_compiler.new VoltCompilerException(msg);
        }

        for (i++; i < displayColCount; i++) {
            ParsedSelectStmt.ParsedColInfo outcol = stmt.displayColumns.get(i);
            if ((outcol.expression.getExpressionType() != ExpressionType.AGGREGATE_COUNT) &&
                    (outcol.expression.getExpressionType() != ExpressionType.AGGREGATE_SUM)) {
                msg += "must have non-group by columns aggregated by sum or count.";
                throw m_compiler.new VoltCompilerException(msg);
            }
            if (outcol.expression.getLeft().getExpressionType() != ExpressionType.VALUE_TUPLE) {
                msg += "must have non-group by columns use only one level of aggregation.";
                throw m_compiler.new VoltCompilerException(msg);
            }
        }
    }
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        byte[] existing = dataInJar.get(key);
        if (existing != null) {
            if (existing.equals(bytes))
                return;
            String msg = "Tring to put the same content in a jar file twice.";
            throw m_compiler.new VoltCompilerException(msg);
        }
        dataInJar.put(key, bytes);
    }
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

            int bytesRead = in.read(bytes);
            assert(bytesRead != -1);

        } catch (FileNotFoundException e) {
            String msg = "JarBuilder can't find file: " + file.getName();
            throw m_compiler.new VoltCompilerException(msg);
        } catch (IOException e) {
            String msg = "IO Exception reading file: " + file.getName();
            throw m_compiler.new VoltCompilerException(msg);
        }

        addEntry(key, bytes);
    }
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        FileOutputStream output = null;
        try {
            output = new FileOutputStream(path);
        } catch (FileNotFoundException e) {
            String msg = "Unable to open destination jarfile for writing";
            throw m_compiler.new VoltCompilerException(msg);
        }

        JarOutputStream jarOut = null;
        try {
            jarOut = new JarOutputStream(output);
        } catch (IOException e) {
            String msg = "Error writing to destination jarfile";
            throw m_compiler.new VoltCompilerException(msg);
        }

        for (String key : dataInJar.keySet()) {
            byte[] bytes = dataInJar.get(key);
            assert(bytes != null);

            JarEntry entry = new JarEntry(key);
            try {
                entry.setSize(bytes.length);
                jarOut.putNextEntry(entry);
                jarOut.write(bytes);
                jarOut.flush();
                jarOut.closeEntry();
            } catch (IOException e) {
                String msg = "Unable to write file: " + key + " to destination jarfile";
                throw m_compiler.new VoltCompilerException(msg);
            }
        }

        try {
            jarOut.close();
        } catch (IOException e) {
            String msg = "Error finishing writing destination jarfile to disk";
            throw m_compiler.new VoltCompilerException(msg);
        }
    }
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

            // These are normal expectable errors -- don't normally need a stack-trace.
            String msg = "Failed to plan for statement (" + catalogStmt.getTypeName() + ") " + catalogStmt.getSqltext();
            if (e.getMessage() != null) {
                msg += " Error: \"" + e.getMessage() + "\"";
            }
            throw compiler.new VoltCompilerException(msg);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw compiler.new VoltCompilerException("Failed to plan for stmt: " + catalogStmt.getTypeName());
        }

        // There is a hard-coded limit to the number of parameters that can be passed to the EE.
        if (plan.parameters.length > CompiledPlan.MAX_PARAM_COUNT) {
            throw compiler.new VoltCompilerException(
                "The statement's parameter count " + plan.parameters.length +
                " must not exceed the maximum " + CompiledPlan.MAX_PARAM_COUNT);
        }

        // Check order determinism before accessing the detail which it caches.
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

            try {
                processed = processVoltDBStatement(stmt, db, whichProcs);
            } catch (VoltCompilerException e) {
                // Reformat the message thrown by VoltDB DDL processing to have a line number.
                String msg = "VoltDB DDL Error: \"" + e.getMessage() + "\" in statement starting on lineno: " + stmt.lineNo;
                throw m_compiler.new VoltCompilerException(msg);
            }
            if (!processed) {
                try {
                    // Check for CREATE TABLE, CREATE VIEW, ALTER or DROP TABLE.
                    // We sometimes choke at parsing statements with newlines, so
                    // check against a newline free version of the stmt.
                    String oneLinerStmt = stmt.statement.replace("\n", " ");
                    Matcher tableMatcher = createTablePattern.matcher(oneLinerStmt);
                    if (tableMatcher.find()) {
                        String tableName = tableMatcher.group(2);
                        m_tableNameToDDL.put(tableName.toUpperCase(), stmt.statement);
                    } else {
                        Matcher atableMatcher = alterOrDropTablePattern.matcher(oneLinerStmt);
                        if (atableMatcher.find()) {
                            String op = atableMatcher.group(1);
                            String tableName = atableMatcher.group(3);
                            if (op.equalsIgnoreCase("DROP")) {
                                m_tableNameToDDL.remove(tableName.toUpperCase());
                            } else {
                                //ALTER - Append the statement
                                String prevStmt = m_tableNameToDDL.get(tableName.toUpperCase());
                                if (prevStmt != null) {
                                    //Append the SQL for report...else would blow up compilation.
                                    m_tableNameToDDL.put(tableName.toUpperCase(), prevStmt + "\n" + stmt.statement);
                                }
                            }
                        }
                    }

                    // kind of ugly.  We hex-encode each statement so we can
                    // avoid embedded newlines so we can delimit statements
                    // with newline.
                    m_fullDDL += Encoder.hexEncode(stmt.statement) + "\n";
                    // Get the diff that results from applying this statement and apply it
                    // to our local tree (with Volt-specific additions)
                    VoltXMLDiff thisStmtDiff = m_hsql.runDDLCommandAndDiff(stmt.statement);
                    applyDiff(thisStmtDiff);
                } catch (HSQLParseException e) {
                    String msg = "DDL Error: \"" + e.getMessage() + "\" in statement starting on lineno: " + stmt.lineNo;
                    throw m_compiler.new VoltCompilerException(msg, stmt.lineNo);
                }
            }
            stmt = getNextStatement(reader, m_compiler);
        }

        try {
            reader.close();
        } catch (IOException e) {
            throw m_compiler.new VoltCompilerException("Error closing schema file");
        }

        // process extra classes
        m_tracker.addExtraClasses(m_classMatcher.getMatchedClassList());
        // possibly save some memory
View Full Code Here

Examples of org.voltdb.compiler.VoltCompiler.VoltCompilerException

        do {
            if ( ! Character.isJavaIdentifierStart(identifier.charAt(loc))) {
                String msg = "Unknown indentifier in DDL: \"" +
                        statement.substring(0,statement.length()-1) +
                        "\" contains invalid identifier \"" + identifier + "\"";
                throw m_compiler.new VoltCompilerException(msg);
            }
            loc = identifier.indexOf('.', loc) + 1;
        }
        while( loc > 0 && loc < identifier.length());
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.