Exemplo n.º 1
0
 public Tuple get(RowKey key) {
   AssociationOperation result = currentState.get(key);
   if (result == null) {
     return cleared ? null : snapshot.get(key);
   } else if (result.getType() == PUT_NULL || result.getType() == REMOVE) {
     return null;
   }
   return result.getValue();
 }
Exemplo n.º 2
0
 public int size() {
   int size = cleared ? 0 : snapshot.size();
   for (Map.Entry<RowKey, AssociationOperation> op : currentState.entrySet()) {
     switch (op.getValue().getType()) {
       case PUT:
       case PUT_NULL:
         if (cleared || !snapshot.containsKey(op.getKey())) {
           size++;
         }
         break;
       case REMOVE:
         if (!cleared && snapshot.containsKey(op.getKey())) {
           size--;
         }
         break;
     }
   }
   return size;
 }
Exemplo n.º 3
0
 public boolean isEmpty() {
   int snapshotSize = cleared ? 0 : snapshot.size();
   // nothing in both
   if (snapshotSize == 0 && currentState.isEmpty()) {
     return true;
   }
   // snapshot bigger than changeset
   if (snapshotSize > currentState.size()) {
     return false;
   }
   return size() == 0;
 }
Exemplo n.º 4
0
 public Set<RowKey> getKeys() {
   Set<RowKey> keys = new HashSet<RowKey>();
   if (!cleared) {
     keys.addAll(snapshot.getRowKeys());
   }
   for (Map.Entry<RowKey, AssociationOperation> op : currentState.entrySet()) {
     switch (op.getValue().getType()) {
       case PUT:
       case PUT_NULL:
         keys.add(op.getKey());
         break;
       case REMOVE:
         keys.remove(op.getKey());
         break;
     }
   }
   return keys;
 }