HBASE-24968 : Move META_COMPARATOR to subclass MetaCellComparator

* Break subclass referencing of MetaCellComparator from superclass CellComparatorImpl
  static initializer by moving META_COMPARATOR to subclass MetaCellComparator

Closes #2329

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Viraj Jasani 2020-08-30 21:59:41 +05:30
parent 2eb2c96960
commit 1c568ec95d
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
12 changed files with 192 additions and 160 deletions

View File

@ -17,16 +17,12 @@
*/
package org.apache.hadoop.hbase;
import java.nio.ByteBuffer;
import java.util.Comparator;
import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.primitives.Longs;
/**
* Compare two HBase cells. Do not use this method comparing <code>-ROOT-</code> or
@ -48,7 +44,6 @@ import org.apache.hbase.thirdparty.com.google.common.primitives.Longs;
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class CellComparatorImpl implements CellComparator {
static final Logger LOG = LoggerFactory.getLogger(CellComparatorImpl.class);
/**
* Comparator for plain key/values; i.e. non-catalog table key/values. Works on Key portion
@ -56,12 +51,6 @@ public class CellComparatorImpl implements CellComparator {
*/
public static final CellComparatorImpl COMPARATOR = new CellComparatorImpl();
/**
* A {@link CellComparatorImpl} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
*/
public static final CellComparatorImpl META_COMPARATOR = new MetaCellComparator();
@Override
public final int compare(final Cell a, final Cell b) {
return compare(a, b, false);
@ -213,7 +202,7 @@ public class CellComparatorImpl implements CellComparator {
/**
* Compares the row part of the cell with a simple plain byte[] like the
* stopRow in Scan. This should be used with context where for hbase:meta
* cells the {{@link #META_COMPARATOR} should be used
* cells the {{@link MetaCellComparator#META_COMPARATOR} should be used
*
* @param left
* the cell to be compared
@ -291,117 +280,6 @@ public class CellComparatorImpl implements CellComparator {
return Long.compare(rtimestamp, ltimestamp);
}
/**
* A {@link CellComparatorImpl} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
*/
public static class MetaCellComparator extends CellComparatorImpl {
// TODO: Do we need a ByteBufferKeyValue version of this?
@Override
public int compareRows(final Cell left, final Cell right) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
right.getRowArray(), right.getRowOffset(), right.getRowLength());
}
@Override
public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
roffset, rlength);
}
@Override
public int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
int diff = compareRows(a, b);
if (diff != 0) {
return diff;
}
diff = compareWithoutRow(a, b);
if (diff != 0) {
return diff;
}
// Negate following comparisons so later edits show up first mvccVersion: later sorts first
return ignoreSequenceid? diff: Longs.compare(b.getSequenceId(), a.getSequenceId());
}
private static int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset,
int rlength) {
int leftDelimiter = Bytes.searchDelimiterIndex(left, loffset, llength, HConstants.DELIMITER);
int rightDelimiter = Bytes
.searchDelimiterIndex(right, roffset, rlength, HConstants.DELIMITER);
// Compare up to the delimiter
int lpart = (leftDelimiter < 0 ? llength : leftDelimiter - loffset);
int rpart = (rightDelimiter < 0 ? rlength : rightDelimiter - roffset);
int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);
if (result != 0) {
return result;
} else {
if (leftDelimiter < 0 && rightDelimiter >= 0) {
return -1;
} else if (rightDelimiter < 0 && leftDelimiter >= 0) {
return 1;
} else if (leftDelimiter < 0) {
return 0;
}
}
// Compare middle bit of the row.
// Move past delimiter
leftDelimiter++;
rightDelimiter++;
int leftFarDelimiter = Bytes.searchDelimiterIndexInReverse(left, leftDelimiter, llength
- (leftDelimiter - loffset), HConstants.DELIMITER);
int rightFarDelimiter = Bytes.searchDelimiterIndexInReverse(right, rightDelimiter, rlength
- (rightDelimiter - roffset), HConstants.DELIMITER);
// Now compare middlesection of row.
lpart = (leftFarDelimiter < 0 ? llength + loffset : leftFarDelimiter) - leftDelimiter;
rpart = (rightFarDelimiter < 0 ? rlength + roffset : rightFarDelimiter) - rightDelimiter;
result = Bytes.compareTo(left, leftDelimiter, lpart, right, rightDelimiter, rpart);
if (result != 0) {
return result;
} else {
if (leftDelimiter < 0 && rightDelimiter >= 0) {
return -1;
} else if (rightDelimiter < 0 && leftDelimiter >= 0) {
return 1;
} else if (leftDelimiter < 0) {
return 0;
}
}
// Compare last part of row, the rowid.
leftFarDelimiter++;
rightFarDelimiter++;
result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset),
right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));
return result;
}
@Override
public int compareRows(ByteBuffer row, Cell cell) {
byte [] array;
int offset;
int len = row.remaining();
if (row.hasArray()) {
array = row.array();
offset = row.position() + row.arrayOffset();
} else {
// We copy the row array if offheap just so we can do a compare. We do this elsewhere too
// in BBUtils when Cell is backed by an offheap ByteBuffer. Needs fixing so no copy. TODO.
array = new byte[len];
offset = 0;
ByteBufferUtils.copyFromBufferToArray(array, row, row.position(),
0, len);
}
// Reverse result since we swap the order of the params we pass below.
return -compareRows(cell, array, offset, len);
}
@Override
public Comparator getSimpleComparator() {
return this;
}
}
@Override
public Comparator getSimpleComparator() {
return new BBKVComparator(this);
@ -424,6 +302,6 @@ public class CellComparatorImpl implements CellComparator {
public static CellComparator getCellComparator(byte [] tableName) {
// FYI, TableName.toBytes does not create an array; just returns existing array pointer.
return Bytes.equals(tableName, TableName.META_TABLE_NAME.toBytes())?
CellComparatorImpl.META_COMPARATOR: CellComparatorImpl.COMPARATOR;
MetaCellComparator.META_COMPARATOR: CellComparatorImpl.COMPARATOR;
}
}

View File

@ -104,7 +104,8 @@ public class KeyValue implements ExtendedCell, Cloneable {
/**
* A {@link KVComparator} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
* @deprecated Use {@link CellComparatorImpl#META_COMPARATOR} instead. Deprecated for hbase 2.0, remove for hbase 3.0.
* @deprecated Use {@link MetaCellComparator#META_COMPARATOR} instead.
* Deprecated for hbase 2.0, remove for hbase 3.0.
*/
@Deprecated
public static final KVComparator META_COMPARATOR = new MetaComparator();
@ -1606,7 +1607,8 @@ public class KeyValue implements ExtendedCell, Cloneable {
/**
* A {@link KVComparator} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
* @deprecated : {@link CellComparatorImpl#META_COMPARATOR} to be used. Deprecated for hbase 2.0, remove for hbase 3.0.
* @deprecated : {@link MetaCellComparator#META_COMPARATOR} to be used.
* Deprecated for hbase 2.0, remove for hbase 3.0.
*/
@Deprecated
public static class MetaComparator extends KVComparator {
@ -1616,7 +1618,8 @@ public class KeyValue implements ExtendedCell, Cloneable {
*/
@Override
public int compare(final Cell left, final Cell right) {
return PrivateCellUtil.compareKeyIgnoresMvcc(CellComparatorImpl.META_COMPARATOR, left, right);
return PrivateCellUtil.compareKeyIgnoresMvcc(MetaCellComparator.META_COMPARATOR, left,
right);
}
@Override

View File

@ -0,0 +1,150 @@
/*
* 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;
import java.nio.ByteBuffer;
import java.util.Comparator;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.hbase.thirdparty.com.google.common.primitives.Longs;
/**
* A {@link CellComparatorImpl} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
*/
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class MetaCellComparator extends CellComparatorImpl {
/**
* A {@link MetaCellComparator} for <code>hbase:meta</code> catalog table
* {@link KeyValue}s.
*/
public static final MetaCellComparator META_COMPARATOR = new MetaCellComparator();
// TODO: Do we need a ByteBufferKeyValue version of this?
@Override
public int compareRows(final Cell left, final Cell right) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
right.getRowArray(), right.getRowOffset(), right.getRowLength());
}
@Override
public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right, roffset,
rlength);
}
@Override
public int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
int diff = compareRows(a, b);
if (diff != 0) {
return diff;
}
diff = compareWithoutRow(a, b);
if (diff != 0) {
return diff;
}
// Negate following comparisons so later edits show up first mvccVersion: later sorts first
return ignoreSequenceid ? diff : Longs.compare(b.getSequenceId(), a.getSequenceId());
}
private static int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset,
int rlength) {
int leftDelimiter = Bytes.searchDelimiterIndex(left, loffset, llength, HConstants.DELIMITER);
int rightDelimiter = Bytes.searchDelimiterIndex(right, roffset, rlength, HConstants.DELIMITER);
// Compare up to the delimiter
int lpart = (leftDelimiter < 0 ? llength : leftDelimiter - loffset);
int rpart = (rightDelimiter < 0 ? rlength : rightDelimiter - roffset);
int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);
if (result != 0) {
return result;
} else {
if (leftDelimiter < 0 && rightDelimiter >= 0) {
return -1;
} else if (rightDelimiter < 0 && leftDelimiter >= 0) {
return 1;
} else if (leftDelimiter < 0) {
return 0;
}
}
// Compare middle bit of the row.
// Move past delimiter
leftDelimiter++;
rightDelimiter++;
int leftFarDelimiter = Bytes
.searchDelimiterIndexInReverse(left, leftDelimiter, llength - (leftDelimiter - loffset),
HConstants.DELIMITER);
int rightFarDelimiter = Bytes
.searchDelimiterIndexInReverse(right, rightDelimiter, rlength - (rightDelimiter - roffset),
HConstants.DELIMITER);
// Now compare middlesection of row.
lpart = (leftFarDelimiter < 0 ? llength + loffset : leftFarDelimiter) - leftDelimiter;
rpart = (rightFarDelimiter < 0 ? rlength + roffset : rightFarDelimiter) - rightDelimiter;
result = Bytes.compareTo(left, leftDelimiter, lpart, right, rightDelimiter, rpart);
if (result != 0) {
return result;
} else {
if (leftDelimiter < 0 && rightDelimiter >= 0) {
return -1;
} else if (rightDelimiter < 0 && leftDelimiter >= 0) {
return 1;
} else if (leftDelimiter < 0) {
return 0;
}
}
// Compare last part of row, the rowid.
leftFarDelimiter++;
rightFarDelimiter++;
result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset), right,
rightFarDelimiter, rlength - (rightFarDelimiter - roffset));
return result;
}
@Override
public int compareRows(ByteBuffer row, Cell cell) {
byte[] array;
int offset;
int len = row.remaining();
if (row.hasArray()) {
array = row.array();
offset = row.position() + row.arrayOffset();
} else {
// We copy the row array if offheap just so we can do a compare. We do this elsewhere too
// in BBUtils when Cell is backed by an offheap ByteBuffer. Needs fixing so no copy. TODO.
array = new byte[len];
offset = 0;
ByteBufferUtils.copyFromBufferToArray(array, row, row.position(), 0, len);
}
// Reverse result since we swap the order of the params we pass below.
return -compareRows(cell, array, offset, len);
}
@Override
public Comparator getSimpleComparator() {
return this;
}
}

