/** Just takes unsigned byte values from the BytesRef and * converts into an IntsRef. */ public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) { scratch.clear(); for(int i=0;i<input.length;i++) { scratch.append(input.bytes[i+input.offset] & 0xFF); } return scratch.get(); }
/** * Convert a character sequence <code>s</code> into full unicode codepoints. */ private static IntsRefBuilder UTF16ToUTF32(CharSequence s, IntsRefBuilder builder) { builder.clear(); for (int charIdx = 0, charLimit = s.length(); charIdx < charLimit;) { final int utf32 = Character.codePointAt(s, charIdx); builder.append(utf32); charIdx += Character.charCount(utf32); } return builder; }
/** Just takes unsigned byte values from the BytesRef and * converts into an IntsRef. */ public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) { scratch.clear(); for(int i=0;i<input.length;i++) { scratch.append(input.bytes[i+input.offset] & 0xFF); } return scratch.get(); }
/** Just takes unsigned byte values from the BytesRef and * converts into an IntsRef. */ public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) { scratch.clear(); for(int i=0;i<input.length;i++) { scratch.append(input.bytes[i+input.offset] & 0xFF); } return scratch.get(); }
/** Just takes unsigned byte values from the BytesRef and * converts into an IntsRef. */ public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) { scratch.clear(); for(int i=0;i<input.length;i++) { scratch.append(input.bytes[i+input.offset] & 0xFF); } return scratch.get(); }
maxPathsBuilder.clear(); maxPathsBuilder.grow(utf32.length + 1); Arrays.fill(maxPathsBuilder.ints(), 0, utf32.length + 1, Integer.MAX_VALUE);
private static void serialize(String file, BytesRef [] all) throws IOException { final Object nothing = NoOutputs.getSingleton().getNoOutput(); final Builder<Object> builder = new Builder<Object>(INPUT_TYPE.BYTE4, NoOutputs.getSingleton()); final IntsRefBuilder intsRef = new IntsRefBuilder(); for (BytesRef br : all) { intsRef.clear(); intsRef.copyUTF8Bytes(br); builder.add(intsRef.get(), nothing); } final FST<Object> fst = builder.finish(); final OutputStreamDataOutput out = new OutputStreamDataOutput(new FileOutputStream(file)); fst.save(out); out.close(); } }