Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public long heapSize() {
if (this.buf.hasArray()) {
return ClassSize.align(FIXED_OVERHEAD + length);
}
return ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
return (long) ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public interface Cell extends HeapSize {
// 4) Timestamp

/**
* @return Long value representing time at which this cell was "Put" into the row. Typically
* represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
* Return a long value representing time at which this cell was "Put" into the row. Typically
* represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
*/
long getTimestamp();

// 5) Type

/**
* @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
* Return the byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Use {@link #getType()}.
*/
@Deprecated
Expand Down Expand Up @@ -160,7 +160,7 @@ public interface Cell extends HeapSize {
byte[] getTagsArray();

/**
* @return the first offset where the tags start in the Cell
* Return the first offset where the tags start in the Cell
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ default int compareRows(byte[] leftRow, byte[] rightRow) {
}

/**
* Lexicographically compare two rows
* @param row ByteBuffer that wraps a row; will read from current position and will reading all
* remaining; will not disturb the ByteBuffer internal state.
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
Expand All @@ -111,7 +112,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
}

/**
* Lexographically compares the two cells excluding the row part. It compares family, qualifier,
* Lexicographically compares the two cells excluding the row part. It compares family, qualifier,
* timestamp and the type
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
Expand All @@ -121,7 +122,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
int compareWithoutRow(Cell leftCell, Cell rightCell);

/**
* Lexographically compares the families of the two cells
* Lexicographically compares the families of the two cells
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
Expand All @@ -130,7 +131,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
int compareFamilies(Cell leftCell, Cell rightCell);

/**
* Lexographically compares the qualifiers of the two cells
* Lexicographically compares the qualifiers of the two cells
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
Expand Down Expand Up @@ -163,10 +164,9 @@ default int compareRows(ByteBuffer row, Cell cell) {
int compareTimestamps(long leftCellts, long rightCellts);

/**
* @return A dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
* Create an instance when you make a new memstore, when you know only BBKVs will be
* passed. Do not pollute with types other than BBKV if can be helped; the Comparator will
* slow.
* Return a dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
* Create an instance when you make a new memstore, when you know only BBKVs will be passed. Do
* not pollute with types other than BBKV if can be helped; the Comparator will slow.
*/
Comparator getSimpleComparator();
Comparator<Cell> getSimpleComparator();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.hadoop.hbase;

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;
Expand Down Expand Up @@ -691,11 +690,11 @@ public final int compareWithoutRow(final Cell left, final Cell right) {
int rFamLength = right.getFamilyLength();
int lQualLength = left.getQualifierLength();
int rQualLength = right.getQualifierLength();
if (lFamLength + lQualLength == 0 && left.getTypeByte() == Type.Minimum.getCode()) {
if (lFamLength + lQualLength == 0 && left.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
if (rFamLength + rQualLength == 0 && right.getTypeByte() == Type.Minimum.getCode()) {
if (rFamLength + rQualLength == 0 && right.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
return -1;
}
if (lFamLength != rFamLength) {
Expand Down
31 changes: 13 additions & 18 deletions hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.function.Function;
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;
Expand Down Expand Up @@ -486,8 +485,7 @@ private static boolean matchingQualifier(final Cell left, final int lqlength, fi
}

/**
* Finds if the qualifier part of the cell and the KV serialized byte[] are equal n * @param buf
* the serialized keyvalue format byte[]
* Finds if the qualifier part of the cell and the KV serialized byte[] are equal.
* @return true if the qualifier matches, false otherwise
*/
public static boolean matchingQualifier(final Cell left, final byte[] buf) {
Expand Down Expand Up @@ -561,8 +559,8 @@ public static boolean matchingTags(final Cell left, final Cell right) {
}

/**
* @return True if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
* or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
* Return true if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
* or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
*/
@SuppressWarnings("deprecation")
public static boolean isDelete(final Cell cell) {
Expand All @@ -572,13 +570,13 @@ public static boolean isDelete(final Cell cell) {
/** Returns True if this cell is a Put. */
@SuppressWarnings("deprecation")
public static boolean isPut(Cell cell) {
return cell.getTypeByte() == Type.Put.getCode();
return cell.getTypeByte() == KeyValue.Type.Put.getCode();
}

/**
* Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may
* change between minor releases. nn * @throws IOException when the passed cell is not of type
* {@link ExtendedCell}
* change between minor releases.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
public static void setTimestamp(Cell cell, long ts) throws IOException {
Expand All @@ -587,8 +585,7 @@ public static void setTimestamp(Cell cell, long ts) throws IOException {

/**
* Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may
* change between minor releases. n * @param ts buffer containing the timestamp value
* @param tsOffset offset to the new timestamp
* change between minor releases.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
Expand All @@ -603,6 +600,7 @@ public static String getCellKeyAsString(Cell cell) {
}

/**
* Return the Key portion of the passed <code>cell</code> as a String.
* @param cell the cell to convert
* @param rowConverter used to convert the row of the cell to a string
* @return The Key portion of the passed <code>cell</code> as a String.
Expand All @@ -623,7 +621,7 @@ public static String getCellKeyAsString(Cell cell, Function<Cell, String> rowCon
sb.append('/');
sb.append(KeyValue.humanReadableTimestamp(cell.getTimestamp()));
sb.append('/');
sb.append(Type.codeToType(cell.getTypeByte()));
sb.append(KeyValue.Type.codeToType(cell.getTypeByte()));
if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {
sb.append("/vlen=");
sb.append(cell.getValueLength());
Expand Down Expand Up @@ -676,15 +674,14 @@ public static boolean matchingTimestamp(Cell a, Cell b) {
return CellComparator.getInstance().compareTimestamps(a.getTimestamp(), b.getTimestamp()) == 0;
}

/**
* Compares the row of two keyvalues for equality nn * @return True if rows match.
*/
/** Compares the row of two keyvalues for equality */
public static boolean matchingRows(final Cell left, final Cell right) {
short lrowlength = left.getRowLength();
short rrowlength = right.getRowLength();
return matchingRows(left, lrowlength, right, rrowlength);
}

/** Compares the row of two keyvalues for equality */
public static boolean matchingRows(final Cell left, final short lrowlength, final Cell right,
final short rrowlength) {
if (lrowlength != rrowlength) return false;
Expand All @@ -708,10 +705,7 @@ public static boolean matchingRows(final Cell left, final short lrowlength, fina
right.getRowOffset(), rrowlength);
}

/**
* Compares the row and column of two keyvalues for equality nn * @return True if same row and
* column.
*/
/** Compares the row and column of two keyvalues for equality */
public static boolean matchingRowColumn(final Cell left, final Cell right) {
short lrowlength = left.getRowLength();
short rrowlength = right.getRowLength();
Expand All @@ -738,6 +732,7 @@ public static boolean matchingRowColumn(final Cell left, final Cell right) {
return matchingColumn(left, lfamlength, lqlength, right, rfamlength, rqlength);
}

/** Compares the row and column of two keyvalues for equality */
public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
int lrowlength = left.getRowLength();
int rrowlength = right.getRowLength();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public ChoreService(final String coreThreadPoolPrefix, int corePoolSize, boolean
}

/**
* Schedule a chore.
* @param chore Chore to be scheduled. If the chore is already scheduled with another ChoreService
* instance, that schedule will be cancelled (i.e. a Chore can only ever be scheduled
* with a single ChoreService instance).
Expand Down Expand Up @@ -252,8 +253,8 @@ int getNumberOfScheduledChores() {
}

/**
* @return number of chores that this service currently has scheduled that are missing their
* scheduled start time
* Return number of chores that this service currently has scheduled that are missing their
* scheduled start time
*/
int getNumberOfChoresMissingStartTime() {
return choresMissingStartTime.size();
Expand All @@ -273,9 +274,6 @@ static class ChoreServiceThreadFactory implements ThreadFactory {
private final static String THREAD_NAME_SUFFIX = ".Chore.";
private AtomicInteger threadNumber = new AtomicInteger(1);

/**
* @param threadPrefix The prefix given to all threads created by this factory
*/
public ChoreServiceThreadFactory(final String threadPrefix) {
this.threadPrefix = threadPrefix;
}
Expand Down Expand Up @@ -350,9 +348,9 @@ synchronized void onChoreMissedStartTime(ScheduledChore chore) {
}

/**
* shutdown the service. Any chores that are scheduled for execution will be cancelled. Any chores
* in the middle of execution will be interrupted and shutdown. This service will be unusable
* after this method has been called (i.e. future scheduling attempts will fail).
* Shut down the service. Any chores that are scheduled for execution will be cancelled. Any
* chores in the middle of execution will be interrupted and shutdown. This service will be
* unusable after this method has been called (i.e. future scheduling attempts will fail).
* <p/>
* Notice that, this will only clean the chore from this ChoreService but you could still schedule
* the chore with other ChoreService.
Expand Down Expand Up @@ -390,9 +388,7 @@ private void cancelAllChores(final boolean mayInterruptIfRunning) {
}
}

/**
* Prints a summary of important details about the chore. Used for debugging purposes
*/
/** Prints a summary of important details about the chore. Used for debugging purposes */
private void printChoreDetails(final String header, ScheduledChore chore) {
if (!LOG.isTraceEnabled()) {
return;
Expand All @@ -408,9 +404,7 @@ private void printChoreDetails(final String header, ScheduledChore chore) {
}
}

/**
* Prints a summary of important details about the service. Used for debugging purposes
*/
/** Prints a summary of important details about the service. Used for debugging purposes */
private void printChoreServiceDetails(final String header) {
if (!LOG.isTraceEnabled()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static Configuration create() {
}

/**
* Creates a Configuration with HBase resources
* @param that Configuration to clone.
* @return a Configuration created with the hbase-*.xml files plus the given configuration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public long getWeightForSsd() {
return weightForSsd;
}

/**
* comparator used to sort hosts based on weight
*/
/** Comparator used to sort hosts based on weight */
public static class WeightComparator implements Comparator<HostAndWeight> {
@Override
public int compare(HostAndWeight l, HostAndWeight r) {
Expand All @@ -100,16 +98,10 @@ public int compare(HostAndWeight l, HostAndWeight r) {
}
}

/**
* Constructor
*/
public HDFSBlocksDistribution() {
this.hostAndWeights = new TreeMap<>();
}

/**
* @see java.lang.Object#toString()
*/
@Override
public synchronized String toString() {
return "number of unique hosts in the distribution=" + this.hostAndWeights.size();
Expand Down Expand Up @@ -206,14 +198,13 @@ public long getUniqueBlocksTotalWeight() {
return uniqueBlocksTotalWeight;
}

/**
* Implementations 'visit' hostAndWeight.
*/
/** Implementations 'visit' hostAndWeight. */
public interface Visitor {
long visit(final HostAndWeight hostAndWeight);
}

/**
* Get the block locality index for a given host
* @param host the host name
* @return the locality index of the given host
*/
Expand All @@ -227,6 +218,7 @@ public float getBlockLocalityIndex(String host) {
}

/**
* Get the block locality index for a ssd for a given host
* @param host the host name
* @return the locality index with ssd of the given host
*/
Expand All @@ -240,6 +232,7 @@ public float getBlockLocalityIndexForSsd(String host) {
}

/**
* Get the blocks local weight for a given host
* @param host the host name
* @return the blocks local weight of the given host
*/
Expand All @@ -248,17 +241,14 @@ public long getBlocksLocalWeight(String host) {
}

/**
* Get the blocks local weight with ssd for a given host
* @param host the host name
* @return the blocks local with ssd weight of the given host
*/
public long getBlocksLocalWithSsdWeight(String host) {
return getBlocksLocalityWeightInternal(host, HostAndWeight::getWeightForSsd);
}

/**
* @param host the host name
* @return the locality index of the given host
*/
private long getBlocksLocalityWeightInternal(String host, Visitor visitor) {
long localityIndex = 0;
HostAndWeight hostAndWeight = this.hostAndWeights.get(host);
Expand Down Expand Up @@ -293,9 +283,7 @@ public void add(HDFSBlocksDistribution otherBlocksDistribution) {
addUniqueWeight(otherBlocksDistribution.getUniqueBlocksTotalWeight());
}

/**
* return the sorted list of hosts in terms of their weights
*/
/** Return the sorted list of hosts in terms of their weights */
public List<String> getTopHosts() {
HostAndWeight[] hostAndWeights = getTopHostsWithWeights();
List<String> topHosts = new ArrayList<>(hostAndWeights.length);
Expand All @@ -305,9 +293,7 @@ public List<String> getTopHosts() {
return topHosts;
}

/**
* return the sorted list of hosts in terms of their weights
*/
/** Return the sorted list of hosts in terms of their weights */
public HostAndWeight[] getTopHostsWithWeights() {
NavigableSet<HostAndWeight> orderedHosts = new TreeSet<>(new HostAndWeight.WeightComparator());
orderedHosts.addAll(this.hostAndWeights.values());
Expand Down
Loading