Package org.jrdf.query.relation

Examples of org.jrdf.query.relation.EvaluatedRelation


    // TODO (AN) Add tuple subsumption i.e. go through the results and remove the results for a given attribute binding
    // that have null values.  Or add it to a new time of join.  Or replace this with minimum union and tuple
    // subsumption.

    public EvaluatedRelation join(EvaluatedRelation relation1, EvaluatedRelation relation2) {
        EvaluatedRelation minUnionResult = leftOuterJoin.join(relation1, relation2);
        return union.union(minUnionResult, relation2);
    }
View Full Code Here


            return performMinimumUnion(relations);
        }
    }

    private EvaluatedRelation performMinimumUnion(LinkedHashSet<EvaluatedRelation> relations) {
        EvaluatedRelation relation = relationProcessor.processRelations(relations, unionTupleEngine);
        EvaluatedRelation subsumptionRelation = relationProcessor.processRelations(relations, subsumptionTupleEngine);
        for (Tuple tuple : subsumptionRelation.getTuples()) {
            relation.getTuples().remove(tuple);
        }
        return relation;
    }
View Full Code Here

    public EvaluatedRelation join(final EvaluatedRelation relation1, final EvaluatedRelation relation2) {
        final Set<EvaluatedRelation> relations = new HashSet<EvaluatedRelation>();
        relations.add(relation1);
        relations.add(relation2);
        final EvaluatedRelation joinResult = naturalJoin.join(relations);
        if (RELATION_DEE.equals(relation1)) {
            return joinResult;
        } else {
            return union.union(joinResult, relation1);
        }
View Full Code Here

        this.tupleEngine = newTupleEngine;
        this.relationProcessor = newRelationProcessor;
    }

    public EvaluatedRelation join(Set<EvaluatedRelation> relations) {
        EvaluatedRelation relation = isDeeDumOrSingle(relations);
        if (relation == null) {
            relation = relationProcessor.processRelations(relations, tupleEngine);
        }
        return relation;
    }
View Full Code Here

        }
        return relation;
    }

    private EvaluatedRelation isDeeDumOrSingle(Set<EvaluatedRelation> relations) {
        EvaluatedRelation relation = null;
        // Is it the empty collection return DEE.
        if (relations.equals(Collections.<EvaluatedRelation>emptySet())) {
            relation = RELATION_DEE;
        }
        // Is it DUM - therefore return DUM
View Full Code Here

        this.tupleComparator = newTupleComparator;
    }

    public EvaluatedRelation processRelations(Set<EvaluatedRelation> relations, TupleEngine tupleEngine) {
        Iterator<EvaluatedRelation> iterator = relations.iterator();
        EvaluatedRelation relation1 = iterator.next();
        EvaluatedRelation relation2 = iterator.next();
        EvaluatedRelation resultRelation = processRelationPairs(tupleEngine, relation1, relation2);
        while (iterator.hasNext()) {
            EvaluatedRelation nextRelation = iterator.next();
            resultRelation = processRelationPairs(tupleEngine, resultRelation, nextRelation);
        }

        return convertToConstants(resultRelation);
    }
View Full Code Here

        this.relationFactory = newRelationFactory;
        this.tupleComparator = newTupleComparator;
    }

    public EvaluatedRelation minus(EvaluatedRelation relation1, EvaluatedRelation relation2) {
        EvaluatedRelation result = deeOrDumOperations(relation1, relation2);
        if (result != null) {
            return result;
        }
        SortedSet<Tuple> resultTuples = new TreeSet<Tuple>(tupleComparator);
        performMinus(relation1, relation2, resultTuples);
View Full Code Here

        result = relationFactory.getRelation(resultTuples);
        return relationProcessor.convertToConstants(result);
    }

    private EvaluatedRelation deeOrDumOperations(EvaluatedRelation relation1, EvaluatedRelation relation2) {
        EvaluatedRelation result = null;
        // DUM - Anything is DUM.
        if (relation1 == RELATION_DUM) {
            result = RELATION_DUM;
            // DEE - DEE is DUM, otherwise it's DEE
        } else if (relation1 == RELATION_DEE) {
View Full Code Here

        boolean result = getResult(graph, queryEngine);
        return new AskAnswerImpl(System.currentTimeMillis() - timeStarted, result);
    }

    private boolean getResult(Graph graph, QueryEngine queryEngine) {
        EvaluatedRelation entireGraph = graphRelationFactory.createRelation(graph);
        queryEngine.initialiseBaseRelation(entireGraph);
        ExpressionSimplifier<Void> simplifier = new ExpressionSimplifierImpl();
        expression.accept(simplifier);
        expression = simplifier.getExpression();
        if (simplifier.parseAgain()) {
            expression.accept(simplifier);
            expression = simplifier.getExpression();
        }
        EvaluatedRelation relation = expression.accept(queryEngine);
        return !relation.isEmpty();
    }
View Full Code Here

    }

    public Answer executeQuery(Graph graph, QueryEngine queryEngine) {
        checkNotNull(graph, queryEngine);
        long timeStarted = System.currentTimeMillis();
        EvaluatedRelation result = getResult(graph, queryEngine);
        LinkedHashSet<Attribute> heading = getHeading(result);
        return new SelectAnswerImpl(heading, result, System.currentTimeMillis() - timeStarted, hasProjected());
    }
View Full Code Here

TOP

Related Classes of org.jrdf.query.relation.EvaluatedRelation

Copyright © 2018 www.massapicom. 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.