phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/3] phoenix git commit: PHOENIX-2774 MemStoreScanner and KeyValueStore should not be aware of KeyValueScanner (Churro Morales)
Date Mon, 28 Mar 2016 15:35:21 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master cd8e86ca7 -> 64fdf840b


PHOENIX-2774 MemStoreScanner and KeyValueStore should not be aware of KeyValueScanner (Churro
Morales)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/bea110c8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/bea110c8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/bea110c8

Branch: refs/heads/master
Commit: bea110c8e70e26514aa658fb2b02d38d215ae6b4
Parents: cd8e86c
Author: James Taylor <jtaylor@salesforce.com>
Authored: Mon Mar 28 08:21:16 2016 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Mon Mar 28 08:21:16 2016 -0700

----------------------------------------------------------------------
 .../hbase/index/covered/KeyValueStore.java      |  4 +-
 .../hbase/index/covered/LocalTableState.java    | 27 ------------
 .../hbase/index/covered/data/IndexMemStore.java | 43 +++-----------------
 .../index/scanner/FilteredKeyValueScanner.java  | 11 +++--
 .../hbase/index/scanner/ReseekableScanner.java  | 28 +++++++++++++
 .../hbase/index/scanner/ScannerBuilder.java     |  2 +-
 .../index/covered/data/TestIndexMemStore.java   |  6 +--
 7 files changed, 44 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/KeyValueStore.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/KeyValueStore.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/KeyValueStore.java
index 39f9062..30d2904 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/KeyValueStore.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/KeyValueStore.java
@@ -18,7 +18,7 @@
 package org.apache.phoenix.hbase.index.covered;
 
 import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
+import org.apache.phoenix.hbase.index.scanner.ReseekableScanner;
 
 /**
  * Store a collection of KeyValues in memory.
@@ -27,7 +27,7 @@ public interface KeyValueStore {
 
   public void add(KeyValue kv, boolean overwrite);
 
-  public KeyValueScanner getScanner();
+  public ReseekableScanner getScanner();
 
   public void rollback(KeyValue kv);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/LocalTableState.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/LocalTableState.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/LocalTableState.java
index 2739cc2..3a7a7eb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/LocalTableState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/LocalTableState.java
@@ -194,33 +194,6 @@ public class LocalTableState implements TableState {
         return this.update.getRow();
     }
 
-    public Result getCurrentRowState() {
-        KeyValueScanner scanner = this.memstore.getScanner();
-        List<Cell> kvs = new ArrayList<Cell>();
-        while (scanner.peek() != null) {
-            try {
-                kvs.add(scanner.next());
-            } catch (IOException e) {
-                // this should never happen - something has gone terribly arwy if it has
-                throw new RuntimeException("Local MemStore threw IOException!");
-            }
-        }
-        return Result.create(kvs);
-    }
-
-    /**
-     * Helper to add a {@link Mutation} to the values stored for the current row
-     * 
-     * @param pendingUpdate
-     *            update to apply
-     */
-    public void addUpdateForTesting(Mutation pendingUpdate) {
-        for (Map.Entry<byte[], List<Cell>> e : pendingUpdate.getFamilyCellMap().entrySet())
{
-        	List<KeyValue> edits = KeyValueUtil.ensureKeyValues(e.getValue());
-            addUpdate(edits);
-        }
-    }
-
     /**
      * @param hints
      */

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java
index 7ae54ad..c7c5e3a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java
@@ -17,7 +17,6 @@
  */
 package org.apache.phoenix.hbase.index.covered.data;
 
-import java.io.IOException;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.SortedSet;
@@ -30,13 +29,12 @@ import org.apache.hadoop.hbase.KeyValue.KVComparator;
 import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.regionserver.IndexKeyValueSkipListSet;
-import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
 import org.apache.hadoop.hbase.regionserver.MemStore;
-import org.apache.hadoop.hbase.regionserver.NonLazyKeyValueScanner;
 import org.apache.hadoop.hbase.util.Bytes;
 
 import org.apache.phoenix.hbase.index.covered.KeyValueStore;
 import org.apache.phoenix.hbase.index.covered.LocalTableState;
+import org.apache.phoenix.hbase.index.scanner.ReseekableScanner;
 
 /**
  * Like the HBase {@link MemStore}, but without all that extra work around maintaining snapshots
and
@@ -55,7 +53,7 @@ import org.apache.phoenix.hbase.index.covered.LocalTableState;
  *  <li>ignoring memstore timestamps in favor of deciding when we want to overwrite
keys based on how
  *    we obtain them</li>
  *   <li>ignoring time range updates (so 
- *    {@link KeyValueScanner#shouldUseScanner(Scan, SortedSet, long)} isn't supported from

+ *    {@link ReseekableScanner#shouldUseScanner(Scan, SortedSet, long)} isn't supported from
  *    {@link #getScanner()}).</li>
  * </ol>
  * <p>
@@ -158,19 +156,19 @@ public class IndexMemStore implements KeyValueStore {
   }
 
   @Override
-  public KeyValueScanner getScanner() {
+  public ReseekableScanner getScanner() {
     return new MemStoreScanner();
   }
   
   /*
-   * MemStoreScanner implements the KeyValueScanner. It lets the caller scan the contents
of a
+   * MemStoreScanner implements the ReseekableScanner. It lets the caller scan the contents
of a
    * memstore -- both current map and snapshot. This behaves as if it were a real scanner
but does
    * not maintain position.
    */
   // This class is adapted from org.apache.hadoop.hbase.MemStore.MemStoreScanner, HBase 0.94.12
   // It does basically the same thing as the MemStoreScanner, but it only keeps track of
