Refine search
/** * Creates a {@link Get} for the HBase snapshot's size against the given table. */ static Get makeGetForSnapshotSize(TableName tn, String snapshot) { Get g = new Get(Bytes.add(QUOTA_TABLE_ROW_KEY_PREFIX, Bytes.toBytes(tn.toString()))); g.addColumn( QUOTA_FAMILY_USAGE, Bytes.add(QUOTA_SNAPSHOT_SIZE_QUALIFIER, Bytes.toBytes(snapshot))); return g; }
/** * Generate the given number of unique byte sequences by appending numeric * suffixes (ASCII representations of decimal numbers). */ public static byte[][] makeNAscii(byte[] base, int n) { byte [][] ret = new byte[n][]; for (int i = 0; i < n; i++) { byte[] tail = Bytes.toBytes(Integer.toString(i)); ret[i] = Bytes.add(base, tail); } return ret; }
/** * Build qualifier key from user permission: * username * username,family * username,family,qualifier */ static byte[] userPermissionKey(UserPermission permission) { byte[] key = Bytes.toBytes(permission.getUser()); byte[] qualifier = null; byte[] family = null; if (permission.getPermission().getAccessScope() == Permission.Scope.TABLE) { TablePermission tablePermission = (TablePermission) permission.getPermission(); family = tablePermission.getFamily(); qualifier = tablePermission.getQualifier(); } if (family != null && family.length > 0) { key = Bytes.add(key, Bytes.add(new byte[]{ACL_KEY_DELIMITER}, family)); if (qualifier != null && qualifier.length > 0) { key = Bytes.add(key, Bytes.add(new byte[]{ACL_KEY_DELIMITER}, qualifier)); } } return key; }
private static byte[][] makeNAsciiWithZeroPrefix(byte[] base, int n) { int maxLength = Integer.toString(n).length(); byte [][] ret = new byte[n][]; for (int i = 0; i < n; i++) { int length = Integer.toString(i).length(); StringBuilder buf = new StringBuilder(Integer.toString(i)); IntStream.range(0, maxLength - length).forEach(v -> buf.insert(0, "0")); byte[] tail = Bytes.toBytes(buf.toString()); ret[i] = Bytes.add(base, tail); } return ret; }
static KeyValue[] genKVs(final byte[] row, final byte[] family, final byte[] value, final long timestamp, final int cols) { KeyValue [] kvs = new KeyValue[cols]; for (int i = 0; i < cols ; i++) { kvs[i] = new KeyValue( row, family, Bytes.toBytes(i), timestamp, Bytes.add(value, Bytes.toBytes(i))); } return kvs; }
private void putData(Region region, byte[] startRow, int numRows, byte[] qf, byte[]... families) throws IOException { for (int i = 0; i < numRows; i++) { Put put = new Put(Bytes.add(startRow, Bytes.toBytes(i))); for (byte[] family : families) { put.addColumn(family, qf, null); } region.put(put); } }