示例#1
0
 public MutationState(
     TableRef table,
     Map<ImmutableBytesPtr, Map<PColumn, byte[]>> mutations,
     long sizeOffset,
     long maxSize,
     PhoenixConnection connection) {
   this.maxSize = maxSize;
   this.connection = connection;
   this.mutations.put(table, mutations);
   this.sizeOffset = sizeOffset;
   this.numRows = mutations.size();
   throwIfTooBig();
 }
示例#2
0
 private MutationState(
     List<Map.Entry<TableRef, Map<ImmutableBytesPtr, Map<PColumn, byte[]>>>> entries,
     long sizeOffset,
     long maxSize,
     PhoenixConnection connection) {
   this.maxSize = maxSize;
   this.connection = connection;
   this.sizeOffset = sizeOffset;
   for (Map.Entry<TableRef, Map<ImmutableBytesPtr, Map<PColumn, byte[]>>> entry : entries) {
     numRows += entry.getValue().size();
     this.mutations.put(entry.getKey(), entry.getValue());
   }
   throwIfTooBig();
 }
示例#3
0
 /**
  * Combine a newer mutation with this one, where in the event of overlaps, the newer one will take
  * precedence.
  *
  * @param newMutation the newer mutation
  */
 public void join(MutationState newMutation) {
   if (this == newMutation) { // Doesn't make sense
     return;
   }
   // Merge newMutation with this one, keeping state from newMutation for any overlaps
   for (Map.Entry<TableRef, Map<ImmutableBytesPtr, Map<PColumn, byte[]>>> entry :
       newMutation.mutations.entrySet()) {
     // Replace existing entries for the table with new entries
     Map<ImmutableBytesPtr, Map<PColumn, byte[]>> existingRows =
         this.mutations.put(entry.getKey(), entry.getValue());
     if (existingRows != null) { // Rows for that table already exist
       // Loop through new rows and replace existing with new
       for (Map.Entry<ImmutableBytesPtr, Map<PColumn, byte[]>> rowEntry :
           entry.getValue().entrySet()) {
         // Replace existing row with new row
         Map<PColumn, byte[]> existingValues =
             existingRows.put(rowEntry.getKey(), rowEntry.getValue());
         if (existingValues != null) {
           if (existingValues != PRow.DELETE_MARKER) {
             Map<PColumn, byte[]> newRow = rowEntry.getValue();
             // if new row is PRow.DELETE_MARKER, it means delete, and we don't need to merge it
             // with existing row.
             if (newRow != PRow.DELETE_MARKER) {
               // Replace existing column values with new column values
               for (Map.Entry<PColumn, byte[]> valueEntry : newRow.entrySet()) {
                 existingValues.put(valueEntry.getKey(), valueEntry.getValue());
               }
               // Now that the existing row has been merged with the new row, replace it back
               // again (since it was replaced with the new one above).
               existingRows.put(rowEntry.getKey(), existingValues);
             }
           }
         } else {
           numRows++;
         }
       }
       // Put the existing one back now that it's merged
       this.mutations.put(entry.getKey(), existingRows);
     } else {
       numRows += entry.getValue().size();
     }
   }
   throwIfTooBig();
 }