-
Notifications
You must be signed in to change notification settings - Fork 48
Sqlite flat mapper
It is a class which main responsibility is to persist/retrieve "sets" or any homogeneous collection of objects in an optimal manner.
In general any big list/collection with homogeneous content is a good candidate to be used with the flat mapper. SetOfParticles, SetOfClasses, SetOfVolumes, and any class that inherits form Set ( at pyworkflow.object.py) is a good candidate to be persisted with the flat mapper.
Any other big, homogeneous list, even if it doesn't extends Set, will work for the flat mapper.
Let's start with an example and follow the complete process. Let's take SetOfParticles which is basically a list of Particle objects.

Each of the particles in the set has the same 13 attributes:
- id
- enabled
- _index
- _filename
- label
- comment
- _samplingRate
- _acquisition._magnification
- ....
For the sake of simplicity we will take into account only those attributes mentioned above, ignoring the rest.
Therefore, let's assume we have in our code something like this:
persistSetOfParticles(mySetOfLegoParticles)
def persistSetOfParticles(setOfParticles):
pass