/** Return true if the given file info key is reserved for internal use. */ public static boolean isReservedFileInfoKey(byte[] key) { return Bytes.startsWith(key, FileInfo.RESERVED_PREFIX_BYTES); }
protected static boolean isNamespaceRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_NAMESPACE_ROW_KEY_PREFIX); }
protected static boolean isRegionServerRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_REGION_SERVER_ROW_KEY_PREFIX); }
protected static boolean isTableRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_TABLE_ROW_KEY_PREFIX); }
protected static boolean isUserRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_USER_ROW_KEY_PREFIX); }
public ReturnCode filterColumn(Cell cell) { byte [] qualifier = CellUtil.cloneQualifier(cell); TreeSet<byte []> lesserOrEqualPrefixes = (TreeSet<byte []>) sortedPrefixes.headSet(qualifier, true); if (lesserOrEqualPrefixes.size() != 0) { byte [] largestPrefixSmallerThanQualifier = lesserOrEqualPrefixes.last(); if (Bytes.startsWith(qualifier, largestPrefixSmallerThanQualifier)) { return ReturnCode.INCLUDE; } if (lesserOrEqualPrefixes.size() == sortedPrefixes.size()) { return ReturnCode.NEXT_ROW; } else { hint = sortedPrefixes.higher(largestPrefixSmallerThanQualifier); return ReturnCode.SEEK_NEXT_USING_HINT; } } else { hint = sortedPrefixes.first(); return ReturnCode.SEEK_NEXT_USING_HINT; } }
protected static void parseUserResult(final String userName, final Result result, final UserQuotasVisitor visitor) throws IOException { Map<byte[], byte[]> familyMap = result.getFamilyMap(QUOTA_FAMILY_INFO); if (familyMap == null || familyMap.isEmpty()) return; for (Map.Entry<byte[], byte[]> entry: familyMap.entrySet()) { Quotas quotas = quotasFromData(entry.getValue()); if (Bytes.startsWith(entry.getKey(), QUOTA_QUALIFIER_SETTINGS_PREFIX)) { String name = Bytes.toString(entry.getKey(), QUOTA_QUALIFIER_SETTINGS_PREFIX.length); if (name.charAt(name.length() - 1) == TableName.NAMESPACE_DELIM) { String namespace = name.substring(0, name.length() - 1); visitor.visitUserQuotas(userName, namespace, quotas); } else { TableName table = TableName.valueOf(name); visitor.visitUserQuotas(userName, table, quotas); } } else if (Bytes.equals(entry.getKey(), QUOTA_QUALIFIER_SETTINGS)) { visitor.visitUserQuotas(userName, quotas); } } }
public void testStartsWith() { assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("h"))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes(""))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("hello"))); assertFalse(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("helloworld"))); assertFalse(Bytes.startsWith(Bytes.toBytes(""), Bytes.toBytes("hello"))); }
if (qualPrefix != null && !Bytes.startsWith(e.getKey(), qualPrefix)) {
public static boolean isLocalIndexFamily(byte[] cf) { return Bytes.startsWith(cf, QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX_BYTES); }
protected static boolean isUserRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_USER_ROW_KEY_PREFIX); }
protected static boolean isNamespaceRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_NAMESPACE_ROW_KEY_PREFIX); }
protected static boolean isTableRowKey(final byte[] key) { return Bytes.startsWith(key, QUOTA_TABLE_ROW_KEY_PREFIX); }
public ReturnCode filterColumn(Cell cell) { byte [] qualifier = CellUtil.cloneQualifier(cell); TreeSet<byte []> lesserOrEqualPrefixes = (TreeSet<byte []>) sortedPrefixes.headSet(qualifier, true); if (lesserOrEqualPrefixes.size() != 0) { byte [] largestPrefixSmallerThanQualifier = lesserOrEqualPrefixes.last(); if (Bytes.startsWith(qualifier, largestPrefixSmallerThanQualifier)) { return ReturnCode.INCLUDE; } if (lesserOrEqualPrefixes.size() == sortedPrefixes.size()) { return ReturnCode.NEXT_ROW; } else { hint = sortedPrefixes.higher(largestPrefixSmallerThanQualifier); return ReturnCode.SEEK_NEXT_USING_HINT; } } else { hint = sortedPrefixes.first(); return ReturnCode.SEEK_NEXT_USING_HINT; } }
protected static void parseUserResult(final String userName, final Result result, final UserQuotasVisitor visitor) throws IOException { Map<byte[], byte[]> familyMap = result.getFamilyMap(QUOTA_FAMILY_INFO); if (familyMap == null || familyMap.isEmpty()) return; for (Map.Entry<byte[], byte[]> entry: familyMap.entrySet()) { Quotas quotas = quotasFromData(entry.getValue()); if (Bytes.startsWith(entry.getKey(), QUOTA_QUALIFIER_SETTINGS_PREFIX)) { String name = Bytes.toString(entry.getKey(), QUOTA_QUALIFIER_SETTINGS_PREFIX.length); if (name.charAt(name.length() - 1) == TableName.NAMESPACE_DELIM) { String namespace = name.substring(0, name.length() - 1); visitor.visitUserQuotas(userName, namespace, quotas); } else { TableName table = TableName.valueOf(name); visitor.visitUserQuotas(userName, table, quotas); } } else if (Bytes.equals(entry.getKey(), QUOTA_QUALIFIER_SETTINGS)) { visitor.visitUserQuotas(userName, quotas); } } }
private static KeyRange concatSuffix(KeyRange result, KeyRange otherRange) { byte[] lowerRange = result.getLowerRange(); byte[] clippedLowerRange = lowerRange; byte[] fullLowerRange = otherRange.getLowerRange(); if (!result.lowerUnbound() && Bytes.startsWith(fullLowerRange, clippedLowerRange)) { lowerRange = fullLowerRange; } byte[] upperRange = result.getUpperRange(); byte[] clippedUpperRange = upperRange; byte[] fullUpperRange = otherRange.getUpperRange(); if (!result.lowerUnbound() && Bytes.startsWith(fullUpperRange, clippedUpperRange)) { upperRange = fullUpperRange; } if (lowerRange == clippedLowerRange && upperRange == clippedUpperRange) { return result; } return KeyRange.getKeyRange(lowerRange, result.isLowerInclusive(), upperRange, result.isUpperInclusive()); }
@Override public void postPut(org.apache.hadoop.hbase.coprocessor.ObserverContext<RegionCoprocessorEnvironment> c, Put put, org.apache.hadoop.hbase.wal.WALEdit edit, Durability durability) throws java.io.IOException { String tableName = c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString(); if (tableName.equalsIgnoreCase(TABLE_NAME) // create the index after the second batch && Bytes.startsWith(put.getRow(), Bytes.toBytes("varchar200_upsert_select"))) { Runnable r = new Runnable() { @Override public void run() { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { // Run CREATE INDEX call in separate thread as otherwise we block // this thread (not a realistic scenario) and prevent our catchup // query from adding the missing rows. conn.createStatement().execute(INDEX_DDL); } catch (SQLException e) { } } }; new Thread(r).start(); } } }
private static KeyRange getTrailingRange(RowKeySchema rowKeySchema, int pkPos, KeyRange range, KeyRange clippedResult, ImmutableBytesWritable ptr) { int separatorLength = rowKeySchema.getField(pkPos).getDataType().isFixedWidth() ? 0 : 1; byte[] lowerRange = KeyRange.UNBOUND; boolean lowerInclusive = false; // Lower range of trailing part of RVC must be true, so we can form a new range to intersect going forward if (!range.lowerUnbound() && Bytes.startsWith(range.getLowerRange(), clippedResult.getLowerRange())) { lowerRange = range.getLowerRange(); int offset = clippedResult.getLowerRange().length + separatorLength; ptr.set(lowerRange, offset, lowerRange.length - offset); lowerRange = ptr.copyBytes(); lowerInclusive = range.isLowerInclusive(); } byte[] upperRange = KeyRange.UNBOUND; boolean upperInclusive = false; if (!range.upperUnbound() && Bytes.startsWith(range.getUpperRange(), clippedResult.getUpperRange())) { upperRange = range.getUpperRange(); int offset = clippedResult.getUpperRange().length + separatorLength; ptr.set(upperRange, offset, upperRange.length - offset); upperRange = ptr.copyBytes(); upperInclusive = range.isUpperInclusive(); } return KeyRange.getKeyRange(lowerRange, lowerInclusive, upperRange, upperInclusive); }
public void testStartsWith() { assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("h"))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes(""))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("hello"))); assertFalse(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("helloworld"))); assertFalse(Bytes.startsWith(Bytes.toBytes(""), Bytes.toBytes("hello"))); }
if (Bytes.startsWith(otherLowerRange, trailingBytes) && (isFixedWidthAtEnd || otherLowerRange.length == trailingBytes.length ||