Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LOBTree.py 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2001-2012 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE
  12. #
  13. ##############################################################################
  14. __all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
  15. 'LOBucket', 'LOSet', 'LOBTree', 'LOTreeSet',
  16. 'union', 'intersection', 'difference', 'multiunion',
  17. )
  18. from zope.interface import moduleProvides
  19. from .Interfaces import IIntegerObjectBTreeModule
  20. from ._base import Bucket
  21. from ._base import MERGE_WEIGHT_default
  22. from ._base import Set
  23. from ._base import Tree as BTree
  24. from ._base import TreeSet
  25. from ._base import _TreeIterator
  26. from ._base import difference as _difference
  27. from ._base import intersection as _intersection
  28. from ._base import multiunion as _multiunion
  29. from ._base import set_operation as _set_operation
  30. from ._base import to_long as _to_key
  31. from ._base import to_ob as _to_value
  32. from ._base import union as _union
  33. from ._base import _fix_pickle
  34. from ._compat import import_c_extension
  35. _BUCKET_SIZE = 60
  36. _TREE_SIZE = 500
  37. using64bits = True
  38. class LOBucketPy(Bucket):
  39. _to_key = _to_key
  40. _to_value = _to_value
  41. MERGE_WEIGHT = MERGE_WEIGHT_default
  42. class LOSetPy(Set):
  43. _to_key = _to_key
  44. class LOBTreePy(BTree):
  45. max_leaf_size = _BUCKET_SIZE
  46. max_internal_size = _TREE_SIZE
  47. _to_key = _to_key
  48. _to_value = _to_value
  49. MERGE_WEIGHT = MERGE_WEIGHT_default
  50. class LOTreeSetPy(TreeSet):
  51. max_leaf_size = _BUCKET_SIZE
  52. max_internal_size = _TREE_SIZE
  53. _to_key = _to_key
  54. class LOTreeIteratorPy(_TreeIterator):
  55. pass
  56. # Can't declare forward refs, so fix up afterwards:
  57. LOBucketPy._mapping_type = LOBucketPy._bucket_type = LOBucketPy
  58. LOBucketPy._set_type = LOSetPy
  59. LOSetPy._mapping_type = LOBucketPy
  60. LOSetPy._set_type = LOSetPy._bucket_type = LOSetPy
  61. LOBTreePy._mapping_type = LOBTreePy._bucket_type = LOBucketPy
  62. LOBTreePy._set_type = LOSetPy
  63. LOTreeSetPy._mapping_type = LOBucketPy
  64. LOTreeSetPy._set_type = LOTreeSetPy._bucket_type = LOSetPy
  65. differencePy = _set_operation(_difference, LOSetPy)
  66. unionPy = _set_operation(_union, LOSetPy)
  67. intersectionPy = _set_operation(_intersection, LOSetPy)
  68. multiunionPy = _set_operation(_multiunion, LOSetPy)
  69. import_c_extension(globals())
  70. _fix_pickle(globals(), __name__)
  71. moduleProvides(IIntegerObjectBTreeModule)