/** * Parses a char array into an int. * @param chars the character array * @param offset The offset into the array * @param len The length * @return the int * @throws NumberFormatException if it can't parse */ public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException { return parseInt(chars, offset, len, 10); }
@Override public BytesRef encode(char[] buffer, int offset, int length) { int payload = ArrayUtil.parseInt(buffer, offset, length);//TODO: improve this so that we don't have to new Strings byte[] bytes = PayloadHelper.encodeInt(payload); BytesRef result = new BytesRef(bytes); return result; } }
@Override public boolean incrementToken() throws IOException { if (input.incrementToken()) { final char[] buffer = termAtt.buffer(); final int length = termAtt.length(); for (int i = 0; i < length; i++) { if (buffer[i] == delimiter) { termAtt.setLength(i); // simply set a new length i++; tfAtt.setTermFrequency(ArrayUtil.parseInt(buffer, i, length - i)); return true; } } return true; } return false; } }
/** * Parses a char array into an int. * @param chars the character array * @param offset The offset into the array * @param len The length * @return the int * @throws NumberFormatException if it can't parse */ public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException { return parseInt(chars, offset, len, 10); }
/** * Parses a char array into an int. * @param chars the character array * @param offset The offset into the array * @param len The length * @return the int * @throws NumberFormatException if it can't parse */ public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException { return parseInt(chars, offset, len, 10); }
/** * Parses a char array into an int. * @param chars the character array * @param offset The offset into the array * @param len The length * @return the int * @throws NumberFormatException if it can't parse */ public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException { return parseInt(chars, offset, len, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param chars a string representation of an int quantity. * @return int the value represented by the argument * @throws NumberFormatException if the argument could not be parsed as an int quantity. */ public static int parseInt(char[] chars) throws NumberFormatException { return parseInt(chars, 0, chars.length, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param chars a string representation of an int quantity. * @return int the value represented by the argument * @throws NumberFormatException if the argument could not be parsed as an int quantity. */ public static int parseInt(char[] chars) throws NumberFormatException { return parseInt(chars, 0, chars.length, 10); }
/** * Parses a char array into an int. * @param chars the character array * @param offset The offset into the array * @param len The length * @return the int * @throws NumberFormatException if it can't parse */ public static int parseInt(char[] chars, int offset, int len) throws NumberFormatException { return parseInt(chars, offset, len, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param chars a string representation of an int quantity. * @return int the value represented by the argument * @throws NumberFormatException if the argument could not be parsed as an int quantity. */ public static int parseInt(char[] chars) throws NumberFormatException { return parseInt(chars, 0, chars.length, 10); }
@Override public BytesRef encode(char[] buffer, int offset, int length) { int payload = ArrayUtil.parseInt(buffer, offset, length);//TODO: improve this so that we don't have to new Strings byte[] bytes = PayloadHelper.encodeInt(payload); BytesRef result = new BytesRef(bytes); return result; } }
@Override public BytesRef encode(char[] buffer, int offset, int length) { int payload = ArrayUtil.parseInt(buffer, offset, length);//TODO: improve this so that we don't have to new Strings byte[] bytes = PayloadHelper.encodeInt(payload); BytesRef result = new BytesRef(bytes); return result; } }
public Payload encode(char[] buffer, int offset, int length) { Payload result = new Payload(); int payload = ArrayUtil.parseInt(buffer, offset, length);//TODO: improve this so that we don't have to new Strings byte[] bytes = PayloadHelper.encodeInt(payload); result.setData(bytes); return result; } }
private int parseIntAt(BytesRef bytes, int offset, CharsRefBuilder scratch) { scratch.copyUTF8Bytes(bytes.bytes, bytes.offset + offset, bytes.length-offset); return ArrayUtil.parseInt(scratch.chars(), 0, scratch.length()); }
private int parseIntAt(int offset) { scratchUTF16.copyUTF8Bytes(scratch.bytes(), offset, scratch.length()-offset); return ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); }
private int parseIntAt(int offset) { scratchUTF16.copyUTF8Bytes(scratch.bytes(), offset, scratch.length()-offset); return ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); }
assert StringHelper.startsWith(scratch.get(), POS): "got line=" + scratch.get().utf8ToString(); scratchUTF16_2.copyUTF8Bytes(scratch.bytes(), POS.length, scratch.length()-POS.length); pos = ArrayUtil.parseInt(scratchUTF16_2.chars(), 0, scratchUTF16_2.length()); } else { pos = -1; assert StringHelper.startsWith(scratch.get(), START_OFFSET): "got line=" + scratch.get().utf8ToString(); scratchUTF16_2.copyUTF8Bytes(scratch.bytes(), START_OFFSET.length, scratch.length()-START_OFFSET.length); startOffset = ArrayUtil.parseInt(scratchUTF16_2.chars(), 0, scratchUTF16_2.length()); SimpleTextUtil.readLine(in, scratch); assert StringHelper.startsWith(scratch.get(), END_OFFSET): "got line=" + scratch.get().utf8ToString(); scratchUTF16_2.grow(scratch.length()-END_OFFSET.length); scratchUTF16_2.copyUTF8Bytes(scratch.bytes(), END_OFFSET.length, scratch.length()-END_OFFSET.length); endOffset = ArrayUtil.parseInt(scratchUTF16_2.chars(), 0, scratchUTF16_2.length());
docID = ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); termFreq = 0; first = false; } else if (StringHelper.startsWith(scratch.get(), FREQ)) { scratchUTF16.copyUTF8Bytes(scratch.bytes(), FREQ.length, scratch.length()-FREQ.length); termFreq = ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); } else if (StringHelper.startsWith(scratch.get(), POS)) {
docID = ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); tf = 0; first = false; } else if (StringHelper.startsWith(scratch.get(), FREQ)) { scratchUTF16.copyUTF8Bytes(scratch.bytes(), FREQ.length, scratch.length()-FREQ.length); tf = ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); posStart = in.getFilePointer(); } else if (StringHelper.startsWith(scratch.get(), POS)) {
sumDocFreq++; scratchUTF16.copyUTF8Bytes(scratch.bytes(), DOC.length, scratch.length()-DOC.length); int docID = ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); visitedDocs.set(docID); } else if (StringHelper.startsWith(scratch.get(), FREQ)) { scratchUTF16.copyUTF8Bytes(scratch.bytes(), FREQ.length, scratch.length()-FREQ.length); totalTermFreq += ArrayUtil.parseInt(scratchUTF16.chars(), 0, scratchUTF16.length()); } else if (StringHelper.startsWith(scratch.get(), TERM)) { if (lastDocsStart != -1) {