Example usage for org.apache.lucene.index IndexWriter numRamDocs

List of usage examples for org.apache.lucene.index IndexWriter numRamDocs

Introduction

In this page you can find the example usage for org.apache.lucene.index IndexWriter numRamDocs.

Prototype

public final synchronized int numRamDocs() 

Source Link

Document

Expert: Return the number of documents currently buffered in RAM.

Usage

From source file:org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorContext.java

License:Apache License

private static void trackIndexSizeInfo(@Nonnull IndexWriter writer, @Nonnull IndexDefinition definition,
        @Nonnull Directory directory) throws IOException {
    checkNotNull(writer);/*from  www . ja v a2  s.co  m*/
    checkNotNull(definition);
    checkNotNull(directory);

    int docs = writer.numDocs();
    int ram = writer.numRamDocs();

    log.trace("Writer for direcory {} - docs: {}, ramDocs: {}", definition, docs, ram);

    String[] files = directory.listAll();
    long overallSize = 0;
    StringBuilder sb = new StringBuilder();
    for (String f : files) {
        sb.append(f).append(":");
        if (directory.fileExists(f)) {
            long size = directory.fileLength(f);
            overallSize += size;
            sb.append(size);
        } else {
            sb.append("--");
        }
        sb.append(", ");
    }
    log.trace("Directory overall size: {}, files: {}",
            org.apache.jackrabbit.oak.commons.IOUtils.humanReadableByteCount(overallSize), sb.toString());
}