Example #1
0
 @Override
 protected <U extends IValue> Result<U> joinRelation(RelationResult that) {
   // Note the reverse of arguments, we need "that join this"
   int arity1 = that.getValue().arity();
   Type eltType = getType().getElementType();
   Type tupleType = that.getType().getElementType();
   Type fieldTypes[] = new Type[arity1 + 1];
   for (int i = 0; i < arity1; i++) {
     fieldTypes[i] = tupleType.getFieldType(i);
   }
   fieldTypes[arity1] = eltType;
   Type resultTupleType = getTypeFactory().tupleType(fieldTypes);
   ISetWriter writer = getValueFactory().setWriter(resultTupleType);
   IValue fieldValues[] = new IValue[arity1 + 1];
   for (IValue relValue : that.getValue()) {
     for (IValue setValue : this.getValue()) {
       for (int i = 0; i < arity1; i++) {
         fieldValues[i] = ((ITuple) relValue).get(i);
       }
       fieldValues[arity1] = setValue;
       writer.insert(getValueFactory().tuple(fieldValues));
     }
   }
   Type resultType = getTypeFactory().relTypeFromTuple(resultTupleType);
   return makeResult(resultType, writer.done(), ctx);
 }
Example #2
0
 @Override
 protected <U extends IValue> Result<U> addRelation(RelationResult that) {
   return that.insertTuple(this);
 }