當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexOutput.writeStringStringMap方法代碼示例

本文整理匯總了Java中org.apache.lucene.store.IndexOutput.writeStringStringMap方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexOutput.writeStringStringMap方法的具體用法?Java IndexOutput.writeStringStringMap怎麽用?Java IndexOutput.writeStringStringMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.store.IndexOutput的用法示例。


在下文中一共展示了IndexOutput.writeStringStringMap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import org.apache.lucene.store.IndexOutput; //導入方法依賴的package包/類
/** Save a single segment's info. */
@Override
public void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene40SegmentInfoFormat.SI_EXTENSION);
  si.addFile(fileName);

  final IndexOutput output = dir.createOutput(fileName, ioContext);

  boolean success = false;
  try {
    CodecUtil.writeHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
    // Write the Lucene version that created this segment, since 3.1
    output.writeString(si.getVersion().toString());
    output.writeInt(si.getDocCount());

    output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
    output.writeStringStringMap(si.getDiagnostics());
    output.writeStringStringMap(Collections.<String,String>emptyMap());
    output.writeStringSet(si.files());

    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(output);
      // TODO: why must we do this? do we not get tracking dir wrapper?
      IOUtils.deleteFilesIgnoringExceptions(si.dir, fileName);
    } else {
      output.close();
    }
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:Lucene40SegmentInfoWriter.java

示例2: write

import org.apache.lucene.store.IndexOutput; //導入方法依賴的package包/類
/** Save a single segment's info. */
@Override
public void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene46SegmentInfoFormat.SI_EXTENSION);
  si.addFile(fileName);

  final IndexOutput output = dir.createOutput(fileName, ioContext);

  boolean success = false;
  try {
    CodecUtil.writeHeader(output, Lucene46SegmentInfoFormat.CODEC_NAME, Lucene46SegmentInfoFormat.VERSION_CURRENT);
    Version version = si.getVersion();
    if (version.major < 3 || version.major > 4) {
      throw new IllegalArgumentException("invalid major version: should be 3 or 4 but got: " + version.major + " segment=" + si);
    }
    // Write the Lucene version that created this segment, since 3.1
    output.writeString(version.toString());
    output.writeInt(si.getDocCount());

    output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
    output.writeStringStringMap(si.getDiagnostics());
    output.writeStringSet(si.files());
    CodecUtil.writeFooter(output);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(output);
      // TODO: are we doing this outside of the tracking wrapper? why must SIWriter cleanup like this?
      IOUtils.deleteFilesIgnoringExceptions(si.dir, fileName);
    } else {
      output.close();
    }
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:Lucene46SegmentInfoWriter.java

示例3: write3xInfo

import org.apache.lucene.store.IndexOutput; //導入方法依賴的package包/類
@Deprecated
public static String write3xInfo(Directory dir, SegmentInfo si, IOContext context) throws IOException {

  // Defensive check: we are about to write this SI in 3.x format, dropping all codec information, etc.
  // so it had better be a 3.x segment or you will get very confusing errors later.
  if ((si.getCodec() instanceof Lucene3xCodec) == false) {
    throw new IllegalStateException("cannot write 3x SegmentInfo unless codec is Lucene3x (got: " + si.getCodec() + ")");
  }

  // NOTE: this is NOT how 3.x is really written...
  String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfoFormat.UPGRADED_SI_EXTENSION);
  si.addFile(fileName);

  //System.out.println("UPGRADE write " + fileName);
  boolean success = false;
  IndexOutput output = dir.createOutput(fileName, context);
  try {
    CodecUtil.writeHeader(output, Lucene3xSegmentInfoFormat.UPGRADED_SI_CODEC_NAME, 
                                  Lucene3xSegmentInfoFormat.UPGRADED_SI_VERSION_CURRENT);
    // Write the Lucene version that created this segment, since 3.1
    output.writeString(si.getVersion().toString());
    output.writeInt(si.getDocCount());

    output.writeStringStringMap(si.attributes());

    output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
    output.writeStringStringMap(si.getDiagnostics());
    output.writeStringSet(si.files());

    output.close();

    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(output);
      try {
        si.dir.deleteFile(fileName);
      } catch (Throwable t) {
        // Suppress so we keep throwing the original exception
      }
    }
  }

  return fileName;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:SegmentInfos.java


注:本文中的org.apache.lucene.store.IndexOutput.writeStringStringMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。