View File

@ -146,7 +146,7 @@ public class TestCellComparator {
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now));
Cell bbb = createByteBufferKeyValueFromKeyValue(new KeyValue(
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now));
CellComparator c = CellComparatorImpl.META_COMPARATOR;
CellComparator c = MetaCellComparator.META_COMPARATOR;
assertTrue(c.compare(bbb, aaa) < 0);
Cell ccc = createByteBufferKeyValueFromKeyValue(
@ -177,7 +177,7 @@ public class TestCellComparator {
@Test
public void testMetaComparisons2() {
long now = System.currentTimeMillis();
CellComparator c = CellComparatorImpl.META_COMPARATOR;
CellComparator c = MetaCellComparator.META_COMPARATOR;
assertTrue(c.compare(createByteBufferKeyValueFromKeyValue(new KeyValue(
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",a,,0,1"), now)),
createByteBufferKeyValueFromKeyValue(new KeyValue(
@ -240,7 +240,7 @@ public class TestCellComparator {
}
assertTrue(assertion);
// Make set with good comparator
set = new TreeSet<>(CellComparatorImpl.META_COMPARATOR);
set = new TreeSet<>(MetaCellComparator.META_COMPARATOR);
Collections.addAll(set, keys);
count = 0;
for (Cell k: set) {

View File

@ -151,7 +151,7 @@ public class TestKeyValue {
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now);
KeyValue bbb = new KeyValue(
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now);
CellComparator c = CellComparatorImpl.META_COMPARATOR;
CellComparator c = MetaCellComparator.META_COMPARATOR;
assertTrue(c.compare(bbb, aaa) < 0);
KeyValue aaaa = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,,1236023996656"),
@ -166,14 +166,14 @@ public class TestKeyValue {
Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1236034574912L,
(byte[])null);
assertTrue(c.compare(x, y) < 0);
comparisons(CellComparatorImpl.META_COMPARATOR);
comparisons(MetaCellComparator.META_COMPARATOR);
comparisons(CellComparatorImpl.COMPARATOR);
metacomparisons(CellComparatorImpl.META_COMPARATOR);
metacomparisons(MetaCellComparator.META_COMPARATOR);
}
@Test
public void testMetaComparatorTableKeysWithCommaOk() {
CellComparator c = CellComparatorImpl.META_COMPARATOR;
CellComparator c = MetaCellComparator.META_COMPARATOR;
long now = System.currentTimeMillis();
// meta keys values are not quite right. A users can enter illegal values
// from shell when scanning meta.
@ -194,13 +194,13 @@ public class TestKeyValue {
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
KeyValue rowB = new KeyValue(Bytes.toBytes("testtable,www.hbase.org/%20,99999"),
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
assertTrue(CellComparatorImpl.META_COMPARATOR.compare(rowA, rowB) < 0);
assertTrue(MetaCellComparator.META_COMPARATOR.compare(rowA, rowB) < 0);
rowA = new KeyValue(Bytes.toBytes("testtable,,1234"), Bytes.toBytes("fam"),
Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
rowB = new KeyValue(Bytes.toBytes("testtable,$www.hbase.org/,99999"),
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
assertTrue(CellComparatorImpl.META_COMPARATOR.compare(rowA, rowB) < 0);
assertTrue(MetaCellComparator.META_COMPARATOR.compare(rowA, rowB) < 0);
}
private void metacomparisons(final CellComparatorImpl c) {
@ -264,7 +264,7 @@ public class TestKeyValue {
}
assertTrue(assertion);
// Make set with good comparator
set = new TreeSet<>(CellComparatorImpl.META_COMPARATOR);
set = new TreeSet<>(MetaCellComparator.META_COMPARATOR);
Collections.addAll(set, keys);
count = 0;
for (KeyValue k : set) {
@ -519,7 +519,7 @@ public class TestKeyValue {
@Test
public void testMetaKeyComparator() {
CellComparator c = CellComparatorImpl.META_COMPARATOR;
CellComparator c = MetaCellComparator.META_COMPARATOR;
long now = System.currentTimeMillis();
KeyValue a = new KeyValue(Bytes.toBytes("table1"), now);

View File

@ -29,8 +29,8 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
@ -613,8 +613,7 @@ public class FixedFileTrailer {
comparatorKlass = CellComparatorImpl.class;
} else if (comparatorClassName.equals(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName())
|| comparatorClassName.equals(KeyValue.META_COMPARATOR.getClass().getName())
|| (comparatorClassName
.equals("org.apache.hadoop.hbase.CellComparator$MetaCellComparator"))) {
|| (comparatorClassName.equals("org.apache.hadoop.hbase.MetaCellComparator"))) {
comparatorKlass = MetaCellComparator.class;
} else if (comparatorClassName.equals("org.apache.hadoop.hbase.KeyValue$RawBytesComparator")
|| comparatorClassName.equals("org.apache.hadoop.hbase.util.Bytes$ByteArrayComparator")) {
@ -636,8 +635,8 @@ public class FixedFileTrailer {
if (comparatorClassName.equals(CellComparatorImpl.COMPARATOR.getClass().getName())) {
return CellComparatorImpl.COMPARATOR;
} else if (comparatorClassName.equals(
CellComparatorImpl.META_COMPARATOR.getClass().getName())) {
return CellComparatorImpl.META_COMPARATOR;
MetaCellComparator.META_COMPARATOR.getClass().getName())) {
return MetaCellComparator.META_COMPARATOR;
}
try {
Class<? extends CellComparator> comparatorClass = getComparatorClass(comparatorClassName);

View File

@ -33,10 +33,10 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.crypto.Encryption;

View File

@ -82,7 +82,6 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
@ -94,6 +93,7 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.PrivateCellUtil;
@ -785,8 +785,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
this.conf = new CompoundConfiguration().add(confParam).addBytesMap(htd.getValues());
this.cellComparator = htd.isMetaTable() ||
conf.getBoolean(USE_META_CELL_COMPARATOR, DEFAULT_USE_META_CELL_COMPARATOR) ?
CellComparatorImpl.META_COMPARATOR :
CellComparatorImpl.COMPARATOR;
MetaCellComparator.META_COMPARATOR : CellComparatorImpl.COMPARATOR;
this.lock = new ReentrantReadWriteLock(conf.getBoolean(FAIR_REENTRANT_CLOSE_LOCK,
DEFAULT_FAIR_REENTRANT_CLOSE_LOCK));
this.flushCheckInterval = conf.getInt(MEMSTORE_PERIODIC_FLUSH_INTERVAL,

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
@ -91,7 +92,7 @@ public class BoundedRecoveredHFilesOutputSink extends OutputSink {
familyCells
.computeIfAbsent(familyName,
key -> new CellSet(
isMetaTable ? CellComparatorImpl.META_COMPARATOR : CellComparatorImpl.COMPARATOR))
isMetaTable ? MetaCellComparator.META_COMPARATOR : CellComparatorImpl.COMPARATOR))
.add(cell);
familySeqIds.compute(familyName, (k, v) -> v == null ? seqId : Math.max(v, seqId));
}
@ -201,7 +202,7 @@ public class BoundedRecoveredHFilesOutputSink extends OutputSink {
withChecksumType(HStore.getChecksumType(walSplitter.conf)).
withBytesPerCheckSum(HStore.getBytesPerChecksum(walSplitter.conf)).
withCellComparator(isMetaTable?
CellComparatorImpl.META_COMPARATOR: CellComparatorImpl.COMPARATOR).build();
MetaCellComparator.META_COMPARATOR: CellComparatorImpl.COMPARATOR).build();
return writerBuilder.withFileContext(hFileContext).build();
}
}

View File

@ -100,7 +100,7 @@ public class MetaMockingUtil {
}
//important: sort the kvs so that binary search work
Collections.sort(kvs, CellComparatorImpl.META_COMPARATOR);
Collections.sort(kvs, MetaCellComparator.META_COMPARATOR);
return Result.create(kvs);
}

View File

@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos;
import org.apache.hadoop.hbase.testclassification.IOTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@ -109,7 +110,7 @@ public class TestFixedFileTrailer {
assertEquals(CellComparatorImpl.COMPARATOR.getClass().getName(), t.getComparatorClassName());
HFileProtos.FileTrailerProto pb = t.toProtobuf();
assertEquals(KeyValue.COMPARATOR.getClass().getName(), pb.getComparatorClassName());
t.setComparatorClass(CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass());
t.setComparatorClass(MetaCellComparator.META_COMPARATOR.getClass());
pb = t.toProtobuf();
assertEquals(KeyValue.META_COMPARATOR.getClass().getName(),
pb.getComparatorClassName());
@ -125,16 +126,16 @@ public class TestFixedFileTrailer {
t.createComparator(KeyValue.COMPARATOR.getClass().getName()).getClass());
assertEquals(CellComparatorImpl.class,
t.createComparator(CellComparator.class.getName()).getClass());
assertEquals(CellComparatorImpl.MetaCellComparator.class,
assertEquals(MetaCellComparator.class,
t.createComparator(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName()).getClass());
assertEquals(CellComparatorImpl.MetaCellComparator.class,
assertEquals(MetaCellComparator.class,
t.createComparator(KeyValue.META_COMPARATOR.getClass().getName()).getClass());
assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(
CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
assertEquals(CellComparatorImpl.META_COMPARATOR.getClass(), t.createComparator(
CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
assertEquals(MetaCellComparator.class, t.createComparator(
MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
assertEquals(MetaCellComparator.META_COMPARATOR.getClass(), t.createComparator(
MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
assertEquals(CellComparatorImpl.COMPARATOR.getClass(), t.createComparator(
CellComparatorImpl.MetaCellComparator.COMPARATOR.getClass().getName()).getClass());
MetaCellComparator.COMPARATOR.getClass().getName()).getClass());
assertNull(t.createComparator(Bytes.BYTES_RAWCOMPARATOR.getClass().getName()));
assertNull(t.createComparator("org.apache.hadoop.hbase.KeyValue$RawBytesComparator"));
} catch (IOException e) {

View File

@ -61,6 +61,7 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.MetaCellComparator;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
@ -762,7 +763,7 @@ public class TestHFile {
// optimization done.
left = getCell(Bytes.toBytes("g"), Bytes.toBytes("a"), Bytes.toBytes("a"));
right = getCell(Bytes.toBytes("i"), Bytes.toBytes("a"), Bytes.toBytes("a"));
mid = HFileWriterImpl.getMidpoint(CellComparatorImpl.META_COMPARATOR, left, right);
mid = HFileWriterImpl.getMidpoint(MetaCellComparator.META_COMPARATOR, left, right);
assertTrue(PrivateCellUtil
.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, left, mid) < 0);
assertTrue(PrivateCellUtil
@ -809,7 +810,7 @@ public class TestHFile {
assertTrue(newKey.getTypeByte() == Type.Maximum.getCode());
// verify metaKeyComparator's getShortMidpointKey output
final CellComparatorImpl metaKeyComparator = CellComparatorImpl.META_COMPARATOR;
final CellComparatorImpl metaKeyComparator = MetaCellComparator.META_COMPARATOR;
kv1 = new KeyValue(Bytes.toBytes("ilovehbase123"), family, qualA, 5, Type.Put);
kv2 = new KeyValue(Bytes.toBytes("ilovehbase234"), family, qualA, 0, Type.Put);
newKey = HFileWriterImpl.getMidpoint(metaKeyComparator, kv1, kv2);