Search in sources :

Example 31 with IgniteException

use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.

the class IgnitePlanner method expandView.

/**
 * {@inheritDoc}
 */
@Override
public RelRoot expandView(RelDataType rowType, String qryStr, List<String> schemaPath, List<String> viewPath) {
    SqlParser parser = SqlParser.create(qryStr, parserCfg);
    SqlNode sqlNode;
    try {
        sqlNode = parser.parseQuery();
    } catch (SqlParseException e) {
        // throw new IgniteSQLException("parse failed", IgniteQueryErrorCode.PARSING, e);
        throw new IgniteException("parse failed", e);
    }
    CalciteCatalogReader catalogReader = this.catalogReader.withSchemaPath(schemaPath);
    SqlValidator validator = new IgniteSqlValidator(operatorTbl, catalogReader, typeFactory, validatorCfg, ctx.parameters());
    SqlToRelConverter sqlToRelConverter = sqlToRelConverter(validator, catalogReader, sqlToRelConverterCfg);
    RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false);
    root = root.withRel(sqlToRelConverter.decorrelate(sqlNode, root.rel));
    return trimUnusedFields(root);
}
Also used : SqlToRelConverter(org.apache.calcite.sql2rel.SqlToRelConverter) SqlParseException(org.apache.calcite.sql.parser.SqlParseException) CalciteCatalogReader(org.apache.calcite.prepare.CalciteCatalogReader) IgniteException(org.apache.ignite.lang.IgniteException) SqlValidator(org.apache.calcite.sql.validate.SqlValidator) SqlParser(org.apache.calcite.sql.parser.SqlParser) RelRoot(org.apache.calcite.rel.RelRoot) SqlNode(org.apache.calcite.sql.SqlNode)

Example 32 with IgniteException

use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.

the class RelJson method relFactory.

private static RelFactory relFactory(String typeName) {
    Class<?> clazz = null;
    if (!typeName.contains(".")) {
        for (String pckg : PACKAGES) {
            if ((clazz = classForName(pckg + typeName, true)) != null) {
                break;
            }
        }
    }
    if (clazz == null) {
        clazz = classForName(typeName, false);
    }
    assert RelNode.class.isAssignableFrom(clazz);
    Constructor<RelNode> constructor;
    try {
        constructor = (Constructor<RelNode>) clazz.getConstructor(RelInput.class);
    } catch (NoSuchMethodException e) {
        throw new IgniteException("class does not have required constructor, " + clazz + "(RelInput)");
    }
    BlockBuilder builder = new BlockBuilder();
    ParameterExpression input = Expressions.parameter(RelInput.class);
    builder.add(Expressions.new_(constructor, input));
    MethodDeclaration declaration = Expressions.methodDecl(Modifier.PUBLIC, RelNode.class, "apply", asList(input), builder.toBlock());
    return Commons.compile(RelFactory.class, Expressions.toString(asList(declaration), "\n", true));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) IgniteException(org.apache.ignite.lang.IgniteException) MethodDeclaration(org.apache.calcite.linq4j.tree.MethodDeclaration) ParameterExpression(org.apache.calcite.linq4j.tree.ParameterExpression) BlockBuilder(org.apache.calcite.linq4j.tree.BlockBuilder)

Example 33 with IgniteException

use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.

the class RelJsonReader method read.

/**
 * Read.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 */
public RelNode read(String s) {
    try {
        lastRel = null;
        Map<String, Object> o = mapper.readValue(s, TYPE_REF);
        List<Map<String, Object>> rels = (List) o.get("rels");
        readRels(rels);
        return lastRel;
    } catch (IOException e) {
        throw new IgniteException(e);
    }
}
Also used : IgniteException(org.apache.ignite.lang.IgniteException) AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 34 with IgniteException

use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.

the class RootNode method close.

/**
 * {@inheritDoc}
 */
@Override
public void close() {
    if (closed) {
        return;
    }
    lock.lock();
    try {
        if (waiting != -1 || !outBuff.isEmpty()) {
            ex.compareAndSet(null, new IgniteException("Query was cancelled"));
        }
        // an exception has to be set first to get right check order
        closed = true;
        cond.signalAll();
    } finally {
        lock.unlock();
    }
    onClose.run();
}
Also used : IgniteException(org.apache.ignite.lang.IgniteException)

Example 35 with IgniteException

use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.

the class RelJsonWriter method asString.

/**
 * AsString.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 */
public String asString() {
    try {
        StringWriter writer = new StringWriter();
        ObjectMapper mapper = new ObjectMapper();
        ObjectWriter writer0 = pretty ? mapper.writer(new DefaultPrettyPrinter()) : mapper.writer();
        writer0.withRootName("rels").writeValue(writer, relList);
        return writer.toString();
    } catch (IOException e) {
        throw new IgniteException(e);
    }
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) StringWriter(java.io.StringWriter) IgniteException(org.apache.ignite.lang.IgniteException) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

IgniteException (org.apache.ignite.lang.IgniteException)39 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 BinaryRow (org.apache.ignite.internal.schema.BinaryRow)10 NotNull (org.jetbrains.annotations.NotNull)10 Map (java.util.Map)9 MarshallerException (org.apache.ignite.internal.schema.marshaller.MarshallerException)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8 HashMap (java.util.HashMap)7 List (java.util.List)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 NodeStoppingException (org.apache.ignite.lang.NodeStoppingException)7 HashSet (java.util.HashSet)6 CompletionException (java.util.concurrent.CompletionException)6 Row (org.apache.ignite.internal.schema.row.Row)6 NoSuchElementException (java.util.NoSuchElementException)5 Set (java.util.Set)5 UUID (java.util.UUID)5 Consumer (java.util.function.Consumer)5 Collectors (java.util.stream.Collectors)5