[Zodb-checkins] CVS: Zope/lib/python/ZODB - fsIndex.py:1.1.2.3

Jim Fulton jim@zope.com
Sat, 1 Dec 2001 15:39:47 -0500


Update of /cvs-repository/Zope/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv3806

Modified Files:
      Tag: BTreeFSIndex-branch
	fsIndex.py 
Log Message:
Added license.

Added an explanatory comment.


=== Zope/lib/python/ZODB/fsIndex.py 1.1.2.2 => 1.1.2.3 ===
-# Mapping from 8-character string to 8-character string
-# where the first two bytes of every string must be two nulls.
-######################################################################
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+# 
+##############################################################################
+"""Implement an OID to File-position (long integer) mapping
+"""
+# 
+# To save space, we do two things:
+# 
+#     1. We split the keys (OIDS) into 6-byte prefixes and 2-byte suffixes.
+#        We use the prefixes as keys in a mapping from prefix to mappings
+#        of suffix to data:
+# 
+#           data is  {prefix -> {suffix -> data}}
+# 
+#     2. We limit the data size to 48 bits. This should allow databases
+#        as large as 256 terabytes.
+# 
+# Mostof the space is consumed by items in the mappings from 2-byte
+# suffix to 6-byte data. This should reduce the overall memory usage to
+# 8-16 bytes per OID.
+# 
+# We use p64 to convert integers to 8-byte strings and lop off the two
+# high-order bytes when saving. On loading data, we add the leading
+# bytes back before using U64 to convert the data back to (long)
+# integers.
+#
 
 try:
     from BTrees._fsBTree import fsBTree as _fsBTree
+    print 'Using fsBTrees'
     #from BTrees.OOBTree import OOBTree as _fsBTree
 except ImportError:
     def fsIndex(): return {}