本文整理汇总了Java中org.apache.lucene.util.OfflineSorter.ByteSequencesWriter方法的典型用法代码示例。如果您正苦于以下问题:Java OfflineSorter.ByteSequencesWriter方法的具体用法?Java OfflineSorter.ByteSequencesWriter怎么用?Java OfflineSorter.ByteSequencesWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.OfflineSorter
的用法示例。
在下文中一共展示了OfflineSorter.ByteSequencesWriter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExternalRefSorter
import org.apache.lucene.util.OfflineSorter; //导入方法依赖的package包/类
/**
* Will buffer all sequences to a temporary file and then sort (all on-disk).
*/
public ExternalRefSorter(OfflineSorter sort) throws IOException {
this.sort = sort;
this.input = File.createTempFile("RefSorter-", ".raw",
OfflineSorter.defaultTempDir());
this.writer = new OfflineSorter.ByteSequencesWriter(input);
}
示例2: sort
import org.apache.lucene.util.OfflineSorter; //导入方法依赖的package包/类
private ByteSequencesReader sort() throws IOException {
String prefix = getClass().getSimpleName();
File directory = OfflineSorter.defaultTempDir();
tempInput = File.createTempFile(prefix, ".input", directory);
tempSorted = File.createTempFile(prefix, ".sorted", directory);
final OfflineSorter.ByteSequencesWriter writer = new OfflineSorter.ByteSequencesWriter(tempInput);
boolean success = false;
try {
BytesRef spare;
byte[] buffer = new byte[0];
ByteArrayDataOutput output = new ByteArrayDataOutput(buffer);
while ((spare = source.next()) != null) {
encode(writer, output, buffer, spare, source.payload(), source.contexts(), source.weight());
}
writer.close();
new OfflineSorter(tieBreakByCostComparator).sort(tempInput, tempSorted);
ByteSequencesReader reader = new OfflineSorter.ByteSequencesReader(tempSorted);
success = true;
return reader;
} finally {
if (success) {
IOUtils.close(writer);
} else {
try {
IOUtils.closeWhileHandlingException(writer);
} finally {
close();
}
}
}
}
示例3: writeAll
import org.apache.lucene.util.OfflineSorter; //导入方法依赖的package包/类
private File writeAll(String name, byte[][] data) throws IOException {
File file = new File(tempDir, name);
ByteSequencesWriter w = new OfflineSorter.ByteSequencesWriter(file);
for (byte [] datum : data) {
w.write(datum);
}
w.close();
return file;
}