You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by el...@apache.org on 2017/03/01 00:55:47 UTC

[2/7] phoenix git commit: PHOENIX-3698 No-args constructor for IndexedWALEditCodec

PHOENIX-3698 No-args constructor for IndexedWALEditCodec

Change-Id: Ic36c61a314e92aa9a8cdf496e210909abe5829dc


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 31a2d9207f436558da81b7ad806b6e108e9ed357
Parents: f077be5
Author: Josh Elser <el...@apache.org>
Authored: Mon Feb 27 16:55:42 2017 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Tue Feb 28 19:03:59 2017 -0500

----------------------------------------------------------------------
 .../regionserver/wal/IndexedWALEditCodec.java   | 20 ++++++++++--
 .../wal/IndexedWALEditCodecTest.java            | 32 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/31a2d920/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java
index 1a70e12..80745a8 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodec.java
@@ -55,11 +55,27 @@ public class IndexedWALEditCodec extends WALCellCodec {
   private static final int MIN_BINARY_COMPATIBLE_INDEX_CODEC_VERSION = VersionUtil.encodeVersion("1", "1", "3");
   private final boolean useDefaultDecoder;
 
+  private static boolean isUseDefaultDecoder() {
+      String hbaseVersion = VersionInfo.getVersion();
+      return VersionUtil.encodeVersion(hbaseVersion) >= MIN_BINARY_COMPATIBLE_INDEX_CODEC_VERSION;
+  }
+
+  /*
+   * No-args constructor must be provided for WALSplitter/RPC Codec path
+   */
+  public IndexedWALEditCodec() {
+      super();
+      this.compression = null;
+      this.useDefaultDecoder = isUseDefaultDecoder();
+  }
+
+  /*
+   * Two-args Configuration and CompressionContext codec must be provided for WALCellCodec path
+   */
   public IndexedWALEditCodec(Configuration conf, CompressionContext compression) {
       super(conf, compression);
       this.compression = compression;
-      String hbaseVersion = VersionInfo.getVersion();
-      this.useDefaultDecoder = VersionUtil.encodeVersion(hbaseVersion) >= MIN_BINARY_COMPATIBLE_INDEX_CODEC_VERSION;
+      this.useDefaultDecoder = isUseDefaultDecoder();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/31a2d920/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodecTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodecTest.java b/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodecTest.java
new file mode 100644
index 0000000..ee726bb
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/wal/IndexedWALEditCodecTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.hadoop.hbase.regionserver.wal;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.io.util.LRUDictionary;
+import org.junit.Test;
+
+public class IndexedWALEditCodecTest {
+
+    @SuppressWarnings("unused")
+    @Test
+    public void testConstructorsArePresent() throws Exception {
+        // "testing" via the presence of these constructors
+        IndexedWALEditCodec codec1 = new IndexedWALEditCodec();
+        IndexedWALEditCodec codec2 = new IndexedWALEditCodec(new Configuration(false), new CompressionContext(LRUDictionary.class, false, false));
+    }
+}