Package org.apache.lucene.store

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


      try {
        Directory dir = (Directory) index;
        int size = 0;
        String[] fileNames = dir.list();
        for (int i=0; i < fileNames.length; i++) {
          size += dir.fileLength(fileNames[i]);
        }
        return size;
      }
      catch (IOException e) { // can never happen (RAMDirectory)
        throw new RuntimeException(e);
View Full Code Here


      bw.write(" <files count='" + dir.listAll().length + "'>\n");
      String[] files = dir.listAll();
      Arrays.sort(files);
      for (String file : files) {
        bw.write("  <file name='" + file +
            "' size='" + dir.fileLength(file) +
            "' func='" + IndexGate.getFileFunction(file) + "'/>\n");
      }
      bw.write(" </files>\n");
      List<IndexCommit> commits = DirectoryReader.listCommits(dir);
      bw.write(" <commits count='" + commits.size() + "'>\n");
View Full Code Here

  @Test
  public void testEOF() throws IOException {
    Directory fsDir = new RAMDirectory();
    String name = "test.eof";
    createFile(name, fsDir, directory);
    long fsLength = fsDir.fileLength(name);
    long hdfsLength = directory.fileLength(name);
    assertEquals(fsLength, hdfsLength);
    testEof(name, fsDir, fsLength);
    testEof(name, directory, hdfsLength);
  }
View Full Code Here

  @Test
  public void testEOF() throws IOException {
    Directory fsDir = FSDirectory.open(new File(file, "normal"));
    String name = "test.eof";
    createFile(name, fsDir, directory);
    long fsLength = fsDir.fileLength(name);
    long hdfsLength = directory.fileLength(name);
    assertEquals(fsLength, hdfsLength);
    testEof(name, fsDir, fsLength);
    testEof(name, directory, hdfsLength);
  }
View Full Code Here

      int numToClear = random().nextInt(5);
      for(int i=0;i<numToClear;i++) {
        bv.clear(random().nextInt(numBits));
      }
      bv.write(d, "test", newIOContext(random()));
      final long size = d.fileLength("test");
      assertTrue("size=" + size, size < 100);
      d.close();
    }

    public void testClearedBitNearEnd() throws IOException {
View Full Code Here

    if (dir == null) {
      LOG.info("Context [{0}] cannot find segment [{1}]", context, segmentName);
      return;
    }
    if (endingPosition == Long.MAX_VALUE) {
      endingPosition = dir.fileLength(fileName) - 1;
    }
    if (_isClosed.get()) {
      LOG.info("Context [{0}] index closed", context);
      return;
    }
View Full Code Here

      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;
      }
      catch (IOException e) { // can never happen (RAMDirectory)
        throw new RuntimeException(e);
View Full Code Here

    System.out.print(end.getTime() - start.getTime());
    System.out.println(" milliseconds to write table");

    System.out.println(" table occupies " +
           store.fileLength("words.tis") + " bytes");

    start = new Date();

    TermInfosReader reader = new TermInfosReader(store, "words", fis);
View Full Code Here

  @Test
  public void testEOF() throws IOException {
    Directory fsDir = FSDirectory.open(new File(file, "normal"));
    String name = "test.eof";
    createFile(name, fsDir, directory);
    long fsLength = fsDir.fileLength(name);
    long hdfsLength = directory.fileLength(name);
    assertEquals(fsLength, hdfsLength);
    testEof(name, fsDir, fsLength);
    testEof(name, directory, hdfsLength);
  }
View Full Code Here

    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

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.