FAQ
Seeing strange behavior with RAMDirectory. Is a file designed to supported
IndexOutput being open concurrently with IndexInput? I open an IndexInput
with IndexOutput open, with data written to the file previously, and the
IndexInput is reporting a filelength of 0, while Directory.fileLength()
reports 110. Also seeing other strange behavior.

Search Discussions

  • Yonik Seeley at Jun 19, 2008 at 4:51 pm
    Did you try calling flush() on the IndexOutput before opening the IndexInput?

    -Yonik

    On Thu, Jun 19, 2008 at 12:13 PM, Jason Rutherglen
    wrote:
    Seeing strange behavior with RAMDirectory. Is a file designed to supported
    IndexOutput being open concurrently with IndexInput? I open an IndexInput
    with IndexOutput open, with data written to the file previously, and the
    IndexInput is reporting a filelength of 0, while Directory.fileLength()
    reports 110. Also seeing other strange behavior.
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Jason Rutherglen at Jun 19, 2008 at 7:00 pm
    Yes. Also close. But then reopen the IndexOutput again later, then open
    the IndexInput. I'm not sure if this is the recomended usage of these
    APIs. It seems everywhere else in the Lucene code base only one is open at
    a time.
    On Thu, Jun 19, 2008 at 12:50 PM, Yonik Seeley wrote:

    Did you try calling flush() on the IndexOutput before opening the
    IndexInput?

    -Yonik

    On Thu, Jun 19, 2008 at 12:13 PM, Jason Rutherglen
    wrote:
    Seeing strange behavior with RAMDirectory. Is a file designed to supported
    IndexOutput being open concurrently with IndexInput? I open an
    IndexInput
    with IndexOutput open, with data written to the file previously, and the
    IndexInput is reporting a filelength of 0, while Directory.fileLength()
    reports 110. Also seeing other strange behavior.
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Jason Rutherglen at Jun 19, 2008 at 7:11 pm
    Here's code that reproduces it.

    public void testMain() throws IOException {
    RAMDirectory ramDirectory = new RAMDirectory();
    IndexOutput output = ramDirectory.createOutput("test");
    byte[] bytes = "hello world".getBytes("UTF-8");
    output.writeBytes(bytes, bytes.length);
    output.flush();
    System.out.println("fileLength: "+ramDirectory.fileLength("test"));
    output = ramDirectory.createOutput("test");
    IndexInput input = ramDirectory.openInput("test");
    System.out.println("input length: "+input.length());
    }
    On Thu, Jun 19, 2008 at 2:59 PM, Jason Rutherglen wrote:

    Yes. Also close. But then reopen the IndexOutput again later, then open
    the IndexInput. I'm not sure if this is the recomended usage of these
    APIs. It seems everywhere else in the Lucene code base only one is open at
    a time.

    On Thu, Jun 19, 2008 at 12:50 PM, Yonik Seeley wrote:

    Did you try calling flush() on the IndexOutput before opening the
    IndexInput?

    -Yonik

    On Thu, Jun 19, 2008 at 12:13 PM, Jason Rutherglen
    wrote:
    Seeing strange behavior with RAMDirectory. Is a file designed to supported
    IndexOutput being open concurrently with IndexInput? I open an
    IndexInput
    with IndexOutput open, with data written to the file previously, and the
    IndexInput is reporting a filelength of 0, while Directory.fileLength()
    reports 110. Also seeing other strange behavior.
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Yonik Seeley at Jun 19, 2008 at 7:21 pm
    createOutput() creates a new file, overwriting the old one.
    If you open the IndexInput before you call createOutput() for the 2nd
    time, you should see the file.

    And you definitely shouldn't have more than one IndexOutput open on
    the same file (but that's not your problem here).

    -Yonik

    On Thu, Jun 19, 2008 at 3:10 PM, Jason Rutherglen
    wrote:
    public void testMain() throws IOException {
    RAMDirectory ramDirectory = new RAMDirectory();
    IndexOutput output = ramDirectory.createOutput("test");
    byte[] bytes = "hello world".getBytes("UTF-8");
    output.writeBytes(bytes, bytes.length);
    output.flush();
    System.out.println("fileLength: "+ramDirectory.fileLength("test"));
    output = ramDirectory.createOutput("test");
    IndexInput input = ramDirectory.openInput("test");
    System.out.println("input length: "+input.length());
    }
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Jason Rutherglen at Jun 19, 2008 at 7:33 pm
    Looks like it cannot be used for a log system that needs concurrent read
    write access to a file. Back to RandomAccessFile which will have buffering
    issues, any experience with http://reader.imagero.com/uio/
    On Thu, Jun 19, 2008 at 3:20 PM, Yonik Seeley wrote:

    createOutput() creates a new file, overwriting the old one.
    If you open the IndexInput before you call createOutput() for the 2nd
    time, you should see the file.

    And you definitely shouldn't have more than one IndexOutput open on
    the same file (but that's not your problem here).

    -Yonik

    On Thu, Jun 19, 2008 at 3:10 PM, Jason Rutherglen
    wrote:
    public void testMain() throws IOException {
    RAMDirectory ramDirectory = new RAMDirectory();
    IndexOutput output = ramDirectory.createOutput("test");
    byte[] bytes = "hello world".getBytes("UTF-8");
    output.writeBytes(bytes, bytes.length);
    output.flush();
    System.out.println("fileLength: "+ramDirectory.fileLength("test"));
    output = ramDirectory.createOutput("test");
    IndexInput input = ramDirectory.openInput("test");
    System.out.println("input length: "+input.length());
    }
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Jason Rutherglen at Jun 19, 2008 at 8:43 pm
    Created a RAMDirectory like directory class that uses
    ByteArrayRandomAccessIO from http://reader.imagero.com/uio/ to allow
    concurrent random file access.
    On Thu, Jun 19, 2008 at 3:33 PM, Jason Rutherglen wrote:

    Looks like it cannot be used for a log system that needs concurrent read
    write access to a file. Back to RandomAccessFile which will have buffering
    issues, any experience with http://reader.imagero.com/uio/
    On Thu, Jun 19, 2008 at 3:20 PM, Yonik Seeley wrote:

    createOutput() creates a new file, overwriting the old one.
    If you open the IndexInput before you call createOutput() for the 2nd
    time, you should see the file.

    And you definitely shouldn't have more than one IndexOutput open on
    the same file (but that's not your problem here).

    -Yonik

    On Thu, Jun 19, 2008 at 3:10 PM, Jason Rutherglen
    wrote:
    public void testMain() throws IOException {
    RAMDirectory ramDirectory = new RAMDirectory();
    IndexOutput output = ramDirectory.createOutput("test");
    byte[] bytes = "hello world".getBytes("UTF-8");
    output.writeBytes(bytes, bytes.length);
    output.flush();
    System.out.println("fileLength: "+ramDirectory.fileLength("test"));
    output = ramDirectory.createOutput("test");
    IndexInput input = ramDirectory.openInput("test");
    System.out.println("input length: "+input.length());
    }
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedJun 19, '08 at 4:13p
activeJun 19, '08 at 8:43p
posts7
users2
websitelucene.apache.org

2 users in discussion

Jason Rutherglen: 5 posts Yonik Seeley: 2 posts

People

Translate

site design / logo © 2022 Grokbase