Search in sources :

Example 1 with BindingSetConversionException

use of org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException in project incubator-rya by apache.

the class PCJKeyToJoinBindingSetIterator method hasNext.

@Override
public boolean hasNext() throws QueryEvaluationException {
    if (!hasNextCalled && !isEmpty) {
        while (iterator.hasNext()) {
            Key key = iterator.next().getKey();
            // constant constraints
            try {
                next = getBindingSetEntryAndMatchConstants(key);
            } catch (BindingSetConversionException e) {
                throw new QueryEvaluationException("Could not deserialize PCJ BindingSet.");
            }
            // skip key if constant constraint don't match
            if (next == EMPTY_ENTRY) {
                continue;
            }
            hasNextCalled = true;
            return true;
        }
        isEmpty = true;
        return false;
    } else if (isEmpty) {
        return false;
    } else {
        return true;
    }
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) BindingSetConversionException(org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException) Key(org.apache.accumulo.core.data.Key)

Example 2 with BindingSetConversionException

use of org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException in project incubator-rya by apache.

the class PCJKeyToCrossProductBindingSetIterator method hasNext.

@Override
public boolean hasNext() throws QueryEvaluationException {
    if (!hasNextCalled && !isEmpty) {
        if (crossProductBsExist) {
            while (crossProductIter.hasNext() || iterator.hasNext()) {
                if (!crossProductIter.hasNext()) {
                    Key key = iterator.next().getKey();
                    try {
                        crossProductIter = getCrossProducts(getBindingSet(key));
                    } catch (BindingSetConversionException e) {
                        throw new QueryEvaluationException(e);
                    }
                }
                if (!crossProductIter.hasNext()) {
                    continue;
                }
                next = crossProductIter.next();
                hasNextCalled = true;
                return true;
            }
        } else {
            while (iterator.hasNext()) {
                Key key = iterator.next().getKey();
                try {
                    next = getBindingSet(key);
                } catch (BindingSetConversionException e) {
                    throw new QueryEvaluationException(e);
                }
                // out by constant constraints
                if (next == null || next == EMPTY_BINDINGSET) {
                    continue;
                }
                hasNextCalled = true;
                return true;
            }
        }
        isEmpty = true;
        return false;
    } else if (isEmpty) {
        return false;
    } else {
        return true;
    }
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) BindingSetConversionException(org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException) Key(org.apache.accumulo.core.data.Key)

Example 3 with BindingSetConversionException

use of org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException in project incubator-rya by apache.

the class PcjIntegrationTestingUtil method makeWriteResultMutations.

/**
 * Create the {@link Mutations} required to write a new {@link BindingSet}
 * to a PCJ table for each {@link VariableOrder} that is provided.
 *
 * @param varOrders
 *            - The variables orders the result will be written to. (not
 *            null)
 * @param result
 *            - A new PCJ result. (not null)
 * @return Mutation that will write the result to a PCJ table.
 * @throws PcjException
 *             The binding set could not be encoded.
 */
private static Set<Mutation> makeWriteResultMutations(final Set<VariableOrder> varOrders, final BindingSet result) throws PcjException {
    checkNotNull(varOrders);
    checkNotNull(result);
    final Set<Mutation> mutations = new HashSet<>();
    for (final VariableOrder varOrder : varOrders) {
        try {
            // Serialize the result to the variable order.
            final byte[] serializedResult = converter.convert(result, varOrder);
            // Row ID = binding set values, Column Family = variable order
            // of the binding set.
            final Mutation addResult = new Mutation(serializedResult);
            addResult.put(varOrder.toString(), "", "");
            mutations.add(addResult);
        } catch (final BindingSetConversionException e) {
            throw new PcjException("Could not serialize a result.", e);
        }
    }
    return mutations;
}
Also used : VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) PcjException(org.apache.rya.indexing.pcj.storage.PcjException) Mutation(org.apache.accumulo.core.data.Mutation) BindingSetConversionException(org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException) HashSet(java.util.HashSet)

Aggregations

BindingSetConversionException (org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException)3 Key (org.apache.accumulo.core.data.Key)2 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)2 HashSet (java.util.HashSet)1 Mutation (org.apache.accumulo.core.data.Mutation)1 PcjException (org.apache.rya.indexing.pcj.storage.PcjException)1 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)1