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.

OLBTree.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. 'OLBucket', 'OLSet', 'OLBTree', 'OLTreeSet',
  16. 'union', 'intersection', 'difference',
  17. 'weightedUnion', 'weightedIntersection',
  18. )
  19. from zope.interface import moduleProvides
  20. from .Interfaces import IObjectIntegerBTreeModule
  21. from ._base import Bucket
  22. from ._base import MERGE
  23. from ._base import MERGE_WEIGHT_numeric
  24. from ._base import MERGE_DEFAULT_int
  25. from ._base import Set
  26. from ._base import Tree as BTree
  27. from ._base import TreeSet
  28. from ._base import _TreeIterator
  29. from ._base import difference as _difference
  30. from ._base import intersection as _intersection
  31. from ._base import set_operation as _set_operation
  32. from ._base import to_ob as _to_key
  33. from ._base import to_long as _to_value
  34. from ._base import union as _union
  35. from ._base import weightedIntersection as _weightedIntersection
  36. from ._base import weightedUnion as _weightedUnion
  37. from ._base import _fix_pickle
  38. from ._compat import import_c_extension
  39. _BUCKET_SIZE = 60
  40. _TREE_SIZE = 250
  41. using64bits = True
  42. class OLBucketPy(Bucket):
  43. _to_key = _to_key
  44. _to_value = _to_value
  45. MERGE = MERGE
  46. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  47. MERGE_DEFAULT = MERGE_DEFAULT_int
  48. class OLSetPy(Set):
  49. _to_key = _to_key
  50. MERGE = MERGE
  51. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  52. MERGE_DEFAULT = MERGE_DEFAULT_int
  53. class OLBTreePy(BTree):
  54. max_leaf_size = _BUCKET_SIZE
  55. max_internal_size = _TREE_SIZE
  56. _to_key = _to_key
  57. _to_value = _to_value
  58. MERGE = MERGE
  59. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  60. MERGE_DEFAULT = MERGE_DEFAULT_int
  61. class OLTreeSetPy(TreeSet):
  62. max_leaf_size = _BUCKET_SIZE
  63. max_internal_size = _TREE_SIZE
  64. _to_key = _to_key
  65. MERGE = MERGE
  66. MERGE_WEIGHT = MERGE_WEIGHT_numeric
  67. MERGE_DEFAULT = MERGE_DEFAULT_int
  68. class OLTreeIteratorPy(_TreeIterator):
  69. pass
  70. # Can't declare forward refs, so fix up afterwards:
  71. OLBucketPy._mapping_type = OLBucketPy._bucket_type = OLBucketPy
  72. OLBucketPy._set_type = OLSetPy
  73. OLSetPy._mapping_type = OLBucketPy
  74. OLSetPy._set_type = OLSetPy._bucket_type = OLSetPy
  75. OLBTreePy._mapping_type = OLBTreePy._bucket_type = OLBucketPy
  76. OLBTreePy._set_type = OLSetPy
  77. OLTreeSetPy._mapping_type = OLBucketPy
  78. OLTreeSetPy._set_type = OLTreeSetPy._bucket_type = OLSetPy
  79. differencePy = _set_operation(_difference, OLSetPy)
  80. unionPy = _set_operation(_union, OLSetPy)
  81. intersectionPy = _set_operation(_intersection, OLSetPy)
  82. weightedUnionPy = _set_operation(_weightedUnion, OLSetPy)
  83. weightedIntersectionPy = _set_operation(_weightedIntersection, OLSetPy)
  84. import_c_extension(globals())
  85. _fix_pickle(globals(), __name__)
  86. moduleProvides(IObjectIntegerBTreeModule)