I/O Version 2 Notes
I/O Simplification
One of the goals of Version 2 is simplification with the new serializers
and one mechanism.
Goals of simplification
-
Reliance on HDF unnecessary
-
Make full use of standard library
-
Elimination of records classes in favor of simple serialization
-
Option to use simple serialization to files instead of object sets in certain
circumstances
-
Make implementation of parallel version straightforward
Rough design sketch:
Scenario: creating a new object set, storing an instance of an object,
and closing the set
-
Client creates and opens an object set
ObjectSet obset("simData.db", StdStorage,
storageOut);
-
ObjectSet constructor creates and opens a pointer to StorageSet as a member
variable
set_m = new StorageSet(name, type,
accessMode);
-
StorageSet constructor constructs a pointer to the appropriate specialization
of StorageResource as member variable
resource_m= new StdStorageResource(name,
accessMode);
-
ObjectSet sets the number of types to zero
numTypes_m =0;
-
ObjectSet gets a byte array pointer and handle for the master boot record
array
objectSetArray_m= set_m->newArray(parameters);
objectSetArrayID= objectSetArray_m->id();
-
ObjectSet gets a byte array pointer and handle for the type record array
typeRecsArray_m= set_m->newArray(parameters);
typeRecsArrayID_m= typeRecsArray_m->id();
-
Client asks the object set to store an instance of Foo
Foo f;
...
long fooID= obset.store(f, "myFoo");
-
ObjectSet constructs type of StorageAdapter for Foo
StorageAdapter<T> a(this);
-
Constructor for StorageAdapter<Foo> constructs itself and the constructor
for its base class, StorageAdapterBase(ObjectSet* s), keeps a pointer to
the invoking object set.
set_m= s;
-
ObjectSet::Store invokes the store() function of the adapter
return a.store(t, objectName);
-
StorageAdapter<Foo> requests a boot record location for the boot record.
The returned object ObjectLoc contains a byte array ID, byte array pointer,
and a record number. It does this with a member function of StorageAdapterBase::newInstance()
loc= newInstance("Foo", objectName);
-
StorageAdapterBase::newInstance() invokes a member of ObjectSet::nextObject()
to obtain an ObjectLoc. It checks for validity of object loc. An invalid
location on return indicates the type has not been registered. newInstance()
checks the location and invokes ObjectSet::addType() if the type has not
been seen before, then again requests an object location. recSize_m is
the required size of the boot record determined by the constructor for
StorageAdapter<Foo>
loc= nextObject(typeName_m, objectName);
if(!loc.valid()){
set_m->addType(typeName_m,
recSize_m);
-
The object set adds the type by creating a new type record instance and
creating a new boot record array for the new type. The type ID is the number
of the next type, i.e., the number of types as types are numbered from
0 to numTypes_m-1.
ByteArray* bootArray= set_m ->newArray(parameters);
bootArrayID= array->id();
typeID= numTypes_m;
TypeRec typeRec(typeName, bootRecSize,
typeID, set_m);
typeRec.
typeRecs_m.push_back(typeRec);
numTypes++;
[more here]
-
The method StorageAdapterBase::newInstance() continues by again requesting
a valid location after registering the type.
loc= nextObject(typeName_m,
objectName);
}
[continue here]