use of org.apache.lucene.store.OutputStreamDataOutput in project lucene-solr by apache.
the class ConnectionCostsWriter method write.
public void write(String baseDir) throws IOException {
String filename = baseDir + File.separator + ConnectionCosts.class.getName().replace('.', File.separatorChar) + ConnectionCosts.FILENAME_SUFFIX;
new File(filename).getParentFile().mkdirs();
OutputStream os = new FileOutputStream(filename);
try {
os = new BufferedOutputStream(os);
final DataOutput out = new OutputStreamDataOutput(os);
CodecUtil.writeHeader(out, ConnectionCosts.HEADER, ConnectionCosts.VERSION);
out.writeVInt(forwardSize);
out.writeVInt(backwardSize);
int last = 0;
assert costs.length == backwardSize;
for (short[] a : costs) {
assert a.length == forwardSize;
for (int i = 0; i < a.length; i++) {
int delta = (int) a[i] - last;
out.writeZInt(delta);
last = a[i];
}
}
} finally {
os.close();
}
}
Aggregations