Java Code Examples for org.apache.hadoop.hbase.client.Mutation#compareTo()
The following examples show how to use
org.apache.hadoop.hbase.client.Mutation#compareTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexUpdateManager.java From phoenix with Apache License 2.0 | 4 votes |
/** * Fix up the current updates, given the pending mutation. * @param updates current updates * @param pendingMutation */ protected void fixUpCurrentUpdates(Collection<Mutation> updates, Mutation pendingMutation) { // need to check for each entry to see if we have a duplicate Mutation toRemove = null; Delete pendingDelete = pendingMutation instanceof Delete ? (Delete) pendingMutation : null; boolean sawRowMatch = false; for (Mutation stored : updates) { int compare = pendingMutation.compareTo(stored); // skip to the right row if (compare < 0) { continue; } else if (compare > 0) { if (sawRowMatch) { break; } continue; } // set that we saw a row match, so any greater row will necessarily be the wrong sawRowMatch = true; // skip until we hit the right timestamp if (stored.getTimeStamp() < pendingMutation.getTimeStamp()) { continue; } if (stored instanceof Delete) { // we already have a delete for this row, so we are done. if (pendingDelete != null) { return; } // pending update must be a Put, so we ignore the Put. // add a marker in the this delete that it has been canceled out already. We need to keep // the delete around though so we can figure out if other Puts would also be canceled out. markMutationForRemoval(stored); return; } // otherwise, the stored mutation is a Put. Either way, we want to remove it. If the pending // update is a delete, we need to remove the entry (no longer applies - covered by the // delete), or its an older version of the row, so we cover it with the newer. toRemove = stored; if (pendingDelete != null) { // the pending mutation, but we need to mark the mutation for removal later markMutationForRemoval(pendingMutation); break; } } updates.remove(toRemove); updates.add(pendingMutation); }
Example 2
Source File: IndexUpdateManager.java From phoenix with Apache License 2.0 | 4 votes |
/** * Fix up the current updates, given the pending mutation. * @param updates current updates * @param pendingMutation */ protected void fixUpCurrentUpdates(Collection<Mutation> updates, Mutation pendingMutation) { // need to check for each entry to see if we have a duplicate Mutation toRemove = null; Delete pendingDelete = pendingMutation instanceof Delete ? (Delete) pendingMutation : null; boolean sawRowMatch = false; for (Mutation stored : updates) { int compare = pendingMutation.compareTo(stored); // skip to the right row if (compare < 0) { continue; } else if (compare > 0) { if (sawRowMatch) { break; } continue; } // set that we saw a row match, so any greater row will necessarily be the wrong sawRowMatch = true; // skip until we hit the right timestamp if (stored.getTimeStamp() < pendingMutation.getTimeStamp()) { continue; } if (stored instanceof Delete) { // we already have a delete for this row, so we are done. if (pendingDelete != null) { return; } // pending update must be a Put, so we ignore the Put. // add a marker in the this delete that it has been canceled out already. We need to keep // the delete around though so we can figure out if other Puts would also be canceled out. markMutationForRemoval(stored); return; } // otherwise, the stored mutation is a Put. Either way, we want to remove it. If the pending // update is a delete, we need to remove the entry (no longer applies - covered by the // delete), or its an older version of the row, so we cover it with the newer. toRemove = stored; if (pendingDelete != null) { // the pending mutation, but we need to mark the mutation for removal later markMutationForRemoval(pendingMutation); break; } } if (toRemove != null) { updates.remove(toRemove); } if (pendingMutation != null) { updates.add(pendingMutation); } }
Example 3
Source File: IndexUpdateManager.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Fix up the current updates, given the pending mutation. * @param updates current updates * @param pendingMutation */ protected void fixUpCurrentUpdates(Collection<Mutation> updates, Mutation pendingMutation) { // need to check for each entry to see if we have a duplicate Mutation toRemove = null; Delete pendingDelete = pendingMutation instanceof Delete ? (Delete) pendingMutation : null; boolean sawRowMatch = false; for (Mutation stored : updates) { int compare = pendingMutation.compareTo(stored); // skip to the right row if (compare < 0) { continue; } else if (compare > 0) { if (sawRowMatch) { break; } continue; } // set that we saw a row match, so any greater row will necessarily be the wrong sawRowMatch = true; // skip until we hit the right timestamp if (stored.getTimeStamp() < pendingMutation.getTimeStamp()) { continue; } if (stored instanceof Delete) { // we already have a delete for this row, so we are done. if (pendingDelete != null) { return; } // pending update must be a Put, so we ignore the Put. // add a marker in the this delete that it has been canceled out already. We need to keep // the delete around though so we can figure out if other Puts would also be canceled out. markMutationForRemoval(stored); return; } // otherwise, the stored mutation is a Put. Either way, we want to remove it. If the pending // update is a delete, we need to remove the entry (no longer applies - covered by the // delete), or its an older version of the row, so we cover it with the newer. toRemove = stored; if (pendingDelete != null) { // the pending mutation, but we need to mark the mutation for removal later markMutationForRemoval(pendingMutation); break; } } updates.remove(toRemove); updates.add(pendingMutation); }