[Zope] Mixing keys
Harm_Kirchhoff at mail.digital.co.jp
Harm_Kirchhoff at mail.digital.co.jp
Fri Oct 31 03:41:12 EST 2003
I am new to ZOPE, so maybe this question is too simple:
I would like to use a BTRee (OOBTree) to store information.
For one type of sub-branch, I would like to use a continuous series of
integers as keys:
dbroot['SE_HMI']={ '2003' : { 'jrl' : { 0 : <a tuple of data>}}
dbroot['SE_HMI']={ '2003' : { 'jrl' : { 1 : <a tuple of data>}}
dbroot['SE_HMI']={ '2003' : { 'jrl' : { 2 : <a tuple of data>}}
... and so on ...
all other branches besides 'jrl' will have string keys.
I read in the ZODB,ZEO programming guide (www.zope.org/Wikis/ZODB/guide/)
that you should only use objects of a SINGLE type as keys.
I could write a generator, that would create strings, by counting from 0
to 255,
however, that would destroy the sort order, because 'ABX' would sort
before 'X', allthough it would represent a much larger number.
Since the frequency of expected accesses will increase with the count
(because the later records will be accessed more frequently), I expect
that performance would be lower as the keys would end up in an unsorted
manner.
The same problem occurs with strings representing numbers, due to the sort
order:
cmp('123','2') , cmp(123,2) , "/" , cmp('ABX','X')
(-1, 1, '/', -1)
Does anybody have any experience with this problem ?
More information about the Zope
mailing list