Thanks Kevin.   I agree reverting to the original code is the right decision until the "optimized" one is fixed.

alex


On Thu, May 29, 2008 at 10:20 PM, Kevin Day <kevin@trumpetinc.com> wrote:
Thomas-

Sorry for the slow response.  I agree that this is an issue.

I have committed a new version of the BlockIo unit test that shows the failure.

It appears that the getLong code contributed by Erwin may have a problem with it - I don't have the energy to debug this (I hate doing bit operations in Java - all the casting and masking is a major hassle), so my recommendation is to switch back to the
original code (or maybe shoot Erwin an email and ask if he has a fix??).

I have comitted code to remove Erwin's algorithm and go back to Alex's original code.  There will be a performancy penalty for this change, but I made the executive decision that it's more important to have correct code than fast code.  If anyone wants
to debug Erwin's algorithm and re-instate it, please go for it!  (I suspect that Brian will be keenly interested in not taking the performance hit).

If you check out the latest from CVS, your problem should be gone.

- K

Kevin Day
Trumpet, Inc.
www.trumpetinc.com



----------------------- Original Message -----------------------

From: "Thomas Elster" <elster20@hotmail.com>
To: <jdbm-developer@lists.sourceforge.net>
Cc:
Date: Sat, 10 May 2008 16:21:26 +0300
Subject: [Jdbm-developer] readLong and writeLong of BlockIo

Hello,

I noticed that the current readLong() method of BlockIo, cannot correctly return a value larger than Integer.MAX_VALUE.
At least not if the long is written with the corresponding writeLong() method of BlockIo. The below code simulates the issue:



  public static void main(String[] args) {
      byte[] data = new byte[8];
      long testLong = Integer.MAX_VALUE;
      testLong += 1;

      BlockIo block = new BlockIo(0, data);
      block.writeLong(0, testLong);
      long shouldBeSame = block.readLong(0);

      System.out.println("Written: " + testLong);
      System.out.println("Read: " + shouldBeSame);
      if (testLong != shouldBeSame)
          System.err.println("Warning! Written and read are not the same...");
      else
          System.out.println("Success. They are the same...");
  }



I use the latest source from the CVS by the way.
I dont know if this is an issue at all, maybe the longs in BlockIo never gets above Integer.MAX_VALUE anyway. I just noticed it, because
I used the same code for linking some logical row ids with eachother ( returned from RecordManager.insert() ), and got errors because
some of the logical ids indeed gets above Integer.MAX_VALUE after a lot of inserts. The original riginal version of readLong() by Alex Boisvert
works without problems in all cases.

I just thought I would let you know. And thanks to everyone here for a great and usefull software.

Best Regards,
Thomas
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone


_______________________________________________
Jdbm-developer mailing list
Jdbm-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jdbm-developer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jdbm-developer mailing list
Jdbm-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jdbm-developer