Skip to content

Commit

Permalink
PHOENIX-3698 No-args constructor for IndexedWALEditCodec
Browse files Browse the repository at this point in the history
Change-Id: Ic36c61a314e92aa9a8cdf496e210909abe5829dc
  • Loading branch information
joshelser committed Mar 1, 2017
1 parent cbc43bb commit 6d36fa7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit 6d36fa7

Please sign in to comment.