/** * Extract the file name from the row suffix into the given {@link Text} * * @param k * Key to extract from * @param buff * Text to place file name into */ public static void getFile(Key k, Text buff) { requireNonNull(k); requireNonNull(buff); checkArgument(COLF_BYTE_SEQ.equals(k.getColumnFamilyData()), "Given metadata replication status key with incorrect colfam"); k.getRow(buff); buff.set(buff.getBytes(), section.getRowPrefix().length(), buff.getLength() - section.getRowPrefix().length()); } }
public static ByteSequence shorten(ByteSequence prev, ByteSequence current) { int minLen = Math.min(prev.length(), current.length()); for (int i = 0; i < minLen; i++) { int pb = 0xff & prev.byteAt(i); int cb = 0xff & current.byteAt(i); int diff = cb - pb; if (diff == 1) { int newLen = findNonFF(prev, i + 1); byte[] successor; if (newLen < prev.length()) { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), BFF); } else { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), B00); } return new ArrayByteSequence(successor); } else if (diff > 1) { byte[] copy = new byte[i + 1]; System.arraycopy(prev.subSequence(0, i + 1).toArray(), 0, copy, 0, i + 1); copy[i] = (byte) ((0xff & copy[i]) + 1); return new ArrayByteSequence(copy); } } ArrayByteSequence successor = new ArrayByteSequence(Bytes.concat(prev.toArray(), B00)); if (successor.equals(current)) { return null; } return successor; }
/** * Extract the file name from the row suffix into the given {@link Text} * * @param k * Key to extract from * @param buff * Text to place file name into */ public static void getFile(Key k, Text buff) { requireNonNull(k); requireNonNull(buff); checkArgument(COLF_BYTE_SEQ.equals(k.getColumnFamilyData()), "Given metadata replication status key with incorrect colfam"); k.getRow(buff); buff.set(buff.getBytes(), section.getRowPrefix().length(), buff.getLength() - section.getRowPrefix().length()); } }
public static ByteSequence shorten(ByteSequence prev, ByteSequence current) { int minLen = Math.min(prev.length(), current.length()); for (int i = 0; i < minLen; i++) { int pb = 0xff & prev.byteAt(i); int cb = 0xff & current.byteAt(i); int diff = cb - pb; if (diff == 1) { int newLen = findNonFF(prev, i + 1); byte[] successor; if (newLen < prev.length()) { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), BFF); } else { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), B00); } return new ArrayByteSequence(successor); } else if (diff > 1) { byte[] copy = new byte[i + 1]; System.arraycopy(prev.subSequence(0, i + 1).toArray(), 0, copy, 0, i + 1); copy[i] = (byte) ((0xff & copy[i]) + 1); return new ArrayByteSequence(copy); } } ArrayByteSequence successor = new ArrayByteSequence(Bytes.concat(prev.toArray(), B00)); if (successor.equals(current)) { return null; } return successor; }