本文整理了Java中org.apache.hadoop.hbase.TableName.compareTo()
方法的一些代码示例,展示了TableName.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableName.compareTo()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.TableName
类名称:TableName
方法名:compareTo
[英]For performance reasons, the ordering is not lexicographic.
[中]出于性能原因,排序不是字典式的。
代码示例来源:origin: apache/hbase
static Comparator<TableDescriptor>
getComparator(Comparator<ColumnFamilyDescriptor> cfComparator) {
return (TableDescriptor lhs, TableDescriptor rhs) -> {
int result = lhs.getTableName().compareTo(rhs.getTableName());
if (result != 0) {
return result;
}
Collection<ColumnFamilyDescriptor> lhsFamilies = Arrays.asList(lhs.getColumnFamilies());
Collection<ColumnFamilyDescriptor> rhsFamilies = Arrays.asList(rhs.getColumnFamilies());
result = Integer.compare(lhsFamilies.size(), rhsFamilies.size());
if (result != 0) {
return result;
}
for (Iterator<ColumnFamilyDescriptor> it = lhsFamilies.iterator(), it2 =
rhsFamilies.iterator(); it.hasNext();) {
result = cfComparator.compare(it.next(), it2.next());
if (result != 0) {
return result;
}
}
// punt on comparison for ordering, just calculate difference
return Integer.compare(lhs.getValues().hashCode(), rhs.getValues().hashCode());
};
}
代码示例来源:origin: apache/hbase
@Override
public boolean visit(Result r) throws IOException {
if (r == null || r.isEmpty()) return true;
count.incrementAndGet();
RegionInfo info = MetaTableAccessor.getRegionInfo(r);
if (info == null) return true; // Keep scanning
if (isTableSpecified
&& info.getTable().compareTo(tableName) > 0) {
// Another table, stop scanning
return false;
}
if (LOG.isTraceEnabled()) LOG.trace("" + info + " IS-SPLIT_PARENT=" + info.isSplitParent());
if (info.isSplitParent()) splitParents.put(info, r);
if (r.getValue(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER) != null) {
mergedRegions.put(info, r);
}
// Returning true means "keep scanning"
return true;
}
};
代码示例来源:origin: apache/hbase
if (name.compareTo(TableName.META_TABLE_NAME) == 0) {
continue;
代码示例来源:origin: apache/hbase
/**
* Compares this split against the given one.
*
* @param split The split to compare to.
* @return The result of the comparison.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(TableSplit split) {
// If The table name of the two splits is the same then compare start row
// otherwise compare based on table names
int tableNameComparison =
getTable().compareTo(split.getTable());
return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo(
getStartRow(), split.getStartRow());
}
代码示例来源:origin: apache/hbase
@Override
public int compare(RegionInfo left, RegionInfo right) {
// This comparator differs from the one RegionInfo in that it sorts
// parent before daughters.
if (left == null) return -1;
if (right == null) return 1;
// Same table name.
int result = left.getTable().compareTo(right.getTable());
if (result != 0) return result;
// Compare start keys.
result = Bytes.compareTo(left.getStartKey(), right.getStartKey());
if (result != 0) return result;
// Compare end keys, but flip the operands so parent comes first
result = rowEndKeyComparator.compare(right.getEndKey(), left.getEndKey());
return result;
}
}
代码示例来源:origin: apache/hbase
int tableCompare = l.getTableName().compareTo(r.getTableName());
if (tableCompare != 0) {
return tableCompare;
代码示例来源:origin: apache/hbase
private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,
RegionInfo regionInfoB) {
int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());
if (result != 0) {
return result;
代码示例来源:origin: org.apache.hbase/hbase-client
static Comparator<TableDescriptor>
getComparator(Comparator<ColumnFamilyDescriptor> cfComparator) {
return (TableDescriptor lhs, TableDescriptor rhs) -> {
int result = lhs.getTableName().compareTo(rhs.getTableName());
if (result != 0) {
return result;
}
Collection<ColumnFamilyDescriptor> lhsFamilies = Arrays.asList(lhs.getColumnFamilies());
Collection<ColumnFamilyDescriptor> rhsFamilies = Arrays.asList(rhs.getColumnFamilies());
result = Integer.compare(lhsFamilies.size(), rhsFamilies.size());
if (result != 0) {
return result;
}
for (Iterator<ColumnFamilyDescriptor> it = lhsFamilies.iterator(), it2 =
rhsFamilies.iterator(); it.hasNext();) {
result = cfComparator.compare(it.next(), it2.next());
if (result != 0) {
return result;
}
}
// punt on comparison for ordering, just calculate difference
return Integer.compare(lhs.getValues().hashCode(), rhs.getValues().hashCode());
};
}
代码示例来源:origin: apache/hbase
int result = lhs.getTable().compareTo(rhs.getTable());
if (result != 0) {
return result;
代码示例来源:origin: org.apache.hbase/hbase-client
private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,
RegionInfo regionInfoB) {
int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());
if (result != 0) {
return result;
代码示例来源:origin: com.aliyun.hbase/alihbase-client
static Comparator<TableDescriptor>
getComparator(Comparator<ColumnFamilyDescriptor> cfComparator) {
return (TableDescriptor lhs, TableDescriptor rhs) -> {
int result = lhs.getTableName().compareTo(rhs.getTableName());
if (result != 0) {
return result;
}
Collection<ColumnFamilyDescriptor> lhsFamilies = Arrays.asList(lhs.getColumnFamilies());
Collection<ColumnFamilyDescriptor> rhsFamilies = Arrays.asList(rhs.getColumnFamilies());
result = Integer.compare(lhsFamilies.size(), rhsFamilies.size());
if (result != 0) {
return result;
}
for (Iterator<ColumnFamilyDescriptor> it = lhsFamilies.iterator(), it2 =
rhsFamilies.iterator(); it.hasNext();) {
result = cfComparator.compare(it.next(), it2.next());
if (result != 0) {
return result;
}
}
// punt on comparison for ordering, just calculate difference
return Integer.compare(lhs.getValues().hashCode(), rhs.getValues().hashCode());
};
}
代码示例来源:origin: harbby/presto-connectors
@Override
public boolean processRow(Result r) throws IOException {
if (r == null || r.isEmpty()) return true;
count.incrementAndGet();
HRegionInfo info = HRegionInfo.getHRegionInfo(r);
if (info == null) return true; // Keep scanning
if (isTableSpecified
&& info.getTable().compareTo(tableName) > 0) {
// Another table, stop scanning
return false;
}
if (info.isSplitParent()) splitParents.put(info, r);
if (r.getValue(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER) != null) {
mergedRegions.put(info, r);
}
// Returning true means "keep scanning"
return true;
}
};
代码示例来源:origin: harbby/presto-connectors
@Override
public boolean processRow(Result row) throws IOException {
HRegionInfo info = MetaScanner.getHRegionInfo(row);
if (info != null && !info.isSplitParent()) {
if (tableName.equals(info.getTable())) {
ServerName server = HRegionInfo.getServerName(row);
if (server == null) {
available.set(false);
return false;
}
regionCount.incrementAndGet();
} else if (tableName.compareTo(info.getTable()) < 0) {
// Return if we are done with the current table
return false;
}
}
return true;
}
};
代码示例来源:origin: org.apache.hbase/hbase-client
int result = lhs.getTable().compareTo(rhs.getTable());
if (result != 0) {
return result;
代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce
/**
* Compares this split against the given one.
*
* @param split The split to compare to.
* @return The result of the comparison.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(TableSplit split) {
// If The table name of the two splits is the same then compare start row
// otherwise compare based on table names
int tableNameComparison =
getTable().compareTo(split.getTable());
return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo(
getStartRow(), split.getStartRow());
}
代码示例来源:origin: org.apache.hbase/hbase-mapreduce
/**
* Compares this split against the given one.
*
* @param split The split to compare to.
* @return The result of the comparison.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(TableSplit split) {
// If The table name of the two splits is the same then compare start row
// otherwise compare based on table names
int tableNameComparison =
getTable().compareTo(split.getTable());
return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo(
getStartRow(), split.getStartRow());
}
代码示例来源:origin: harbby/presto-connectors
@Override
public int compare(HRegionInfo left, HRegionInfo right) {
// This comparator differs from the one HRegionInfo in that it sorts
// parent before daughters.
if (left == null) return -1;
if (right == null) return 1;
// Same table name.
int result = left.getTable().compareTo(right.getTable());
if (result != 0) return result;
// Compare start keys.
result = Bytes.compareTo(left.getStartKey(), right.getStartKey());
if (result != 0) return result;
// Compare end keys, but flip the operands so parent comes first
result = rowEndKeyComparator.compare(right.getEndKey(), left.getEndKey());
return result;
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public boolean processRow(Result row) throws IOException {
HRegionInfo info = MetaScanner.getHRegionInfo(row);
if (info != null && !info.isSplitParent()) {
if (tableName.equals(info.getTable())) {
ServerName server = HRegionInfo.getServerName(row);
if (server == null) {
available.set(false);
return false;
}
if (!Bytes.equals(info.getStartKey(), HConstants.EMPTY_BYTE_ARRAY)) {
for (byte[] splitKey : splitKeys) {
// Just check if the splitkey is available
if (Bytes.equals(info.getStartKey(), splitKey)) {
regionCount.incrementAndGet();
break;
}
}
} else {
// Always empty start row should be counted
regionCount.incrementAndGet();
}
} else if (tableName.compareTo(info.getTable()) < 0) {
// Return if we are done with the current table
return false;
}
}
return true;
}
};
代码示例来源:origin: org.locationtech.geomesa/geomesa-bigtable-spark
@Override
public int compareTo(BigtableExtendedScanSplit o) {
// If The table name of the two splits is the same then compare start row
// otherwise compare based on table names
int tableNameComparison =
name.compareTo(o.name);
return tableNameComparison != 0 ? tableNameComparison :
Bytes.compareTo(
scan.getRowSet().getRowRanges(0).getStartKeyClosed().toByteArray(),
o.scan.getRowSet().getRowRanges(0).getStartKeyClosed().toByteArray());
}
代码示例来源:origin: com.aliyun.hbase/alihbase-client
private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,
RegionInfo regionInfoB) {
int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());
if (result != 0) {
return result;
内容来源于网络,如有侵权,请联系作者删除!