Example #1
0
 @Override
 public boolean equals(Relation arg) {
   if (arg == this) return true;
   if (arg == null || !(arg instanceof Relation)) return false;
   Relation other = (Relation) arg;
   return TYPE.equals(other.getType()) && other.stream().findFirst().isPresent();
 }
Example #2
0
 /**
  * we look for keys that are preserved by the projection and if so these keys are the new keys,
  * otherwise the 'on' attributes form the new key (key of the projection)
  */
 @Override
 public Keys lazyComputeKey() {
   Keys keys = operand.getKeys();
   Predicate<Key> p = (k) -> isKeyPreserving(k);
   Set<Key> kept = keys.stream().filter(p).collect(Collectors.toSet());
   if (kept.isEmpty()) {
     return new Keys(type.getLargestKey());
   } else {
     return new Keys(kept);
   }
 }
Example #3
0
 public boolean isKeyPreserving() {
   Predicate<Key> pred = (k) -> isKeyPreserving(k);
   return operand.getKeys().stream().anyMatch(pred);
 }
Example #4
0
 @Override
 protected RelationType typeCheck() {
   return operand.getType().project(attributes);
 }