HBASE-24968 : Move META_COMPARATOR to subclass MetaCellComparator (#2332)
* 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:
parent
ad177059cf
commit
859bf3ea9a
|
@ -45,6 +45,7 @@ import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HRegionLocation;
|
import org.apache.hadoop.hbase.HRegionLocation;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
|
import org.apache.hadoop.hbase.MetaCellComparator;
|
||||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||||
import org.apache.hadoop.hbase.RegionLocations;
|
import org.apache.hadoop.hbase.RegionLocations;
|
||||||
import org.apache.hadoop.hbase.RegionTooBusyException;
|
import org.apache.hadoop.hbase.RegionTooBusyException;
|
||||||
|
@ -683,7 +684,7 @@ public class TestClientNoCluster extends Configured implements Tool {
|
||||||
* Comparator for meta row keys.
|
* Comparator for meta row keys.
|
||||||
*/
|
*/
|
||||||
private static class MetaRowsComparator implements Comparator<byte []> {
|
private static class MetaRowsComparator implements Comparator<byte []> {
|
||||||
private final CellComparatorImpl delegate = CellComparatorImpl.META_COMPARATOR;
|
private final CellComparatorImpl delegate = MetaCellComparator.META_COMPARATOR;
|
||||||
@Override
|
@Override
|
||||||
public int compare(byte[] left, byte[] right) {
|
public int compare(byte[] left, byte[] right) {
|
||||||
return delegate.compareRows(new KeyValue.KeyOnlyKeyValue(left), right, 0, right.length);
|
return delegate.compareRows(new KeyValue.KeyOnlyKeyValue(left), right, 0, right.length);
|
||||||
|
|
|
@ -17,16 +17,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase;
|
package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import org.apache.hadoop.hbase.KeyValue.Type;
|
import org.apache.hadoop.hbase.KeyValue.Type;
|
||||||
import org.apache.hadoop.hbase.util.ByteBufferUtils;
|
import org.apache.hadoop.hbase.util.ByteBufferUtils;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.apache.yetus.audience.InterfaceStability;
|
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
|
* 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
|
@InterfaceAudience.Private
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class CellComparatorImpl implements CellComparator {
|
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
|
* 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();
|
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
|
@Override
|
||||||
public final int compare(final Cell a, final Cell b) {
|
public final int compare(final Cell a, final Cell b) {
|
||||||
return compare(a, b, false);
|
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
|
* 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
|
* 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
|
* @param left
|
||||||
* the cell to be compared
|
* the cell to be compared
|
||||||
|
@ -291,117 +280,6 @@ public class CellComparatorImpl implements CellComparator {
|
||||||
return Long.compare(rtimestamp, ltimestamp);
|
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
|
@Override
|
||||||
public Comparator getSimpleComparator() {
|
public Comparator getSimpleComparator() {
|
||||||
return new BBKVComparator(this);
|
return new BBKVComparator(this);
|
||||||
|
@ -424,6 +302,6 @@ public class CellComparatorImpl implements CellComparator {
|
||||||
public static CellComparator getCellComparator(byte [] tableName) {
|
public static CellComparator getCellComparator(byte [] tableName) {
|
||||||
// FYI, TableName.toBytes does not create an array; just returns existing array pointer.
|
// FYI, TableName.toBytes does not create an array; just returns existing array pointer.
|
||||||
return Bytes.equals(tableName, TableName.META_TABLE_NAME.toBytes())?
|
return Bytes.equals(tableName, TableName.META_TABLE_NAME.toBytes())?
|
||||||
CellComparatorImpl.META_COMPARATOR: CellComparatorImpl.COMPARATOR;
|
MetaCellComparator.META_COMPARATOR: CellComparatorImpl.COMPARATOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,8 @@ public class KeyValue implements ExtendedCell, Cloneable {
|
||||||
/**
|
/**
|
||||||
* A {@link KVComparator} for <code>hbase:meta</code> catalog table
|
* A {@link KVComparator} for <code>hbase:meta</code> catalog table
|
||||||
* {@link KeyValue}s.
|
* {@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
|
@Deprecated
|
||||||
public static final KVComparator META_COMPARATOR = new MetaComparator();
|
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
|
* A {@link KVComparator} for <code>hbase:meta</code> catalog table
|
||||||
* {@link KeyValue}s.
|
* {@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
|
@Deprecated
|
||||||
public static class MetaComparator extends KVComparator {
|
public static class MetaComparator extends KVComparator {
|
||||||
|
@ -1616,7 +1618,8 @@ public class KeyValue implements ExtendedCell, Cloneable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Cell left, final Cell right) {
|
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
|
@Override
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -146,7 +146,7 @@ public class TestCellComparator {
|
||||||
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now));
|
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now));
|
||||||
Cell bbb = createByteBufferKeyValueFromKeyValue(new KeyValue(
|
Cell bbb = createByteBufferKeyValueFromKeyValue(new KeyValue(
|
||||||
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now));
|
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now));
|
||||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
CellComparator c = MetaCellComparator.META_COMPARATOR;
|
||||||
assertTrue(c.compare(bbb, aaa) < 0);
|
assertTrue(c.compare(bbb, aaa) < 0);
|
||||||
|
|
||||||
Cell ccc = createByteBufferKeyValueFromKeyValue(
|
Cell ccc = createByteBufferKeyValueFromKeyValue(
|
||||||
|
@ -177,7 +177,7 @@ public class TestCellComparator {
|
||||||
@Test
|
@Test
|
||||||
public void testMetaComparisons2() {
|
public void testMetaComparisons2() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
CellComparator c = MetaCellComparator.META_COMPARATOR;
|
||||||
assertTrue(c.compare(createByteBufferKeyValueFromKeyValue(new KeyValue(
|
assertTrue(c.compare(createByteBufferKeyValueFromKeyValue(new KeyValue(
|
||||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",a,,0,1"), now)),
|
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",a,,0,1"), now)),
|
||||||
createByteBufferKeyValueFromKeyValue(new KeyValue(
|
createByteBufferKeyValueFromKeyValue(new KeyValue(
|
||||||
|
@ -240,7 +240,7 @@ public class TestCellComparator {
|
||||||
}
|
}
|
||||||
assertTrue(assertion);
|
assertTrue(assertion);
|
||||||
// Make set with good comparator
|
// Make set with good comparator
|
||||||
set = new TreeSet<>(CellComparatorImpl.META_COMPARATOR);
|
set = new TreeSet<>(MetaCellComparator.META_COMPARATOR);
|
||||||
Collections.addAll(set, keys);
|
Collections.addAll(set, keys);
|
||||||
count = 0;
|
count = 0;
|
||||||
for (Cell k: set) {
|
for (Cell k: set) {
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class TestKeyValue {
|
||||||
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now);
|
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now);
|
||||||
KeyValue bbb = new KeyValue(
|
KeyValue bbb = new KeyValue(
|
||||||
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now);
|
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now);
|
||||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
CellComparator c = MetaCellComparator.META_COMPARATOR;
|
||||||
assertTrue(c.compare(bbb, aaa) < 0);
|
assertTrue(c.compare(bbb, aaa) < 0);
|
||||||
|
|
||||||
KeyValue aaaa = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,,1236023996656"),
|
KeyValue aaaa = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,,1236023996656"),
|
||||||
|
@ -166,14 +166,14 @@ public class TestKeyValue {
|
||||||
Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1236034574912L,
|
Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1236034574912L,
|
||||||
(byte[])null);
|
(byte[])null);
|
||||||
assertTrue(c.compare(x, y) < 0);
|
assertTrue(c.compare(x, y) < 0);
|
||||||
comparisons(CellComparatorImpl.META_COMPARATOR);
|
comparisons(MetaCellComparator.META_COMPARATOR);
|
||||||
comparisons(CellComparatorImpl.COMPARATOR);
|
comparisons(CellComparatorImpl.COMPARATOR);
|
||||||
metacomparisons(CellComparatorImpl.META_COMPARATOR);
|
metacomparisons(MetaCellComparator.META_COMPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetaComparatorTableKeysWithCommaOk() {
|
public void testMetaComparatorTableKeysWithCommaOk() {
|
||||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
CellComparator c = MetaCellComparator.META_COMPARATOR;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
// meta keys values are not quite right. A users can enter illegal values
|
// meta keys values are not quite right. A users can enter illegal values
|
||||||
// from shell when scanning meta.
|
// from shell when scanning meta.
|
||||||
|
@ -194,13 +194,13 @@ public class TestKeyValue {
|
||||||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
||||||
KeyValue rowB = new KeyValue(Bytes.toBytes("testtable,www.hbase.org/%20,99999"),
|
KeyValue rowB = new KeyValue(Bytes.toBytes("testtable,www.hbase.org/%20,99999"),
|
||||||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
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"),
|
rowA = new KeyValue(Bytes.toBytes("testtable,,1234"), Bytes.toBytes("fam"),
|
||||||
Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
||||||
rowB = new KeyValue(Bytes.toBytes("testtable,$www.hbase.org/,99999"),
|
rowB = new KeyValue(Bytes.toBytes("testtable,$www.hbase.org/,99999"),
|
||||||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
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) {
|
private void metacomparisons(final CellComparatorImpl c) {
|
||||||
|
@ -264,7 +264,7 @@ public class TestKeyValue {
|
||||||
}
|
}
|
||||||
assertTrue(assertion);
|
assertTrue(assertion);
|
||||||
// Make set with good comparator
|
// Make set with good comparator
|
||||||
set = new TreeSet<>(CellComparatorImpl.META_COMPARATOR);
|
set = new TreeSet<>(MetaCellComparator.META_COMPARATOR);
|
||||||
Collections.addAll(set, keys);
|
Collections.addAll(set, keys);
|
||||||
count = 0;
|
count = 0;
|
||||||
for (KeyValue k : set) {
|
for (KeyValue k : set) {
|
||||||
|
@ -519,7 +519,7 @@ public class TestKeyValue {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetaKeyComparator() {
|
public void testMetaKeyComparator() {
|
||||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
CellComparator c = MetaCellComparator.META_COMPARATOR;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
KeyValue a = new KeyValue(Bytes.toBytes("table1"), now);
|
KeyValue a = new KeyValue(Bytes.toBytes("table1"), now);
|
||||||
|
|
|
@ -29,8 +29,8 @@ import java.nio.ByteBuffer;
|
||||||
import org.apache.hadoop.fs.FSDataInputStream;
|
import org.apache.hadoop.fs.FSDataInputStream;
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl;
|
import org.apache.hadoop.hbase.CellComparatorImpl;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
|
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
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.io.compress.Compression;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
@ -613,8 +613,7 @@ public class FixedFileTrailer {
|
||||||
comparatorKlass = CellComparatorImpl.class;
|
comparatorKlass = CellComparatorImpl.class;
|
||||||
} else if (comparatorClassName.equals(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName())
|
} else if (comparatorClassName.equals(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName())
|
||||||
|| comparatorClassName.equals(KeyValue.META_COMPARATOR.getClass().getName())
|
|| comparatorClassName.equals(KeyValue.META_COMPARATOR.getClass().getName())
|
||||||
|| (comparatorClassName
|
|| (comparatorClassName.equals("org.apache.hadoop.hbase.MetaCellComparator"))) {
|
||||||
.equals("org.apache.hadoop.hbase.CellComparator$MetaCellComparator"))) {
|
|
||||||
comparatorKlass = MetaCellComparator.class;
|
comparatorKlass = MetaCellComparator.class;
|
||||||
} else if (comparatorClassName.equals("org.apache.hadoop.hbase.KeyValue$RawBytesComparator")
|
} else if (comparatorClassName.equals("org.apache.hadoop.hbase.KeyValue$RawBytesComparator")
|
||||||
|| comparatorClassName.equals("org.apache.hadoop.hbase.util.Bytes$ByteArrayComparator")) {
|
|| comparatorClassName.equals("org.apache.hadoop.hbase.util.Bytes$ByteArrayComparator")) {
|
||||||
|
@ -636,8 +635,8 @@ public class FixedFileTrailer {
|
||||||
if (comparatorClassName.equals(CellComparatorImpl.COMPARATOR.getClass().getName())) {
|
if (comparatorClassName.equals(CellComparatorImpl.COMPARATOR.getClass().getName())) {
|
||||||
return CellComparatorImpl.COMPARATOR;
|
return CellComparatorImpl.COMPARATOR;
|
||||||
} else if (comparatorClassName.equals(
|
} else if (comparatorClassName.equals(
|
||||||
CellComparatorImpl.META_COMPARATOR.getClass().getName())) {
|
MetaCellComparator.META_COMPARATOR.getClass().getName())) {
|
||||||
return CellComparatorImpl.META_COMPARATOR;
|
return MetaCellComparator.META_COMPARATOR;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class<? extends CellComparator> comparatorClass = getComparatorClass(comparatorClassName);
|
Class<? extends CellComparator> comparatorClass = getComparatorClass(comparatorClassName);
|
||||||
|
|
|
@ -33,10 +33,10 @@ import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
|
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
|
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||||
|
import org.apache.hadoop.hbase.MetaCellComparator;
|
||||||
import org.apache.hadoop.hbase.PrivateCellUtil;
|
import org.apache.hadoop.hbase.PrivateCellUtil;
|
||||||
import org.apache.hadoop.hbase.io.compress.Compression;
|
import org.apache.hadoop.hbase.io.compress.Compression;
|
||||||
import org.apache.hadoop.hbase.io.crypto.Encryption;
|
import org.apache.hadoop.hbase.io.crypto.Encryption;
|
||||||
|
|
|
@ -82,7 +82,6 @@ import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellBuilderType;
|
import org.apache.hadoop.hbase.CellBuilderType;
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl;
|
import org.apache.hadoop.hbase.CellComparatorImpl;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl.MetaCellComparator;
|
|
||||||
import org.apache.hadoop.hbase.CellScanner;
|
import org.apache.hadoop.hbase.CellScanner;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.CompareOperator;
|
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.HConstants.OperationStatusCode;
|
||||||
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
|
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
|
import org.apache.hadoop.hbase.MetaCellComparator;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||||
import org.apache.hadoop.hbase.NotServingRegionException;
|
import org.apache.hadoop.hbase.NotServingRegionException;
|
||||||
import org.apache.hadoop.hbase.PrivateCellUtil;
|
import org.apache.hadoop.hbase.PrivateCellUtil;
|
||||||
|
@ -780,8 +780,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
this.conf = new CompoundConfiguration().add(confParam).addBytesMap(htd.getValues());
|
this.conf = new CompoundConfiguration().add(confParam).addBytesMap(htd.getValues());
|
||||||
this.cellComparator = htd.isMetaTable() ||
|
this.cellComparator = htd.isMetaTable() ||
|
||||||
conf.getBoolean(USE_META_CELL_COMPARATOR, DEFAULT_USE_META_CELL_COMPARATOR) ?
|
conf.getBoolean(USE_META_CELL_COMPARATOR, DEFAULT_USE_META_CELL_COMPARATOR) ?
|
||||||
CellComparatorImpl.META_COMPARATOR :
|
MetaCellComparator.META_COMPARATOR : CellComparatorImpl.COMPARATOR;
|
||||||
CellComparatorImpl.COMPARATOR;
|
|
||||||
this.lock = new ReentrantReadWriteLock(conf.getBoolean(FAIR_REENTRANT_CLOSE_LOCK,
|
this.lock = new ReentrantReadWriteLock(conf.getBoolean(FAIR_REENTRANT_CLOSE_LOCK,
|
||||||
DEFAULT_FAIR_REENTRANT_CLOSE_LOCK));
|
DEFAULT_FAIR_REENTRANT_CLOSE_LOCK));
|
||||||
this.flushCheckInterval = conf.getInt(MEMSTORE_PERIODIC_FLUSH_INTERVAL,
|
this.flushCheckInterval = conf.getInt(MEMSTORE_PERIODIC_FLUSH_INTERVAL,
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellComparatorImpl;
|
import org.apache.hadoop.hbase.CellComparatorImpl;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
|
import org.apache.hadoop.hbase.MetaCellComparator;
|
||||||
import org.apache.hadoop.hbase.PrivateCellUtil;
|
import org.apache.hadoop.hbase.PrivateCellUtil;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
|
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
|
||||||
|
@ -91,7 +92,7 @@ public class BoundedRecoveredHFilesOutputSink extends OutputSink {
|
||||||
familyCells
|
familyCells
|
||||||
.computeIfAbsent(familyName,
|
.computeIfAbsent(familyName,
|
||||||
key -> new CellSet(
|
key -> new CellSet(
|
||||||
isMetaTable ? CellComparatorImpl.META_COMPARATOR : CellComparatorImpl.COMPARATOR))
|
isMetaTable ? MetaCellComparator.META_COMPARATOR : CellComparatorImpl.COMPARATOR))
|
||||||
.add(cell);
|
.add(cell);
|
||||||
familySeqIds.compute(familyName, (k, v) -> v == null ? seqId : Math.max(v, seqId));
|
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)).
|
withChecksumType(HStore.getChecksumType(walSplitter.conf)).
|
||||||
withBytesPerCheckSum(HStore.getBytesPerChecksum(walSplitter.conf)).
|
withBytesPerCheckSum(HStore.getBytesPerChecksum(walSplitter.conf)).
|
||||||
withCellComparator(isMetaTable?
|
withCellComparator(isMetaTable?
|
||||||
CellComparatorImpl.META_COMPARATOR: CellComparatorImpl.COMPARATOR).build();
|
MetaCellComparator.META_COMPARATOR: CellComparatorImpl.COMPARATOR).build();
|
||||||
return writerBuilder.withFileContext(hFileContext).build();
|
return writerBuilder.withFileContext(hFileContext).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class MetaMockingUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
//important: sort the kvs so that binary search work
|
//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);
|
return Result.create(kvs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.CellComparatorImpl;
|
||||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
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.shaded.protobuf.generated.HFileProtos;
|
||||||
import org.apache.hadoop.hbase.testclassification.IOTests;
|
import org.apache.hadoop.hbase.testclassification.IOTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
@ -109,7 +110,7 @@ public class TestFixedFileTrailer {
|
||||||
assertEquals(CellComparatorImpl.COMPARATOR.getClass().getName(), t.getComparatorClassName());
|
assertEquals(CellComparatorImpl.COMPARATOR.getClass().getName(), t.getComparatorClassName());
|
||||||
HFileProtos.FileTrailerProto pb = t.toProtobuf();
|
HFileProtos.FileTrailerProto pb = t.toProtobuf();
|
||||||
assertEquals(KeyValue.COMPARATOR.getClass().getName(), pb.getComparatorClassName());
|
assertEquals(KeyValue.COMPARATOR.getClass().getName(), pb.getComparatorClassName());
|
||||||
t.setComparatorClass(CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass());
|
t.setComparatorClass(MetaCellComparator.META_COMPARATOR.getClass());
|
||||||
pb = t.toProtobuf();
|
pb = t.toProtobuf();
|
||||||
assertEquals(KeyValue.META_COMPARATOR.getClass().getName(),
|
assertEquals(KeyValue.META_COMPARATOR.getClass().getName(),
|
||||||
pb.getComparatorClassName());
|
pb.getComparatorClassName());
|
||||||
|
@ -125,16 +126,16 @@ public class TestFixedFileTrailer {
|
||||||
t.createComparator(KeyValue.COMPARATOR.getClass().getName()).getClass());
|
t.createComparator(KeyValue.COMPARATOR.getClass().getName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.class,
|
assertEquals(CellComparatorImpl.class,
|
||||||
t.createComparator(CellComparator.class.getName()).getClass());
|
t.createComparator(CellComparator.class.getName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.MetaCellComparator.class,
|
assertEquals(MetaCellComparator.class,
|
||||||
t.createComparator(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName()).getClass());
|
t.createComparator(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.MetaCellComparator.class,
|
assertEquals(MetaCellComparator.class,
|
||||||
t.createComparator(KeyValue.META_COMPARATOR.getClass().getName()).getClass());
|
t.createComparator(KeyValue.META_COMPARATOR.getClass().getName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(
|
assertEquals(MetaCellComparator.class, t.createComparator(
|
||||||
CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
|
MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.META_COMPARATOR.getClass(), t.createComparator(
|
assertEquals(MetaCellComparator.META_COMPARATOR.getClass(), t.createComparator(
|
||||||
CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
|
MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass());
|
||||||
assertEquals(CellComparatorImpl.COMPARATOR.getClass(), t.createComparator(
|
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(Bytes.BYTES_RAWCOMPARATOR.getClass().getName()));
|
||||||
assertNull(t.createComparator("org.apache.hadoop.hbase.KeyValue$RawBytesComparator"));
|
assertNull(t.createComparator("org.apache.hadoop.hbase.KeyValue$RawBytesComparator"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -60,6 +60,7 @@ import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.KeyValue.Type;
|
import org.apache.hadoop.hbase.KeyValue.Type;
|
||||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||||
|
import org.apache.hadoop.hbase.MetaCellComparator;
|
||||||
import org.apache.hadoop.hbase.PrivateCellUtil;
|
import org.apache.hadoop.hbase.PrivateCellUtil;
|
||||||
import org.apache.hadoop.hbase.Tag;
|
import org.apache.hadoop.hbase.Tag;
|
||||||
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
|
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
|
||||||
|
@ -736,7 +737,7 @@ public class TestHFile {
|
||||||
// optimization done.
|
// optimization done.
|
||||||
left = CellUtil.createCell(Bytes.toBytes("g"), Bytes.toBytes("a"), Bytes.toBytes("a"));
|
left = CellUtil.createCell(Bytes.toBytes("g"), Bytes.toBytes("a"), Bytes.toBytes("a"));
|
||||||
right = CellUtil.createCell(Bytes.toBytes("i"), Bytes.toBytes("a"), Bytes.toBytes("a"));
|
right = CellUtil.createCell(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.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, left, mid) < 0);
|
||||||
assertTrue(PrivateCellUtil.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, mid, right) == 0);
|
assertTrue(PrivateCellUtil.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, mid, right) == 0);
|
||||||
|
|
||||||
|
@ -788,7 +789,7 @@ public class TestHFile {
|
||||||
assertTrue(newKey.getTypeByte() == Type.Maximum.getCode());
|
assertTrue(newKey.getTypeByte() == Type.Maximum.getCode());
|
||||||
|
|
||||||
// verify metaKeyComparator's getShortMidpointKey output
|
// 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);
|
kv1 = new KeyValue(Bytes.toBytes("ilovehbase123"), family, qualA, 5, Type.Put);
|
||||||
kv2 = new KeyValue(Bytes.toBytes("ilovehbase234"), family, qualA, 0, Type.Put);
|
kv2 = new KeyValue(Bytes.toBytes("ilovehbase234"), family, qualA, 0, Type.Put);
|
||||||
newKey = HFileWriterImpl.getMidpoint(metaKeyComparator, kv1, kv2);
|
newKey = HFileWriterImpl.getMidpoint(metaKeyComparator, kv1, kv2);
|
||||||
|
|
Loading…
Reference in New Issue