TWiki> Persistency Web>Cool>CoolVectorPayload (revision 1)EditAttachPDF
COOL now supports different modes for storing payloads in folders:
  • inline payload ( the default mode )
  • separate table mode
  • vector payload mode

If the separate table mode is used, the payload of the IOVs is internally stored in a separate table. If this mode is used, multi version folders with large payloads will use less space in the database, since the so called system-objects don't duplicate the payload but refer to the payload in the separate table. There is no difference in the client API using this mode. This mode is succeeded by the vector payload mode, which has more features, so it probably makes more sense to use the vector payload mode, if you have the choice.

The vector payload mode is related to the separate payload mode, but in addition it allows several payload records, or even zero payload records to be associated with one IOV. The number of payload records is varialbe from IOV to IOV. The payload is also stored in a separate table, which means that this mode also has the advantage of less overhead for system-objects, but internally the separate payload mode is different from this mode.

To access the payload records in vector payload mode, the new payloadIterator() method of the IObject interface should be used, which returns an iterator similar to the record iterator. It is still possible to use the old interface using the payload() method of the IObject interface, but you will only get access to the first payload record using this method. It is not recommended to use the old interface on vector payload folders.

To store records vectors of IRecordPtr are used with a new storeObject() method in the IFolder interface.

Here is a short PyCool example for the vector folder mode:

#!/bin/env python
from PyCool import cool

def dataPtr(i,j,c):
  data = cool.PyCool.Helpers.IRecordPtr(  spec  )
  data.get()['i'] = i
  data.get()['j'] = j
  data.get()['c'] = c
  return data

connectString = 'sqlite://;schema=COOLTEST.db;dbname=COOLTEST'

dbSvc = cool.DatabaseSvcFactory.databaseService()
print 'dropping database', connectString
dbSvc.dropDatabase( connectString )

print 'creating database'
db = dbSvc.createDatabase( connectString )

print 'setting up spec'
spec = cool.RecordSpecification()
spec.extend( 'i', cool.StorageType.Int32 )
spec.extend( 'j', cool.StorageType.Int32 )
spec.extend( 'c', cool.StorageType.Int32 )
 
# Create the MV folder specification with vector payload mode
folderSpec = cool.FolderSpecification( cool.FolderVersioning.SINGLE_VERSION, 
                                       spec, 
                                       cool.PayloadMode.VECTORPAYLOAD );

print 'creating folder'
f = db.createFolder( "/folder", folderSpec )

print 'filling folder'
f.setupStorageBuffer()
for c in range(0,2):
  for i in range(0,5):
      v = cool.IRecordVector()
      for j in range(0, i ):
          v.push_back( dataPtr(i,j,c) )
      f.storeObject( i, i+1, v , c )
f.flushStorageBuffer()

# Reading back data:
i = f.browseObjects( 0, 1000, cool.ChannelSelection.all() )
print "# of IOVs: %d" % i.size()
for obj in i:
  print "IOV [%d, %d[ c:%s " % ( obj.since(), obj.until(), obj.channelId() );
  for p in obj.payloadIterator():
    print "  %s" % p

-- MartinWache - 14-Oct-2010

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2010-10-14 - unknown
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Persistency All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback