Java Code Examples for org.apache.hadoop.hbase.util.Bytes.startsWith()

The following are Jave code examples for showing how to use startsWith() of the org.apache.hadoop.hbase.util.Bytes class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ditb   File: QuotaTableUtil.java   View Source Code Vote up 7 votes
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);
    }
  }
}
 
Example 2
Project: ditb   File: MultipleColumnPrefixFilter.java   View Source Code Vote up 6 votes
public ReturnCode filterColumn(byte[] buffer, int qualifierOffset, int qualifierLength) {
  byte [] qualifier = Arrays.copyOfRange(buffer, qualifierOffset,
                                         qualifierLength + qualifierOffset);
  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;
  }
}
 
Example 3
Project: ditb   File: IndexFile.java   View Source Code Vote up 5 votes
static FileInfo appendFileInfo(FileInfo fi, final byte [] k, final byte [] v,
  final boolean checkPrefix)
throws IOException {
  if (k == null || v == null) {
    throw new NullPointerException("Key nor value may be null");
  }
  if (checkPrefix &&
      Bytes.startsWith(k, FileInfo.RESERVED_PREFIX_BYTES)) {
    throw new IOException("Keys with a " + FileInfo.RESERVED_PREFIX +
      " are reserved");
  }
  fi.put(k, v);
  return fi;
}
 
Example 4
Project: ditb   File: HFile.java   View Source Code Vote up 4 votes
/** 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);
}
 
Example 5
Project: ditb   File: QuotaTableUtil.java   View Source Code Vote up 4 votes
protected static boolean isNamespaceRowKey(final byte[] key) {
  return Bytes.startsWith(key, QUOTA_NAMESPACE_ROW_KEY_PREFIX);
}
 
Example 6
Project: ditb   File: QuotaTableUtil.java   View Source Code Vote up 4 votes
protected static boolean isTableRowKey(final byte[] key) {
  return Bytes.startsWith(key, QUOTA_TABLE_ROW_KEY_PREFIX);
}
 
Example 7
Project: ditb   File: QuotaTableUtil.java   View Source Code Vote up 4 votes
protected static boolean isUserRowKey(final byte[] key) {
  return Bytes.startsWith(key, QUOTA_USER_ROW_KEY_PREFIX);
}
 
Example 8
Project: ditb   File: IndexFile.java   View Source Code Vote up 2 votes
/**
 * Return true if the given file info key is reserved for internal
 * use by HFile.
 */
public static boolean isReservedFileInfoKey(byte[] key) {
  return Bytes.startsWith(key, FileInfo.RESERVED_PREFIX_BYTES);
}