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


Java Directory.fileLength方法代码示例

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


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

示例1: fitsIntoMem

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
private static boolean fitsIntoMem(@NonNull final Directory dir) {
    try {
        long size = 0;
        for (String path : dir.listAll()) {
            size+=dir.fileLength(path);
        }
        return IndexCacheFactory.getDefault().getRAMController().shouldLoad(size);
    } catch (IOException ioe) {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LuceneIndex.java

示例2: addRecoveredFileDetails

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
private void addRecoveredFileDetails(SegmentInfos si, Store store, RecoveryState.Index index) throws IOException {
    final Directory directory = store.directory();
    for (String name : Lucene.files(si)) {
        long length = directory.fileLength(name);
        index.addFileDetail(name, length, true);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:StoreRecovery.java

示例3: estimateSize

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
private static long estimateSize(Directory directory) throws IOException {
    long estimatedSize = 0;
    String[] files = directory.listAll();
    for (String file : files) {
        try {
            estimatedSize += directory.fileLength(file);
        } catch (NoSuchFileException | FileNotFoundException | AccessDeniedException e) {
            // ignore, the file is not there no more; on Windows, if one thread concurrently deletes a file while
            // calling Files.size, you can also sometimes hit AccessDeniedException
        }
    }
    return estimatedSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:Store.java

示例4: main

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception{
    File samplesFilesDir = new File("build/classes/ensemble/");
    File indexDir = new File("build/classes/ensemble/search/index");
    File docDir = new File("../../../artifacts/sdk/docs/api");
    File samplesDir = new File("src/ensemble/samples");
    // create index
    ///System.out.println("Indexing to directory '" + indexDir + "'...");
    long start = System.currentTimeMillis();
    Directory dir = FSDirectory.open(indexDir);
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);
    IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer);
    iwc.setOpenMode(OpenMode.CREATE);
    // generate and write index of all java doc and samples
    IndexWriter writer = new IndexWriter(dir, iwc);

    List<String> samplesFileList = new ArrayList<String>();

    indexSamples(writer, samplesDir, samplesFileList);
    try {
        indexJavaDocAllClasses(writer, docDir);
    } catch (Exception e) {
        System.out.println("\nWarning: We were not able to locate the JavaFX API documentation for your build environment.\n"
                + "Ensemble search will not include the API documentation.\n"); 
    }
    writer.close();
    // create a listAll.txt file that is used
    FileWriter listAllOut = new FileWriter(new File(indexDir,"listAll.txt"));
    for (String fileName: dir.listAll()) {
        if (!"listAll.txt".equals(fileName)) { // don't include the "listAll.txt" file
            Long length = dir.fileLength(fileName);
            listAllOut.write(fileName);
            listAllOut.write(':');
            listAllOut.write(length.toString());
            listAllOut.write('\n');
        }
    }
    listAllOut.flush();
    listAllOut.close();

    FileWriter sampleFilesCache = new FileWriter(new File(samplesFilesDir,"samplesAll.txt"));
    for (String oneSample: samplesFileList) {
            sampleFilesCache.write(oneSample);
            sampleFilesCache.write('\n');
    }
    sampleFilesCache.flush();
    sampleFilesCache.close();

    // print time taken
    ///System.out.println(System.currentTimeMillis() - start + " total milliseconds");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:51,代码来源:BuildEnsembleSearchIndex.java

示例5: TermInfosReader

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
TermInfosReader(Directory dir, String seg, FieldInfos fis, IOContext context, int indexDivisor)
     throws CorruptIndexException, IOException {
  boolean success = false;

  if (indexDivisor < 1 && indexDivisor != -1) {
    throw new IllegalArgumentException("indexDivisor must be -1 (don't load terms index) or greater than 0: got " + indexDivisor);
  }

  try {
    directory = dir;
    segment = seg;
    fieldInfos = fis;

    origEnum = newSegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_EXTENSION),
                                                       context), fieldInfos, false);
    size = origEnum.size;


    if (indexDivisor != -1) {
      // Load terms index
      totalIndexInterval = origEnum.indexInterval * indexDivisor;

      final String indexFileName = IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION);
      final SegmentTermEnum indexEnum = newSegmentTermEnum(directory.openInput(indexFileName,
                                                                                 context), fieldInfos, true);

      try {
        index = new TermInfosReaderIndex(indexEnum, indexDivisor, dir.fileLength(indexFileName), totalIndexInterval);
        indexLength = index.length();
      } finally {
        indexEnum.close();
      }
    } else {
      // Do not load terms index:
      totalIndexInterval = -1;
      index = null;
      indexLength = -1;
    }
    success = true;
  } finally {
    // With lock-less commits, it's entirely possible (and
    // fine) to hit a FileNotFound exception above. In
    // this case, we want to explicitly close any subset
    // of things that were opened so that we don't have to
    // wait for a GC to do so.
    if (!success) {
      close();
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:TermInfosReader.java


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