当前位置: 首页>>代码示例>>Java>>正文


Java IOUtils.reThrow方法代码示例

本文整理汇总了Java中org.apache.lucene.util.IOUtils.reThrow方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtils.reThrow方法的具体用法?Java IOUtils.reThrow怎么用?Java IOUtils.reThrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.util.IOUtils的用法示例。


在下文中一共展示了IOUtils.reThrow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMergeException

import org.apache.lucene.util.IOUtils; //导入方法依赖的package包/类
final private void handleMergeException(Throwable t, MergePolicy.OneMerge merge) throws IOException {

    if (infoStream.isEnabled("IW")) {
      infoStream.message("IW", "handleMergeException: merge=" + segString(merge.segments) + " exc=" + t);
    }

    // Set the exception on the merge, so if
    // forceMerge is waiting on us it sees the root
    // cause exception:
    merge.setException(t);
    addMergeException(merge);

    if (t instanceof MergePolicy.MergeAbortedException) {
      // We can ignore this exception (it happens when
      // close(false) or rollback is called), unless the
      // merge involves segments from external directories,
      // in which case we must throw it so, for example, the
      // rollbackTransaction code in addIndexes* is
      // executed.
      if (merge.isExternal) {
        throw (MergePolicy.MergeAbortedException) t;
      }
    } else {
      IOUtils.reThrow(t);
    }
  }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:IndexWriter.java

示例2: testPostings

import org.apache.lucene.util.IOUtils; //导入方法依赖的package包/类
/**
 * Test the term index.
 * @lucene.experimental
 */
public static Status.TermIndexStatus testPostings(AtomicReader reader, PrintStream infoStream, boolean verbose, boolean failFast) throws IOException {

  // TODO: we should go and verify term vectors match, if
  // crossCheckTermVectors is on...

  Status.TermIndexStatus status;
  final int maxDoc = reader.maxDoc();
  final Bits liveDocs = reader.getLiveDocs();

  try {
    if (infoStream != null) {
      infoStream.print("    test: terms, freq, prox...");
    }

    final Fields fields = reader.fields();
    final FieldInfos fieldInfos = reader.getFieldInfos();
    status = checkFields(fields, liveDocs, maxDoc, fieldInfos, true, false, infoStream, verbose);
    if (liveDocs != null) {
      if (infoStream != null) {
        infoStream.print("    test (ignoring deletes): terms, freq, prox...");
      }
      checkFields(fields, null, maxDoc, fieldInfos, true, false, infoStream, verbose);
    }
  } catch (Throwable e) {
    if (failFast) {
      IOUtils.reThrow(e);
    }
    msg(infoStream, "ERROR: " + e);
    status = new Status.TermIndexStatus();
    status.error = e;
    if (infoStream != null) {
      e.printStackTrace(infoStream);
    }
  }

  return status;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:CheckIndex.java

示例3: doClose

import org.apache.lucene.util.IOUtils; //导入方法依赖的package包/类
@Override
protected void doClose() throws IOException {
  Throwable firstExc = null;
  for (final AtomicReader r : getSequentialSubReaders()) {
    // try to close each reader, even if an exception is thrown
    try {
      r.decRef();
    } catch (Throwable t) {
      if (firstExc == null) {
        firstExc = t;
      }
    }
  }

  if (writer != null) {
    try {
      writer.decRefDeleter(segmentInfos);
    } catch (AlreadyClosedException ex) {
      // This is OK, it just means our original writer was
      // closed before we were, and this may leave some
      // un-referenced files in the index, which is
      // harmless.  The next time IW is opened on the
      // index, it will delete them.
    }
  }

  // throw the first exception
  IOUtils.reThrow(firstExc);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:StandardDirectoryReader.java

示例4: testStoredFields

import org.apache.lucene.util.IOUtils; //导入方法依赖的package包/类
/**
 * Test stored fields.
 * @lucene.experimental
 */
public static Status.StoredFieldStatus testStoredFields(AtomicReader reader, PrintStream infoStream, boolean failFast) throws IOException {
  final Status.StoredFieldStatus status = new Status.StoredFieldStatus();

  try {
    if (infoStream != null) {
      infoStream.print("    test: stored fields.......");
    }

    // Scan stored fields for all documents
    final Bits liveDocs = reader.getLiveDocs();
    for (int j = 0; j < reader.maxDoc(); ++j) {
      // Intentionally pull even deleted documents to
      // make sure they too are not corrupt:
      Document doc = reader.document(j);
      if (liveDocs == null || liveDocs.get(j)) {
        status.docCount++;
        status.totFields += doc.getFields().size();
      }
    }      

    // Validate docCount
    if (status.docCount != reader.numDocs()) {
      throw new RuntimeException("docCount=" + status.docCount + " but saw " + status.docCount + " undeleted docs");
    }

    msg(infoStream, "OK [" + status.totFields + " total field count; avg " + 
        NumberFormat.getInstance(Locale.ROOT).format((((float) status.totFields)/status.docCount)) + " fields per doc]");      
  } catch (Throwable e) {
    if (failFast) {
      IOUtils.reThrow(e);
    }
    msg(infoStream, "ERROR [" + String.valueOf(e.getMessage()) + "]");
    status.error = e;
    if (infoStream != null) {
      e.printStackTrace(infoStream);
    }
  }

  return status;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:CheckIndex.java

示例5: testDocValues

import org.apache.lucene.util.IOUtils; //导入方法依赖的package包/类
/**
 * Test docvalues.
 * @lucene.experimental
 */
public static Status.DocValuesStatus testDocValues(AtomicReader reader,
                                                   PrintStream infoStream,
                                                   boolean failFast) throws IOException {
  final Status.DocValuesStatus status = new Status.DocValuesStatus();
  try {
    if (infoStream != null) {
      infoStream.print("    test: docvalues...........");
    }
    for (FieldInfo fieldInfo : reader.getFieldInfos()) {
      if (fieldInfo.hasDocValues()) {
        status.totalValueFields++;
        checkDocValues(fieldInfo, reader, infoStream, status);
      } else {
        if (reader.getBinaryDocValues(fieldInfo.name) != null ||
            reader.getNumericDocValues(fieldInfo.name) != null ||
            reader.getSortedDocValues(fieldInfo.name) != null || 
            reader.getSortedSetDocValues(fieldInfo.name) != null || 
            reader.getDocsWithField(fieldInfo.name) != null) {
          throw new RuntimeException("field: " + fieldInfo.name + " has docvalues but should omit them!");
        }
      }
    }

    msg(infoStream, "OK [" + status.totalValueFields + " docvalues fields; "
                           + status.totalBinaryFields + " BINARY; " 
                           + status.totalNumericFields + " NUMERIC; "
                           + status.totalSortedFields + " SORTED; "
                           + status.totalSortedNumericFields + " SORTED_NUMERIC; "
                           + status.totalSortedSetFields + " SORTED_SET]");
  } catch (Throwable e) {
    if (failFast) {
      IOUtils.reThrow(e);
    }
    msg(infoStream, "ERROR [" + String.valueOf(e.getMessage()) + "]");
    status.error = e;
    if (infoStream != null) {
      e.printStackTrace(infoStream);
    }
  }
  return status;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:CheckIndex.java


注:本文中的org.apache.lucene.util.IOUtils.reThrow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。