/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }
public int[] getWordLengths(byte []b, int start, int end) { //Given a string like "hello how are you", it returns an array //like [4 5, 3, 3, 3], where the first element is the number of //fields if (!keySpecSeen) { //if there were no key specs, then the whole key is one word return new int[] {1}; } int[] lengths = new int[10]; int currLenLengths = lengths.length; int idx = 1; int pos; while ((pos = UTF8ByteArrayUtils.findBytes(b, start, end, keyFieldSeparator)) != -1) { if (++idx == currLenLengths) { int[] temp = lengths; lengths = new int[(currLenLengths = currLenLengths*2)]; System.arraycopy(temp, 0, lengths, 0, temp.length); } lengths[idx - 1] = pos - start; start = pos + 1; } if (start != end) { lengths[idx] = end - start; } lengths[0] = idx; //number of words is the first element return lengths; } public int getStartOffset(byte[]b, int start, int end,
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param start starting offset * @param length the length of byte array * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, int start, int length, byte b, int n) { int pos = -1; int nextStart = start; for (int i = 0; i < n; i++) { pos = findByte(utf, nextStart, length, b); if (pos < 0) { return pos; } nextStart = pos + 1; } return pos; }
/** * Find the nth occurrence of the given byte b in a UTF-8 encoded string * @param utf a byte array containing a UTF-8 encoded string * @param b the byte to find * @param n the desired occurrence of the given byte * @return position that nth occurrence of the given byte if exists; otherwise -1 */ public static int findNthByte(byte [] utf, byte b, int n) { return findNthByte(utf, 0, utf.length, b, n); }