[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BLOB question - Subclassing BLOBContainerImpl



I have been using Ozone blobs a lot the past two months and the scenario 
you describe sounds similar to one I experienced at first. In my case, the 
problem was that I wasn't using explicit transactions when I created and 
wrote to the BLOB (these are necessary for use specifically with BLOBs - a 
little bit of documentation can be found under ExternalTransactions in the 
API docs).  When I didn't use explicit transactions, the BLOB was created 
and persisted, but the data didn't.  In case your situation is similar, 
here's a sample of code that worked for me:

         // Connect to database:
         System.out.println( "Connecting to database..." );
         LocalDatabase db = new LocalDatabase();
         db.open ("C:\\projects\\spatialBlob\\oz",  0, "tear", "");
         db.reloadClasses();
         System.out.println( "Connected." );

         //*****
         ExternalTransaction tx = db.newTransaction();
         tx.begin();
                 System.out.println( "Transaction started..." );
         //****

         // Create a new BLOB:
         System.out.println( "Creating BLOB..." );
         String name = "BLOB1";
         blob = (BLOBContainer)db.createObject( 
BLOBContainerImpl.class.getName(), 0, name );
         System.out.println( "BLOB created." );

         // Initialize BLOB (set page size):
         blob.init(blobPageSize);
         System.out.println( "Blob page size: " + blobPageSize);


         [....WRITE TO BLOB...]


         //****
         tx.commit();
                 System.out.println( "Transaction committed." );
         //****

Note: In the tests that I did it appeared to be necessary to create and 
write to the BLOB within the same transaction (although I don't know why 
this should be the case).

Also note: Ozone appears to do a pretty good job of compressing the data 
within the BLOBs so sometimes the actual size of the data in the ozone 
files will be much smaller than the data is in uncompressed form.

Hope this is useful.

David Olivier

At 07:26 PM 7/31/2001 -0400, John Derrick wrote:
>I've been working with Ozone for the last 3 weeks and it's impressive. 
>What a great find. I hope that all the contributors to Ozone have a real 
>sense of accomplishment and pride in their efforts. Let's see what you can 
>do next!
>
>I'm hoping someone may be able to help me with a design issue I'm 
>currently wrestling with. I'm working on an application where I want to 
>use a BLOBContainers to store the contents of  HTML documents. Currently 
>I'm using a Vector to store the collection of documents.
>
>In one approach I defined a "Document" class as an OzoneObject.  The class 
>contained a BLOBContainer. When running the application, I noted that the 
>clusters being created didn't look like they were using BLOB pages. I 
>arrived at this conclusion by seeing that the cluster size was 64k or 
>less. I noticed when doing some prototyping and creating BLOBContainers 
>directly (rather than having them contained in a persistent object) that 
>the cluster size was over 100k.
>
>In the second approach, I made the "Document" class a subclass of 
>BLOBContainerImpl. (i.e. I had an interface "Document" that extends 
>BLOBContainer and a class DocumentImpl that extends BLOBContainerImpl and 
>implements Document).  This also resulted in the same problem where it 
>appears BLOB pages are not being used.
>
>Is it required that the BLOBContainerImpl class NOT be subclassed to work 
>properly? Or am I simply doing something wrong? I'd be grateful for any 
>suggestions.
>

----------------------------------------------------------------------
Post a message:         mailto:ozone-users@ozone-db.org
Unsubscribe:            mailto:ozone-users-request@ozone-db.org?body=unsubscribe
Contact administrator:  mailto:ozone-users-owner@ozone-db.org
Read archived messages: http://www.ozone-db.org/
----------------------------------------------------------------------