/** * Reads an automaton from a file. */ public static <T> FST<T> read(Path path, Outputs<T> outputs) throws IOException { try (InputStream is = Files.newInputStream(path)) { return new FST<>(new InputStreamDataInput(new BufferedInputStream(is)), outputs); } }
@Override public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { this.fst = new FST<>(dataIn, new PairOutputs<>( PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = dataIn.readVInt(); hasPayloads = dataIn.readByte() == 1; } finally { IOUtils.close(input); } return true; }
final int version; try { version = CodecUtil.checkHeader(new InputStreamDataInput(in), TRANSLOG_CODEC, VERSION_CHECKSUMS, VERSION_PRIMARY_TERM); } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException e) { tryReportOldVersionError(path, channel);
/** * Reads an automaton from a file. */ public static <T> FST<T> read(Path path, Outputs<T> outputs) throws IOException { try (InputStream is = Files.newInputStream(path)) { return new FST<>(new InputStreamDataInput(new BufferedInputStream(is)), outputs); } }
public static Checkpoint read(Path path) throws IOException { try (InputStream in = Files.newInputStream(path)) { return new Checkpoint(new InputStreamDataInput(in)); } }
/** * Reads an automaton from a file. */ public static <T> FST<T> read(Path path, Outputs<T> outputs) throws IOException { try (InputStream is = Files.newInputStream(path)) { return new FST<>(new InputStreamDataInput(new BufferedInputStream(is)), outputs); } }
/** * Reads an automaton from a file. */ public static <T> FST<T> read(Path path, Outputs<T> outputs) throws IOException { try (InputStream is = Files.newInputStream(path)) { return new FST<>(new InputStreamDataInput(new BufferedInputStream(is)), outputs); } }
@Override public boolean load(InputStream input) throws IOException { try { this.fst = new FST<Long>(new InputStreamDataInput(input), PositiveIntOutputs.getSingleton(true)); } finally { IOUtils.close(input); } return true; }
@Override public boolean load(InputStream input) throws IOException { InputStream is = new BufferedInputStream(input); try { this.automaton = new FST<Object>(new InputStreamDataInput(is), NoOutputs.getSingleton()); cacheRootArcs(); } finally { IOUtils.close(is); } return true; } }
/** * Calls {@link #load(DataInput)} after converting * {@link InputStream} to {@link DataInput} */ public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { return load(dataIn); } finally { IOUtils.close(input); } }
@Override public synchronized boolean load(InputStream input) throws IOException { try { this.higherWeightsCompletion = new FSTCompletion(new FST<Object>( new InputStreamDataInput(input), NoOutputs.getSingleton())); this.normalCompletion = new FSTCompletion( higherWeightsCompletion.getFST(), false, exactMatchFirst); } finally { IOUtils.close(input); } return true; } }
@Override public void readFrom(InputStream in) throws IOException { DataInput input = new InputStreamDataInput(in); set = new CharVectorHashSet(ignoreCase); int size = input.readInt(); for(int entryInx=0;entryInx < size; entryInx++) { set.add(new CharVector(input.readString())); } }
@Override public void readFrom(InputStream in) throws IOException { super.readFrom(in); DataInput input = new InputStreamDataInput(in); wordSet = new CharVectorHashSet(ignoreCase); int size = input.readVInt(); for (int entryInx = 0; entryInx < size; entryInx++) { wordSet.add(new CharVector(input.readUString())); } }
@Override public void readFrom(InputStream in) throws IOException { super.readFrom(in); DataInput input = new InputStreamDataInput(in); wordSet = new CharVectorHashSet(ignoreCase); int size = input.readVInt(); for (int entryInx = 0; entryInx < size; entryInx++) { wordSet.add(new CharVector(input.readUString())); } }
@Override public void readFrom(InputStream in) throws IOException { DataInput input = new InputStreamDataInput(in); map = new CharVectorHashMap<CharVector[]>(ignoreCase); int size = input.readVInt(); for (int entryInx = 0; entryInx < size; entryInx++) { CharVector key = new CharVector(input.readUString()); int valueLength = input.readVInt(); CharVector[] values = new CharVector[valueLength]; for (int valueInx = 0; valueInx < valueLength; valueInx++) { values[valueInx] = new CharVector(input.readUString()); } map.put(key, values); } }
@Override public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { this.fst = new FST<>(dataIn, new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = dataIn.readVInt(); hasPayloads = dataIn.readByte() == 1; } finally { IOUtils.close(input); } return true; }
@Override public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { this.fst = new FST<>(dataIn, new PairOutputs<>( PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = dataIn.readVInt(); hasPayloads = dataIn.readByte() == 1; } finally { IOUtils.close(input); } return true; }
@Override public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { this.fst = new FST<>(dataIn, new PairOutputs<>( PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = dataIn.readVInt(); hasPayloads = dataIn.readByte() == 1; } finally { IOUtils.close(input); } return true; }
@Override public boolean load(InputStream input) throws IOException { DataInput dataIn = new InputStreamDataInput(input); try { this.fst = new FST<>(dataIn, new PairOutputs<>( PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = dataIn.readVInt(); hasPayloads = dataIn.readByte() == 1; } finally { IOUtils.close(input); } return true; }
static void writeFile(Directory directory, String fileName, long size) throws Exception{ IndexOutput o = directory.createOutput(fileName, IOContext.DEFAULT); o.copyBytes(new InputStreamDataInput(new NullInputStream(size)), size); o.close(); }