castor
  1. castor
  2. CASTOR-1029

allow to forget read only objects in long batch processes

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 0.9.6
    • Fix Version/s: None
    • Component/s: JDO
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • Bugzilla Id:
      1892
    • Number of attachments :
      2

      Description

      When using Castor to process data in a long read only batch process the fetched
      objects are all stored in TransactionContext._readOnlyObjects. This hash table
      is not cleared until the end of the transaction. So there may arise problems
      running out of heap memory.
      Well, one way to overcome this would be to use shorter transactions. But I
      think it's better to provide a simple additional method to disable usage of the
      read-only-objects hash table. It avoids reconnecting to the database very
      frequently and increases the performance of the batch process.
      Attached patch implements the new function Database.setRememberReadOnlyObjects
      () to deactivate the read only hash.

      1. castor-1892-forget-ro-objects.patch
        6 kB
        Martin Fuchs
      2. patch-1892.txt
        26 kB
        Ralf Joachim

        Activity

        Hide
        Ralf Joachim added a comment -

        >Would be fine with me. But could you please explain what the
        >name "ReadOffTransaction" stands for? I could think about a new constant with a
        >name like "PlainRead" or "BatchRead" in the Database interface.

        I used 'ReadOffTransaction' as it is a read only without adding the objects read
        to the transaction but I also didn't like that name. Maybe your ideas are
        better. Let's hear suggestions from our contibutors speaking native english

        >Perhaps someone can explain me why the accessMode is translated into an
        >AccessMode object in DatabaseImpl.load() ?
        >Dropping this mapping and just using the enumeration values could perhaps make
        >the code a bit more readable.
        I guess that this has historical reasons and that the one that introduced
        AccessMode don't wanted to change Database interface. If we want to do that now
        we first need to introduce new db.load(... AccessMode) methods and declare the
        old ones as deprecated until we remove them some versions later. We also can
        make code a little easier to read by delegating the short->AccessMode
        translation to the AccessMode class.

        Show
        Ralf Joachim added a comment - >Would be fine with me. But could you please explain what the >name "ReadOffTransaction" stands for? I could think about a new constant with a >name like "PlainRead" or "BatchRead" in the Database interface. I used 'ReadOffTransaction' as it is a read only without adding the objects read to the transaction but I also didn't like that name. Maybe your ideas are better. Let's hear suggestions from our contibutors speaking native english >Perhaps someone can explain me why the accessMode is translated into an >AccessMode object in DatabaseImpl.load() ? >Dropping this mapping and just using the enumeration values could perhaps make >the code a bit more readable. I guess that this has historical reasons and that the one that introduced AccessMode don't wanted to change Database interface. If we want to do that now we first need to introduce new db.load(... AccessMode) methods and declare the old ones as deprecated until we remove them some versions later. We also can make code a little easier to read by delegating the short->AccessMode translation to the AccessMode class.
        Hide
        Martin Fuchs added a comment -

        Well, I though of keeping the Database interface as it's now (just adding a new
        constant for the read-only-dont-remember mode) and dropping the AccessMode
        class.

        Show
        Martin Fuchs added a comment - Well, I though of keeping the Database interface as it's now (just adding a new constant for the read-only-dont-remember mode) and dropping the AccessMode class.
        Hide
        Ralf Joachim added a comment -

        If you search where the AccessMode class is used you may recognize that it will
        be rather complicated to remove it (211 references). In addition I prefer
        enumerations like AccessMode over unrelated short primitives.

        I'll prepare a patch about my ideas to modify AccessMode and clean up Database
        and DatabaseImpl.

        Show
        Ralf Joachim added a comment - If you search where the AccessMode class is used you may recognize that it will be rather complicated to remove it (211 references). In addition I prefer enumerations like AccessMode over unrelated short primitives. I'll prepare a patch about my ideas to modify AccessMode and clean up Database and DatabaseImpl.
        Hide
        Ralf Joachim added a comment -

        Created an attachment (id=989)
        Patch to make usage of AccessMode public

        Show
        Ralf Joachim added a comment - Created an attachment (id=989) Patch to make usage of AccessMode public
        Hide
        Ralf Joachim added a comment -

        Moved refactoring of AccessMode to bug 1933

        Show
        Ralf Joachim added a comment - Moved refactoring of AccessMode to bug 1933

          People

          • Assignee:
            Unassigned
            Reporter:
            Martin Fuchs
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: