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/6d36fa7c Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6d36fa7c Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6d36fa7c Branch: refs/heads/calcite Commit: 6d36fa7ca70200568e285aa513f0a577eaade060 Parents: cbc43bb Author: Josh Elser <[email protected]> Authored: Mon Feb 27 16:55:42 2017 -0500 Committer: Josh Elser <[email protected]> Committed: Tue Feb 28 19:54:51 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/6d36fa7c/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/6d36fa7c/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)); + } +}
