Package org.apache.lucene.store

Examples of org.apache.lucene.store.Directory.listAll()


    IndexReader last = readers[size - 1];

    assertEquals(100, last.numDocs());

    assertTrue(listAll.length > directory.listAll().length);

    last.close();
    writer.close();
    gc.close();
  }
View Full Code Here


  private int getMemorySize(Object index) {
    if (index instanceof Directory) {
      try {
        Directory dir = (Directory) index;
        int size = 0;
        String[] fileNames = dir.listAll();
        for (int i=0; i < fileNames.length; i++) {
          size += dir.fileLength(fileNames[i]);
        }
        return size;
      }
View Full Code Here

        writer.close();

        long gen = SegmentInfos.getCurrentSegmentGeneration(dir);
        assertTrue("segment generation should be > 1 but got " + gen, gen > 1);

        String[] files = dir.listAll();
        for(int i=0;i<files.length;i++) {
          if (files[i].endsWith(".cfs")) {
            dir.deleteFile(files[i]);
            break;
          }
View Full Code Here

    indexWriter.close();

    _TestUtil.checkIndex(dir);

    assertNoUnreferencedFiles(dir, "no tv files");
    String[] files = dir.listAll();
    for(String file : files) {
      assertTrue(!file.endsWith(IndexFileNames.VECTORS_FIELDS_EXTENSION));
      assertTrue(!file.endsWith(IndexFileNames.VECTORS_INDEX_EXTENSION));
      assertTrue(!file.endsWith(IndexFileNames.VECTORS_DOCUMENTS_EXTENSION));
    }
View Full Code Here

    Directory directory = new TraceableDirectory(new SlowAccessDirectory(dir));
    IndexReader indexReader = getIndexReader(directory);
    int maxSampleSize = 1000;
    int blockSize = 8192;
    long totalLookups = 0;
    for (String s : directory.listAll()) {
      if (s.endsWith(".pos") || s.endsWith(".doc") || s.endsWith(".tim")) {
        long fileLength = directory.fileLength(s);
        long maxHits = (long) Math.ceil(fileLength / (double) blockSize);
        totalLookups += maxHits;
        System.out.println("file [" + s + "] size [" + fileLength + "] maxhits [" + maxHits + "]");
View Full Code Here

    IndexReader indexReader = getIndexReader(directory);
    int maxSampleSize = 1000;
    int blockSize = 8192;
    // int blockSize = 1024 * 1024;
    long totalLookups = 0;
    for (String s : directory.listAll()) {
      if (s.endsWith(".pos") || s.endsWith(".doc") || s.endsWith(".tim")) {
        long fileLength = directory.fileLength(s);
        long maxHits = (long) Math.ceil(fileLength / (double) blockSize);
        totalLookups += maxHits;
        System.out.println("file [" + s + "] size [" + fileLength + "] maxhits [" + maxHits + "]");
View Full Code Here

  @Override
  public void files(SegmentInfoPerCommit info, Collection<String> files) throws IOException {
    super.files(info, files);
    Directory dir = info.info.dir;
    String[] listAll = dir.listAll();
    for (String file : listAll) {
      if (file.endsWith(FILTER)) {
        if (file.startsWith(info.info.name + SEP) && file.endsWith(FILTER)) {
          files.add(file);
        }
View Full Code Here

        // don't use NRT
        w.commit();
        r = IndexReader.open(dir);
      }

      List<String> files = Arrays.asList(dir.listAll());
      assertTrue(files.contains("_0.cfs"));
      w.addDocument(doc);
      w.optimize();
      if (iter == 1) {
        w.commit();
View Full Code Here

      if (iter == 1) {
        w.commit();
      }
      IndexReader r2 = r.reopen();
      assertTrue(r != r2);
      files = Arrays.asList(dir.listAll());

      // NOTE: here we rely on "Windows" behavior, ie, even
      // though IW wanted to delete _0.cfs since it was
      // optimized away, because we have a reader open
      // against this file, it should still be here:
View Full Code Here

      assertTrue(files.contains("_0.cfs"));
      // optimize created this
      //assertTrue(files.contains("_2.cfs"));
      w.deleteUnusedFiles();

      files = Arrays.asList(dir.listAll());
      // r still holds this file open
      assertTrue(files.contains("_0.cfs"));
      //assertTrue(files.contains("_2.cfs"));

      r.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.