2 Replies Latest reply: Jul 23, 2012 5:00 PM by 951211 RSS

    DPL and DiskOrderedCursor

    951211
      I am inserting entities into my database using the DPL with PrimaryIndex.put(). I'm wondering if I should be able to retrieve entities using a DiskOrderedCursor (for optimal read performance) and deserialize them back to my custom entity objects. I've tried using the Bind API (even though I did not use it to serialize the objects on insert), but I get the following error. Is there a better method for this?

      com.sleepycat.util.RuntimeExceptionWrapper: java.io.StreamCorruptedException: invalid type code: 00
           at com.sleepycat.util.RuntimeExceptionWrapper.wrapIfNeeded(RuntimeExceptionWrapper.java:30)
           at com.sleepycat.bind.serial.SerialBinding.entryToObject(SerialBinding.java:142)
        • 1. Re: DPL and DiskOrderedCursor
          greybird
          I'm wondering if I should be able to retrieve entities using a DiskOrderedCursor (for optimal read performance) and deserialize them back to my custom entity objects.
          Yes, you can.
          I've tried using the Bind API (even though I did not use it to serialize the objects on insert), but I get the following error. Is there a better method for this?
          You have the right idea but the problem is that you're using the SerialBinding, which is not the binding used to by the DPL. You can get the DPL's bindings from the DPL itself. See the "Low Level Access" section here:

          http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/persist/EntityIndex.html

          >
          Low Level Access

          Each Direct Persistence Layer index is associated with an underlying Database or SecondaryDatabase defined in the Base API. At this level, an index is a Btree managed by the Berkeley DB Java Edition transactional storage engine. Although you may never need to work at the Base API level, keep in mind that some types of performance tuning can be done by configuring the underlying databases. See the EntityStore class for more information on database and sequence configuration.

          If you wish to access an index using the Base API, you may call the PrimaryIndex.getDatabase() or SecondaryIndex.getDatabase() method to get the underlying database. To translate between entity or key objects and DatabaseEntry objects at this level, use the bindings returned by PrimaryIndex.getEntityBinding(), PrimaryIndex.getKeyBinding(), and SecondaryIndex.getKeyBinding().
          >

          --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
          • 2. Re: DPL and DiskOrderedCursor
            951211
            Perfect, thanks!