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;
}
}
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;
}
}
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;
}
Aggregations