本文整理汇总了Java中org.apache.lucene.benchmark.byTask.utils.StreamUtils类的典型用法代码示例。如果您正苦于以下问题:Java StreamUtils类的具体用法?Java StreamUtils怎么用?Java StreamUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamUtils类属于org.apache.lucene.benchmark.byTask.utils包,在下文中一共展示了StreamUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: WriteLineDocTask
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
public WriteLineDocTask(PerfRunData runData) throws Exception {
super(runData);
Config config = runData.getConfig();
fname = config.get("line.file.out", null);
if (fname == null) {
throw new IllegalArgumentException("line.file.out must be set");
}
OutputStream out = StreamUtils.outputStream(new File(fname));
lineFileOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), StreamUtils.BUFFER_SIZE));
docMaker = runData.getDocMaker();
// init fields
String f2r = config.get("line.fields",null);
if (f2r == null) {
fieldsToWrite = DEFAULT_FIELDS;
} else {
if (f2r.indexOf(SEP)>=0) {
throw new IllegalArgumentException("line.fields "+f2r+" should not contain the separator char: "+SEP);
}
fieldsToWrite = f2r.split(",");
}
// init sufficient fields
sufficientFields = new boolean[fieldsToWrite.length];
String suff = config.get("sufficient.fields",DEFAULT_SUFFICIENT_FIELDS);
if (",".equals(suff)) {
checkSufficientFields = false;
} else {
checkSufficientFields = true;
HashSet<String> sf = new HashSet<>(Arrays.asList(suff.split(",")));
for (int i=0; i<fieldsToWrite.length; i++) {
if (sf.contains(fieldsToWrite[i])) {
sufficientFields[i] = true;
}
}
}
writeHeader(lineFileOut);
}
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:WriteLineDocTask.java
示例2: openFile
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
private synchronized void openFile() {
try {
if (reader != null) {
reader.close();
}
InputStream is = StreamUtils.inputStream(file);
reader = new BufferedReader(new InputStreamReader(is, encoding), StreamUtils.BUFFER_SIZE);
if (skipHeaderLine) {
reader.readLine(); // skip one line - the header line - already handled that info
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:LineDocSource.java
示例3: openNextFile
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
void openNextFile() throws NoMoreDataException, IOException {
close();
currPathType = null;
while (true) {
if (nextFile >= inputFiles.size()) {
// exhausted files, start a new round, unless forever set to false.
if (!forever) {
throw new NoMoreDataException();
}
nextFile = 0;
iteration++;
}
File f = inputFiles.get(nextFile++);
if (verbose) {
System.out.println("opening: " + f + " length: " + f.length());
}
try {
InputStream inputStream = StreamUtils.inputStream(f); // support either gzip, bzip2, or regular text file, by extension
reader = new BufferedReader(new InputStreamReader(inputStream, encoding), StreamUtils.BUFFER_SIZE);
currPathType = TrecDocParser.pathType(f);
return;
} catch (Exception e) {
if (verbose) {
System.out.println("Skipping 'bad' file " + f.getAbsolutePath()+" due to "+e.getMessage());
continue;
}
throw new NoMoreDataException();
}
}
}
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TrecContentSource.java
示例4: WriteLineDocTask
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
public WriteLineDocTask(PerfRunData runData) throws Exception {
super(runData);
Config config = runData.getConfig();
fname = config.get("line.file.out", null);
if (fname == null) {
throw new IllegalArgumentException("line.file.out must be set");
}
OutputStream out = StreamUtils.outputStream(new File(fname));
lineFileOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), StreamUtils.BUFFER_SIZE));
docMaker = runData.getDocMaker();
// init fields
String f2r = config.get("line.fields",null);
if (f2r == null) {
fieldsToWrite = DEFAULT_FIELDS;
} else {
if (f2r.indexOf(SEP)>=0) {
throw new IllegalArgumentException("line.fields "+f2r+" should not contain the separator char: "+SEP);
}
fieldsToWrite = f2r.split(",");
}
// init sufficient fields
sufficientFields = new boolean[fieldsToWrite.length];
String suff = config.get("sufficient.fields",DEFAULT_SUFFICIENT_FIELDS);
if (",".equals(suff)) {
checkSufficientFields = false;
} else {
checkSufficientFields = true;
HashSet<String> sf = new HashSet<String>(Arrays.asList(suff.split(",")));
for (int i=0; i<fieldsToWrite.length; i++) {
if (sf.contains(fieldsToWrite[i])) {
sufficientFields[i] = true;
}
}
}
writeHeader(lineFileOut);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:40,代码来源:WriteLineDocTask.java
示例5: assertReadText
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
private void assertReadText(File f) throws Exception {
InputStream ir = StreamUtils.inputStream(f);
InputStreamReader in = new InputStreamReader(ir, IOUtils.CHARSET_UTF_8);
BufferedReader r = new BufferedReader(in);
String line = r.readLine();
assertEquals("Wrong text found in "+f.getName(), TEXT, line);
r.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:StreamUtilsTest.java
示例6: openNextFile
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
void openNextFile() throws NoMoreDataException, IOException {
close();
while (true) {
if (nextFile >= inputFiles.size()) {
// exhausted files, start a new round, unless forever set to false.
if (!forever) {
throw new NoMoreDataException();
}
nextFile = 0;
iteration++;
}
File f = inputFiles.get(nextFile++);
if (verbose) {
System.out.println("opening: " + f + " length: " + f.length());
}
try {
// supports gzip, bzip2, or regular text file, extension is used to detect
InputStream inputStream = StreamUtils.inputStream(f);
reader = new DataInputStream(inputStream);
return;
} catch (Exception e) {
if (verbose) {
System.out.println("Skipping 'bad' file " + f.getAbsolutePath()+" due to "+e.getMessage());
continue;
}
throw new NoMoreDataException();
}
}
}
开发者ID:searchivarius,项目名称:IndexTextCollect,代码行数:31,代码来源:ClueWeb09ContentSource.java
示例7: WriteEnwikiLineDocTask
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
public WriteEnwikiLineDocTask(PerfRunData runData) throws Exception {
super(runData);
OutputStream out = StreamUtils.outputStream(categoriesLineFile(new File(fname)));
categoryLineFileOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), StreamUtils.BUFFER_SIZE));
writeHeader(categoryLineFileOut);
}
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:WriteEnwikiLineDocTask.java
示例8: openInputStream
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
/** Open the input stream. */
protected InputStream openInputStream() throws IOException {
return StreamUtils.inputStream(file);
}
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:EnwikiContentSource.java
示例9: WriteEnwikiLineDocTask
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
public WriteEnwikiLineDocTask(PerfRunData runData) throws Exception {
super(runData);
OutputStream out = StreamUtils.outputStream(categoriesLineFile(new File(fname)));
categoryLineFileOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), StreamUtils.BUFFER_SIZE));
writeHeader(categoryLineFileOut);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:7,代码来源:WriteEnwikiLineDocTask.java
示例10: autoOutFile
import org.apache.lucene.benchmark.byTask.utils.StreamUtils; //导入依赖的package包/类
private File autoOutFile(String ext) throws Exception {
File f = new File(testDir,"testfile." + ext);
OutputStream os = StreamUtils.outputStream(f);
writeText(os);
return f;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:7,代码来源:StreamUtilsTest.java
注:本文中的org.apache.lucene.benchmark.byTask.utils.StreamUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论