/** * Splits the array of bytes into array of arrays of bytes * on byte separator * @param bytes the array of bytes to split * @param separator the delimiting byte */ public static byte[][] bytes2byteArray(byte[] bytes, byte separator) { return bytes2byteArray(bytes, bytes.length, separator); }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in input to read from * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** * Splits the array of bytes into array of arrays of bytes on byte separator * * @param bytes * the array of bytes to split * @param separator * the delimiting byte */ public static byte[][] bytes2byteArray(byte[] bytes, byte separator) { return bytes2byteArray(bytes, bytes.length, separator); }
/** * Splits the array of bytes into array of arrays of bytes * on byte separator * @param bytes the array of bytes to split * @param separator the delimiting byte */ public static byte[][] bytes2byteArray(byte[] bytes, byte separator) { return bytes2byteArray(bytes, bytes.length, separator); }
/** * Splits the array of bytes into array of arrays of bytes * on byte separator * @param bytes the array of bytes to split * @param separator the delimiting byte */ public static byte[][] bytes2byteArray(byte[] bytes, byte separator) { return bytes2byteArray(bytes, bytes.length, separator); }
/** * Convert a UTF8 string to an array of byte arrays. */ public static byte[][] getPathComponents(String path) { // avoid intermediate split to String[] final byte[] bytes = string2Bytes(path); return bytes2byteArray(bytes, bytes.length, (byte)Path.SEPARATOR_CHAR); }
/** * Convert a UTF8 string to an array of byte arrays. */ public static byte[][] getPathComponents(String path) { // avoid intermediate split to String[] final byte[] bytes = string2Bytes(path); return bytes2byteArray(bytes, bytes.length, (byte)Path.SEPARATOR_CHAR); }
public void testString(String str) throws Exception { String pathString = str; byte[][] oldPathComponents = INode.getPathComponents(pathString); byte[][] newPathComponents = DFSUtil.bytes2byteArray(pathString.getBytes("UTF-8"), (byte) Path.SEPARATOR_CHAR); if (oldPathComponents[0] == null) { assertTrue(oldPathComponents[0] == newPathComponents[0]); } else { assertTrue("Path components do not match for " + pathString, Arrays.deepEquals(oldPathComponents, newPathComponents)); } } }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in input to read from * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInputStream in) throws IOException { UTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in input to read from * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }