Search in sources :

Example 31 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class BufferManagerImpl method getState.

@Override
public void getState(String state_id, OutputStream ostream) {
    TupleBuffer buffer = this.getTupleBuffer(state_id);
    if (buffer != null) {
        try {
            ObjectOutputStream out = new ObjectOutputStream(ostream);
            getTupleBufferState(out, buffer);
            out.flush();
        } catch (TeiidComponentException e) {
            throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30054, e);
        } catch (IOException e) {
            throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30055, e);
        }
    }
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 32 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class FileStorageManager method initialize.

/**
 * Initialize
 */
public void initialize() throws TeiidComponentException {
    if (this.directory == null) {
        throw new TeiidComponentException(QueryPlugin.Event.TEIID30040, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30040));
    }
    dirFile = new File(this.directory);
    makeDir(dirFile);
    for (int i = 0; i < subDirectories.length; i++) {
        // $NON-NLS-1$
        subDirectories[i] = new File(this.directory, "b" + i);
        makeDir(subDirectories[i]);
    }
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 33 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class TestResolver method helpCheckElements.

private void helpCheckElements(LanguageObject langObj, String[] elementNames, String[] elementIDs) {
    List<ElementSymbol> elements = new ArrayList<ElementSymbol>();
    ElementCollectorVisitor.getElements(langObj, elements);
    // $NON-NLS-1$
    assertEquals("Wrong number of elements: ", elementNames.length, elements.size());
    for (int i = 0; i < elements.size(); i++) {
        ElementSymbol symbol = elements.get(i);
        // $NON-NLS-1$
        assertEquals("Element name does not match: ", elementNames[i].toUpperCase(), symbol.getName().toUpperCase());
        Object elementID = symbol.getMetadataID();
        try {
            String name = metadata.getFullName(elementID);
            // $NON-NLS-1$ //$NON-NLS-2$
            assertNotNull("ElementSymbol " + symbol + " was not resolved and has no metadataID", elementID);
            // $NON-NLS-1$
            assertEquals("ElementID name does not match: ", elementIDs[i].toUpperCase(), name.toUpperCase());
        } catch (TeiidComponentException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) ArrayList(java.util.ArrayList) LanguageObject(org.teiid.query.sql.LanguageObject) TeiidComponentException(org.teiid.core.TeiidComponentException)

Example 34 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class TestJoinNode method helpCreateJoin.

protected void helpCreateJoin() {
    // $NON-NLS-1$
    ElementSymbol es1 = new ElementSymbol("e1");
    es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    // $NON-NLS-1$
    ElementSymbol es2 = new ElementSymbol("e2");
    es2.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    List leftElements = new ArrayList();
    leftElements.add(es1);
    leftNode = new BlockingFakeRelationalNode(1, leftTuples);
    leftNode.setElements(leftElements);
    List rightElements = new ArrayList();
    rightElements.add(es2);
    rightNode = new BlockingFakeRelationalNode(2, rightTuples) {

        @Override
        public boolean hasBuffer() {
            return false;
        }

        @Override
        public TupleBuffer getBufferDirect(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException {
            fail();
            throw new AssertionError();
        }
    };
    rightNode.setElements(rightElements);
    List joinElements = new ArrayList();
    joinElements.add(es1);
    joinElements.add(es2);
    join = new JoinNode(3);
    joinStrategy = new NestedLoopJoinStrategy();
    join.setJoinStrategy(joinStrategy);
    join.setElements(joinElements);
    join.setJoinType(joinType);
    switch(criteriaType) {
        case NO_CRITERIA:
            break;
        case EQUAL_CRITERIA:
            join.setJoinExpressions(Arrays.asList(es1), Arrays.asList(es2));
            joinStrategy = new MergeJoinStrategy(SortOption.SORT, SortOption.SORT, false);
            join.setJoinStrategy(joinStrategy);
            break;
        case FUNCTION_CRITERIA:
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 });
            // $NON-NLS-1$
            FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class });
            func.setFunctionDescriptor(desc);
            func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
            CompareCriteria joinCriteria = new CompareCriteria(es2, CompareCriteria.EQ, func);
            join.setJoinCriteria(joinCriteria);
            break;
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) TupleBuffer(org.teiid.common.buffer.TupleBuffer) FunctionDescriptor(org.teiid.query.function.FunctionDescriptor) BlockedException(org.teiid.common.buffer.BlockedException) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) TeiidProcessingException(org.teiid.core.TeiidProcessingException) Function(org.teiid.query.sql.symbol.Function) ArrayList(java.util.ArrayList) List(java.util.List) TeiidComponentException(org.teiid.core.TeiidComponentException)

Example 35 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class TestSelectNode method testTimeslicing.

@Test
public void testTimeslicing() throws TeiidComponentException, TeiidProcessingException {
    // $NON-NLS-1$
    ElementSymbol es1 = new ElementSymbol("e1");
    es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    List elements = new ArrayList();
    elements.add(es1);
    CompareCriteria crit = new CompareCriteria(es1, CompareCriteria.EQ, new Constant(new Integer(1)));
    List[] data = new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) };
    List childElements = new ArrayList();
    childElements.add(es1);
    helpTestSelect(elements, crit, childElements, null, data, new FakeRelationalNode(2, data), new SelectNode(3) {

        int i = 0;

        @Override
        protected Evaluator getEvaluator(Map elementMap) {
            return new Evaluator(elementMap, getDataManager(), getContext()) {

                @Override
                public Boolean evaluateTVL(Criteria criteria, List<?> tuple) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
                    if (i++ == 1) {
                        throw new QueryProcessor.ExpiredTimeSliceException();
                    }
                    return super.evaluateTVL(criteria, tuple);
                }
            };
        }
    });
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) ExpressionEvaluationException(org.teiid.api.exception.query.ExpressionEvaluationException) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) Criteria(org.teiid.query.sql.lang.Criteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) Evaluator(org.teiid.query.eval.Evaluator) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) BlockedException(org.teiid.common.buffer.BlockedException) QueryProcessor(org.teiid.query.processor.QueryProcessor) ArrayList(java.util.ArrayList) List(java.util.List) TeiidComponentException(org.teiid.core.TeiidComponentException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

TeiidComponentException (org.teiid.core.TeiidComponentException)109 TeiidProcessingException (org.teiid.core.TeiidProcessingException)33 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)23 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)23 ArrayList (java.util.ArrayList)18 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)17 BlockedException (org.teiid.common.buffer.BlockedException)16 IOException (java.io.IOException)15 List (java.util.List)14 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)13 Test (org.junit.Test)12 LanguageObject (org.teiid.query.sql.LanguageObject)12 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)11 CommandContext (org.teiid.query.util.CommandContext)11 QueryValidatorException (org.teiid.api.exception.query.QueryValidatorException)10 ExpressionEvaluationException (org.teiid.api.exception.query.ExpressionEvaluationException)9 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)9 HashMap (java.util.HashMap)7 TeiidException (org.teiid.core.TeiidException)7 LogonException (org.teiid.client.security.LogonException)6