a single
   // set, rather than a primary and a secondary set of KeyValues.
-  protected class MemStoreScanner extends NonLazyKeyValueScanner {
+  protected class MemStoreScanner implements ReseekableScanner {
     // Next row information for the set
     private KeyValue nextRow = null;
 
@@ -276,7 +274,6 @@ public class IndexMemStore implements KeyValueStore {
 
     @Override
     public synchronized Cell peek() {
-      // DebugPrint.println(" MS@" + hashCode() + " peek = " + getLowest());
       return nextRow;
     }
 
@@ -300,35 +297,5 @@ public class IndexMemStore implements KeyValueStore {
       this.kvsetIt = null;
       this.kvsetItRow = null;
     }
-
-    /**
-     * MemStoreScanner returns max value as sequence id because it will always have the latest
data
-     * among all files.
-     */
-    @Override
-    public long getSequenceID() {
-      return Long.MAX_VALUE;
-    }
-    
-    @Override
-    public boolean shouldUseScanner(Scan scan, SortedSet<byte[]> columns, long oldestUnexpiredTS)
{
-      throw new UnsupportedOperationException(this.getClass().getName()
-          + " doesn't support checking to see if it should use a scanner!");
-    }
-
-    @Override
-    public boolean backwardSeek(Cell arg0) throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean seekToLastRow() throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean seekToPreviousRow(Cell arg0) throws IOException {
-        throw new UnsupportedOperationException();
-    }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/FilteredKeyValueScanner.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/FilteredKeyValueScanner.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/FilteredKeyValueScanner.java
index a1cbd61..072b624 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/FilteredKeyValueScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/FilteredKeyValueScanner.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.Filter.ReturnCode;
-import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
 import org.apache.phoenix.hbase.index.covered.KeyValueStore;
 
 /**
@@ -33,22 +32,22 @@ import org.apache.phoenix.hbase.index.covered.KeyValueStore;
  * here because we are only concerned with a single MemStore for the index; we don't need
to worry about multiple column
  * families or minimizing seeking through file - we just want to iterate the kvs quickly,
in-memory.
  */
-public class FilteredKeyValueScanner implements Scanner {
+public class FilteredKeyValueScanner implements ReseekableScanner {
 
-    private KeyValueScanner delegate;
+    private ReseekableScanner delegate;
     private Filter filter;
 
     public FilteredKeyValueScanner(Filter filter, KeyValueStore store) {
         this(filter, store.getScanner());
     }
 
-    private FilteredKeyValueScanner(Filter filter, KeyValueScanner delegate) {
+    private FilteredKeyValueScanner(Filter filter, ReseekableScanner delegate) {
         this.delegate = delegate;
         this.filter = filter;
     }
 
     @Override
-    public Cell peek() {
+    public Cell peek() throws IOException {
         return delegate.peek();
     }
 
@@ -107,7 +106,7 @@ public class FilteredKeyValueScanner implements Scanner {
 
 
     @Override
-    public void close() {
+    public void close() throws IOException {
         this.delegate.close();
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ReseekableScanner.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ReseekableScanner.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ReseekableScanner.java
new file mode 100644
index 0000000..cc82fb6
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ReseekableScanner.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.hbase.index.scanner;
+
+import org.apache.hadoop.hbase.Cell;
+
+import java.io.IOException;
+
+public interface ReseekableScanner extends Scanner {
+
+  boolean reseek(Cell key) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ScannerBuilder.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ScannerBuilder.java
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ScannerBuilder.java
index 330cb0e..f8d0cf1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ScannerBuilder.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/scanner/ScannerBuilder.java
@@ -159,7 +159,7 @@ public class ScannerBuilder {
       }
 
       @Override
-      public void close() {
+      public void close() throws IOException {
         kvScanner.close();
       }
     };

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bea110c8/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/data/TestIndexMemStore.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/data/TestIndexMemStore.java
b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/data/TestIndexMemStore.java
index 42e0b03..400757d 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/data/TestIndexMemStore.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/data/TestIndexMemStore.java
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertTrue;
 
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValue.Type;
-import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.hbase.index.scanner.ReseekableScanner;
 import org.junit.Test;
 
 public class TestIndexMemStore {
@@ -45,7 +45,7 @@ public class TestIndexMemStore {
     store.add(kv, true);
     // adding the exact same kv shouldn't change anything stored if not overwritting
     store.add(kv2, false);
-    KeyValueScanner scanner = store.getScanner();
+    ReseekableScanner scanner = store.getScanner();
     KeyValue first = KeyValue.createFirstOnRow(row);
     scanner.seek(first);
     assertTrue("Overwrote kv when specifically not!", kv == scanner.next());
@@ -79,7 +79,7 @@ public class TestIndexMemStore {
     store.add(d, true);
 
     // null qualifiers should always sort before the non-null cases
-    KeyValueScanner scanner = store.getScanner();
+    ReseekableScanner scanner = store.getScanner();
     KeyValue first = KeyValue.createFirstOnRow(row);
     assertTrue("Didn't have any data in the scanner", scanner.seek(first));
     assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next());


Mime
View raw message