Review Board 1.6.3

scan can early exit for incrementColumnValue()

Review Request #1053 - updated 3 years, 6 months ago

khemani Reviewers
trunk hbase
HBASE-3082 jgray
None hbase
Ensure that during incrementColumnValue() the scan triggered by the get() does an early exit if it finds the KV in the memstore.
I have been testing it on my cluster. No unit testing yet.
src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Revision 0e3940c New Change
... 2846 lines hidden [Expand]
public Result get(final Get get, final Integer lockid) throws IOException {
2847
    List<KeyValue> result = get(get);
2847
    List<KeyValue> result = get(get);
2848

   
2848

   
2849
    return new Result(result);
2849
    return new Result(result);
2850
  }
2850
  }
2851

   
2851

   

   
2852
  /**

   
2853
   * This is modeled after {@link #get(Get)}. Unlike get it exits early if the target KV is

   
2854
   * found in the memstore. The assumption that the mem-store has the latest version of the KV is

   
2855
   * is true for {@link #incrementColumnValue(byte[], byte[], byte[], long, boolean)}

   
2856
   * @param get

   
2857
   * @return result

   
2858
   * @throws IOException

   
2859
   */

   
2860
  private List<KeyValue> getLastIncrement(final Get get) throws IOException {

   
2861
    InternalScan iscan = new InternalScan(get);

   
2862

   

   
2863

   

   
2864
    List<KeyValue> results = new ArrayList<KeyValue>();

   
2865

   

   
2866
    // memstore scan

   
2867
    iscan.checkOnlyMemStore();

   
2868
    InternalScanner scanner = null;

   
2869
    try {

   
2870
      scanner = getScanner(iscan);

   
2871
      scanner.next(results);

   
2872
    } finally {

   
2873
      if (scanner != null)

   
2874
        scanner.close();

   
2875
    }

   
2876

   

   
2877
    // For increments it is guaranteed that the result found in memstore is the latest version

   
2878
    if (! results.isEmpty()) {

   
2879
      return results;

   
2880
    }

   
2881

   

   
2882
    //store files scan

   
2883
    iscan.checkOnlyStoreFiles();

   
2884
    scanner = null;

   
2885
    try {

   
2886
      scanner = getScanner(iscan);

   
2887
      scanner.next(results);

   
2888
    } finally {

   
2889
      if (scanner != null)

   
2890
        scanner.close();

   
2891
    }

   
2892
    return results;

   
2893
  }

   
2894

   
2852
  /*
2895
  /*
2853
   * Do a get based on the get parameter.
2896
   * Do a get based on the get parameter.
2854
   */
2897
   */
2855
  private List<KeyValue> get(final Get get) throws IOException {
2898
  private List<KeyValue> get(final Get get) throws IOException {
2856
    Scan scan = new Scan(get);
2899
    Scan scan = new Scan(get);
... 36 lines hidden [Expand]
public long incrementColumnValue(byte [] row, byte [] family,
2893

   
2936

   
2894
        // Get the old value:
2937
        // Get the old value:
2895
        Get get = new Get(row);
2938
        Get get = new Get(row);
2896
        get.addColumn(family, qualifier);
2939
        get.addColumn(family, qualifier);
2897

   
2940

   
2898
        List<KeyValue> results = get(get);
2941
        List<KeyValue> results = getLastIncrement(get);
2899

   
2942

   
2900
        if (!results.isEmpty()) {
2943
        if (!results.isEmpty()) {
2901
          KeyValue kv = results.get(0);
2944
          KeyValue kv = results.get(0);
2902
          byte [] buffer = kv.getBuffer();
2945
          byte [] buffer = kv.getBuffer();
2903
          int valueOffset = kv.getValueOffset();
2946
          int valueOffset = kv.getValueOffset();
... 273 lines hidden [Expand]
src/main/java/org/apache/hadoop/hbase/regionserver/InternalScan.java
New File
 
src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
Revision 4775fc8 New Change
 
  1. src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java: Loading...
  2. src/main/java/org/apache/hadoop/hbase/regionserver/InternalScan.java: Loading...
  3. src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java: Loading...