Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
63970e79
Commit
63970e79
authored
Feb 20, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial cut at BTrees implementation. It compiles, but does not work.
parent
4171baa3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
289 additions
and
248 deletions
+289
-248
src/BTrees/BTreeModuleTemplate.c
src/BTrees/BTreeModuleTemplate.c
+54
-64
src/BTrees/BTreeTemplate.c
src/BTrees/BTreeTemplate.c
+52
-45
src/BTrees/BucketTemplate.c
src/BTrees/BucketTemplate.c
+52
-43
src/BTrees/IIBTree.py
src/BTrees/IIBTree.py
+3
-3
src/BTrees/IOBTree.py
src/BTrees/IOBTree.py
+3
-3
src/BTrees/OIBTree.py
src/BTrees/OIBTree.py
+3
-3
src/BTrees/OOBTree.py
src/BTrees/OOBTree.py
+18
-3
src/BTrees/SetOpTemplate.c
src/BTrees/SetOpTemplate.c
+5
-5
src/BTrees/SetTemplate.c
src/BTrees/SetTemplate.c
+43
-32
src/BTrees/TreeSetTemplate.c
src/BTrees/TreeSetTemplate.c
+43
-32
src/BTrees/_IIBTree.c
src/BTrees/_IIBTree.c
+1
-2
src/BTrees/_IOBTree.c
src/BTrees/_IOBTree.c
+1
-2
src/BTrees/__init__.py
src/BTrees/__init__.py
+11
-11
No files found.
src/BTrees/BTreeModuleTemplate.c
View file @
63970e79
...
@@ -12,23 +12,11 @@
...
@@ -12,23 +12,11 @@
****************************************************************************/
****************************************************************************/
#include "Python.h"
#ifdef PERSISTENT
#ifdef PERSISTENT
#include "cPersistence.h"
#include "cPersistence.h"
#include "cPersistenceAPI.h"
/***************************************************************
The following are macros that ought to be in cPersistence.h */
#ifndef PER_USE
#define PER_USE(O) \
(((O)->state != cPersistent_GHOST_STATE \
|| (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
? (((O)->state==cPersistent_UPTODATE_STATE) \
? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
#define PER_ACCESSED(O) ((O)->atime=((long)(time(NULL)/3))%65536)
#endif
/***************************************************************/
/***************************************************************/
#else
#else
...
@@ -70,7 +58,7 @@ typedef struct BTreeItemStruct {
...
@@ -70,7 +58,7 @@ typedef struct BTreeItemStruct {
typedef
struct
Bucket_s
{
typedef
struct
Bucket_s
{
#ifdef PERSISTENT
#ifdef PERSISTENT
cPersisten
t_HEAD
PyPersis
t_HEAD
#else
#else
PyObject_HEAD
PyObject_HEAD
#endif
#endif
...
@@ -88,7 +76,7 @@ static void PyVar_AssignB(Bucket **v, Bucket *e) { Py_XDECREF(*v); *v=e;}
...
@@ -88,7 +76,7 @@ static void PyVar_AssignB(Bucket **v, Bucket *e) { Py_XDECREF(*v); *v=e;}
typedef
struct
{
typedef
struct
{
#ifdef PERSISTENT
#ifdef PERSISTENT
cPersisten
t_HEAD
PyPersis
t_HEAD
#else
#else
PyObject_HEAD
PyObject_HEAD
#endif
#endif
...
@@ -97,7 +85,7 @@ typedef struct {
...
@@ -97,7 +85,7 @@ typedef struct {
BTreeItem
*
data
;
BTreeItem
*
data
;
}
BTree
;
}
BTree
;
staticforward
Py
ExtensionClass
BTreeType
;
staticforward
Py
TypeObject
BTreeType
;
#define BTREE(O) ((BTree*)(O))
#define BTREE(O) ((BTree*)(O))
...
@@ -270,7 +258,7 @@ static char BTree_module_documentation[] =
...
@@ -270,7 +258,7 @@ static char BTree_module_documentation[] =
"
\n
"
"
\n
"
MASTER_ID
MASTER_ID
BTREEITEMSTEMPLATE_C
BTREEITEMSTEMPLATE_C
"$Id: BTreeModuleTemplate.c,v 1.1
8 2002/02/11 23:40:40 gvanrossum
Exp $
\n
"
"$Id: BTreeModuleTemplate.c,v 1.1
9 2002/02/20 23:59:51 jeremy
Exp $
\n
"
BTREETEMPLATE_C
BTREETEMPLATE_C
BUCKETTEMPLATE_C
BUCKETTEMPLATE_C
KEYMACROS_H
KEYMACROS_H
...
@@ -282,44 +270,37 @@ VALUEMACROS_H
...
@@ -282,44 +270,37 @@ VALUEMACROS_H
BTREEITEMSTEMPLATE_C
BTREEITEMSTEMPLATE_C
;
;
int
init_persist_type
(
PyTypeObject
*
type
)
{
type
->
ob_type
=
&
PyType_Type
;
type
->
tp_getattro
=
PyPersist_TYPE
->
tp_getattro
;
type
->
tp_setattro
=
PyPersist_TYPE
->
tp_setattro
;
/* XXX for now */
type
->
tp_traverse
=
PyPersist_TYPE
->
tp_traverse
;
type
->
tp_clear
=
PyPersist_TYPE
->
tp_clear
;
return
PyType_Ready
(
type
);
}
void
void
INITMODULE
(
void
)
INITMODULE
(
void
)
{
{
PyObject
*
m
,
*
d
,
*
c
;
PyObject
*
m
,
*
d
,
*
c
;
UNLESS
(
sort_str
=
PyString_FromString
(
"sort"
))
return
;
sort_str
=
PyString_InternFromString
(
"sort"
);
UNLESS
(
reverse_str
=
PyString_FromString
(
"reverse"
))
return
;
if
(
!
sort_str
)
UNLESS
(
items_str
=
PyString_FromString
(
"items"
))
return
;
return
;
UNLESS
(
__setstate___str
=
PyString_FromString
(
"__setstate__"
))
return
;
reverse_str
=
PyString_InternFromString
(
"reverse"
);
if
(
!
reverse_str
)
UNLESS
(
PyExtensionClassCAPI
=
PyCObject_Import
(
"ExtensionClass"
,
"CAPI"
))
return
;
__setstate___str
=
PyString_InternFromString
(
"__setstate__"
);
if
(
!
__setstate___str
)
return
;
return
;
#ifdef PERSISTENT
if
((
cPersistenceCAPI
=
PyCObject_Import
(
"cPersistence"
,
"CAPI"
)))
{
BucketType
.
methods
.
link
=
cPersistenceCAPI
->
methods
;
BucketType
.
tp_getattro
=
cPersistenceCAPI
->
getattro
;
BucketType
.
tp_setattro
=
cPersistenceCAPI
->
setattro
;
SetType
.
methods
.
link
=
cPersistenceCAPI
->
methods
;
SetType
.
tp_getattro
=
cPersistenceCAPI
->
getattro
;
SetType
.
tp_setattro
=
cPersistenceCAPI
->
setattro
;
BTreeType
.
methods
.
link
=
cPersistenceCAPI
->
methods
;
BTreeType
.
tp_getattro
=
cPersistenceCAPI
->
getattro
;
BTreeType
.
tp_setattro
=
cPersistenceCAPI
->
setattro
;
TreeSetType
.
methods
.
link
=
cPersistenceCAPI
->
methods
;
TreeSetType
.
tp_getattro
=
cPersistenceCAPI
->
getattro
;
TreeSetType
.
tp_setattro
=
cPersistenceCAPI
->
setattro
;
}
else
return
;
/* Grab the ConflictError class */
/* Grab the ConflictError class */
m
=
PyImport_ImportModule
(
"ZODB.POSException"
);
m
=
PyImport_ImportModule
(
"ZODB.POSException"
);
if
(
m
!=
NULL
)
{
if
(
m
!=
NULL
)
{
c
=
PyObject_GetAttrString
(
m
,
"BTreesConflictError"
);
c
=
PyObject_GetAttrString
(
m
,
"BTreesConflictError"
);
if
(
c
!=
NULL
)
if
(
c
!=
NULL
)
...
@@ -332,31 +313,40 @@ INITMODULE (void)
...
@@ -332,31 +313,40 @@ INITMODULE (void)
ConflictError
=
PyExc_ValueError
;
ConflictError
=
PyExc_ValueError
;
}
}
#else
BTreeType
.
tp_getattro
=
PyExtensionClassCAPI
->
getattro
;
BucketType
.
tp_getattro
=
PyExtensionClassCAPI
->
getattro
;
SetType
.
tp_getattro
=
PyExtensionClassCAPI
->
getattro
;
TreeSetType
.
tp_getattro
=
PyExtensionClassCAPI
->
getattro
;
#endif
BTreeItemsType
.
ob_type
=&
PyType_Type
;
#ifdef INTSET_H
#ifdef INTSET_H
UNLESS
(
d
=
PyImport_ImportModule
(
"intSet"
))
return
;
UNLESS
(
d
=
PyImport_ImportModule
(
"intSet"
))
return
;
UNLESS
(
intSetType
=
PyObject_GetAttrString
(
d
,
"intSet"
))
return
;
UNLESS
(
intSetType
=
PyObject_GetAttrString
(
d
,
"intSet"
))
return
;
Py_DECREF
(
d
);
Py_DECREF
(
d
);
#endif
#endif
/* Initialize the PyPersist_C_API and the type objects. */
PyPersist_C_API
=
PyCObject_Import
(
"Persistence.cPersistence"
,
"C_API"
);
if
(
PyPersist_C_API
==
NULL
)
return
;
BTreeItemsType
.
ob_type
=
&
PyType_Type
;
init_persist_type
(
&
BucketType
);
init_persist_type
(
&
BTreeType
);
init_persist_type
(
&
SetType
);
init_persist_type
(
&
TreeSetType
);
/* Create the module and add the functions */
/* Create the module and add the functions */
m
=
Py_InitModule4
(
"_"
MOD_NAME_PREFIX
"BTree"
,
module_methods
,
m
=
Py_InitModule4
(
"_"
MOD_NAME_PREFIX
"BTree"
,
BTree_module_documentation
,
module_methods
,
BTree_module_documentation
,
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
/* Add some symbolic constants to the module */
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"Bucket"
,
PyExtensionClass_Export
(
d
,
MOD_NAME_PREFIX
"Bucket"
,
BucketType
);
(
PyObject
*
)
&
BucketType
)
<
0
)
PyExtensionClass_Export
(
d
,
MOD_NAME_PREFIX
"BTree"
,
BTreeType
);
return
;
PyExtensionClass_Export
(
d
,
MOD_NAME_PREFIX
"Set"
,
SetType
);
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"BTree"
,
PyExtensionClass_Export
(
d
,
MOD_NAME_PREFIX
"TreeSet"
,
TreeSetType
);
(
PyObject
*
)
&
BTreeType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"Set"
,
(
PyObject
*
)
&
SetType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"TreeSet"
,
(
PyObject
*
)
&
TreeSetType
)
<
0
)
return
;
}
}
src/BTrees/BTreeTemplate.c
View file @
63970e79
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
****************************************************************************/
****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.2
1 2002/02/11 23:40:40 gvanrossum
Exp $\n"
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.2
2 2002/02/20 23:59:51 jeremy
Exp $\n"
/*
/*
** _BTree_get
** _BTree_get
...
@@ -481,7 +481,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
...
@@ -481,7 +481,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
||
(
bchanged
/* The bucket changed */
||
(
bchanged
/* The bucket changed */
&&
self
->
len
==
1
/* We have only one */
&&
self
->
len
==
1
/* We have only one */
&&
!
SameType_Check
(
self
,
self
->
data
->
value
)
/* It's our child */
&&
!
SameType_Check
(
self
,
self
->
data
->
value
)
/* It's our child */
&&
BUCKET
(
self
->
data
->
value
)
->
oid
==
NULL
/* It's in our record */
&&
BUCKET
(
self
->
data
->
value
)
->
po_oid
==
NULL
/* It's in our record */
)
)
)
)
if
(
PER_CHANGED
(
self
)
<
0
)
if
(
PER_CHANGED
(
self
)
<
0
)
...
@@ -570,10 +570,10 @@ _BTree_clear(BTree *self)
...
@@ -570,10 +570,10 @@ _BTree_clear(BTree *self)
static
PyObject
*
static
PyObject
*
BTree__p_deactivate
(
BTree
*
self
,
PyObject
*
args
)
BTree__p_deactivate
(
BTree
*
self
,
PyObject
*
args
)
{
{
if
(
self
->
state
==
cPersistent_UPTODATE_STATE
&&
self
->
jar
)
if
(
self
->
po_state
==
UPTODATE
&&
self
->
po_dm
)
{
{
if
(
_BTree_clear
(
self
)
<
0
)
return
NULL
;
if
(
_BTree_clear
(
self
)
<
0
)
return
NULL
;
self
->
state
=
cPersistent_GHOST_STATE
;
self
->
po_state
=
GHOST
;
}
}
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
@@ -619,7 +619,7 @@ BTree_getstate(BTree *self, PyObject *args)
...
@@ -619,7 +619,7 @@ BTree_getstate(BTree *self, PyObject *args)
if
(
self
->
len
==
1
if
(
self
->
len
==
1
&&
self
->
data
->
value
->
ob_type
!=
self
->
ob_type
&&
self
->
data
->
value
->
ob_type
!=
self
->
ob_type
#ifdef PERSISTENT
#ifdef PERSISTENT
&&
BUCKET
(
self
->
data
->
value
)
->
oid
==
NULL
&&
BUCKET
(
self
->
data
->
value
)
->
po_
oid
==
NULL
#endif
#endif
)
)
{
{
...
@@ -731,9 +731,9 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
...
@@ -731,9 +731,9 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
{
{
if
(
!
firstbucket
)
firstbucket
=
self
->
data
->
value
;
if
(
!
firstbucket
)
firstbucket
=
self
->
data
->
value
;
UNLESS
(
ExtensionClassSubclassInstance_Check
(
/* XXX what is this? */
firstbucket
,
if
(
!
PyObject_IsInstance
(
firstbucket
,
(
PyObject
*
)
noval
?
&
SetType
:
&
BucketType
))
(
noval
?
&
SetType
:
&
BucketType
)
))
{
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"No firstbucket in non-empty BTree"
);
"No firstbucket in non-empty BTree"
);
...
@@ -788,7 +788,7 @@ BTree__p_resolveConflict(BTree *self, PyObject *args)
...
@@ -788,7 +788,7 @@ BTree__p_resolveConflict(BTree *self, PyObject *args)
UNLESS
(
s
[
i
]
==
Py_None
||
PyTuple_Check
(
s
[
i
]))
UNLESS
(
s
[
i
]
==
Py_None
||
PyTuple_Check
(
s
[
i
]))
return
merge_error
(
-
100
,
-
100
,
-
100
,
-
100
);
return
merge_error
(
-
100
,
-
100
,
-
100
,
-
100
);
if
(
ExtensionClassSubclassInstance_Check
(
self
,
&
BTreeType
))
if
(
PyObject_IsInstance
((
PyObject
*
)
self
,
(
PyObject
*
)
&
BTreeType
))
r
=
_bucket__p_resolveConflict
(
OBJECT
(
&
BucketType
),
s
);
r
=
_bucket__p_resolveConflict
(
OBJECT
(
&
BucketType
),
s
);
else
else
r
=
_bucket__p_resolveConflict
(
OBJECT
(
&
SetType
),
s
);
r
=
_bucket__p_resolveConflict
(
OBJECT
(
&
SetType
),
s
);
...
@@ -1238,11 +1238,7 @@ static void
...
@@ -1238,11 +1238,7 @@ static void
BTree_dealloc
(
BTree
*
self
)
BTree_dealloc
(
BTree
*
self
)
{
{
_BTree_clear
(
self
);
_BTree_clear
(
self
);
PyPersist_TYPE
->
tp_dealloc
((
PyObject
*
)
self
);
PER_DEL
(
self
);
Py_DECREF
(
self
->
ob_type
);
PyMem_DEL
(
self
);
}
}
static
int
static
int
...
@@ -1301,35 +1297,46 @@ static PyNumberMethods BTree_as_number_for_nonzero = {
...
@@ -1301,35 +1297,46 @@ static PyNumberMethods BTree_as_number_for_nonzero = {
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
(
inquiry
)
BTree_nonzero
};
(
inquiry
)
BTree_nonzero
};
static
PyExtensionClass
BTreeType
=
{
static
PyTypeObject
BTreeType
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
/* PyPersist_Type */
0
,
/*ob_size*/
0
,
/* ob_size */
MOD_NAME_PREFIX
"BTree"
,
/*tp_name*/
"Persistence.BTrees.OOBTree."
MOD_NAME_PREFIX
"BTree"
,
/* tp_name */
sizeof
(
BTree
),
/*tp_basicsize*/
sizeof
(
BTree
),
/* tp_basicsize */
0
,
/*tp_itemsize*/
0
,
/* tp_itemsize */
/************* methods ********************/
(
destructor
)
BTree_dealloc
,
/* tp_dealloc */
(
destructor
)
BTree_dealloc
,
/*tp_dealloc*/
0
,
/* tp_print */
(
printfunc
)
0
,
/*tp_print*/
0
,
/* tp_getattr */
(
getattrfunc
)
0
,
/*obsolete tp_getattr*/
0
,
/* tp_setattr */
(
setattrfunc
)
0
,
/*obsolete tp_setattr*/
0
,
/* tp_compare */
(
cmpfunc
)
0
,
/*tp_compare*/
0
,
/* tp_repr */
(
reprfunc
)
0
,
/*tp_repr*/
&
BTree_as_number_for_nonzero
,
/* tp_as_number */
&
BTree_as_number_for_nonzero
,
/*tp_as_number*/
0
,
/* tp_as_sequence */
0
,
/*tp_as_sequence*/
&
BTree_as_mapping
,
/* tp_as_mapping */
&
BTree_as_mapping
,
/*tp_as_mapping*/
0
,
/* tp_hash */
(
hashfunc
)
0
,
/*tp_hash*/
0
,
/* tp_call */
(
ternaryfunc
)
0
,
/*tp_call*/
0
,
/* tp_str */
(
reprfunc
)
0
,
/*tp_str*/
0
,
/* tp_getattro */
(
getattrofunc
)
0
,
0
,
/* tp_setattro */
0
,
/*tp_setattro*/
0
,
/* tp_as_buffer */
/* XXX need to define traverse and clear functions */
/* Space for future expansion */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
0L
,
0L
,
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Mapping type implemented as sorted list of items"
,
0
,
/* tp_doc */
METHOD_CHAIN
(
BTree_methods
),
0
,
/* tp_traverse */
EXTENSIONCLASS_BASICNEW_FLAG
0
,
/* tp_clear */
#ifdef PERSISTENT
0
,
/* tp_richcompare */
|
PERSISTENT_TYPE_FLAG
0
,
/* tp_weaklistoffset */
#endif
0
,
/* tp_iter */
|
EXTENSIONCLASS_NOINSTDICT_FLAG
,
0
,
/* tp_iternext */
BTree_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
PyType_GenericNew
,
/* tp_new */
};
};
src/BTrees/BucketTemplate.c
View file @
63970e79
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
****************************************************************************/
****************************************************************************/
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.2
5 2002/02/11 23:40:40 gvanrossum
Exp $\n"
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.2
6 2002/02/20 23:59:51 jeremy
Exp $\n"
/*
/*
** _bucket_get
** _bucket_get
...
@@ -806,10 +806,10 @@ _bucket_clear(Bucket *self)
...
@@ -806,10 +806,10 @@ _bucket_clear(Bucket *self)
static
PyObject
*
static
PyObject
*
bucket__p_deactivate
(
Bucket
*
self
,
PyObject
*
args
)
bucket__p_deactivate
(
Bucket
*
self
,
PyObject
*
args
)
{
{
if
(
self
->
state
==
cPersistent_UPTODATE_STATE
&&
self
->
jar
)
if
(
self
->
po_state
==
UPTODATE
&&
self
->
po_dm
)
{
{
if
(
_bucket_clear
(
self
)
<
0
)
return
NULL
;
if
(
_bucket_clear
(
self
)
<
0
)
return
NULL
;
self
->
state
=
cPersistent_GHOST_STATE
;
self
->
po_state
=
GHOST
;
}
}
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
@@ -1130,14 +1130,10 @@ static struct PyMethodDef Bucket_methods[] = {
...
@@ -1130,14 +1130,10 @@ static struct PyMethodDef Bucket_methods[] = {
};
};
static
void
static
void
B
ucket_dealloc
(
Bucket
*
self
)
b
ucket_dealloc
(
Bucket
*
self
)
{
{
_bucket_clear
(
self
);
_bucket_clear
(
self
);
PyPersist_TYPE
->
tp_dealloc
((
PyObject
*
)
self
);
PER_DEL
(
self
);
Py_DECREF
(
self
->
ob_type
);
PyMem_DEL
(
self
);
}
}
/* Code to access Bucket objects as mappings */
/* Code to access Bucket objects as mappings */
...
@@ -1164,8 +1160,11 @@ bucket_repr(Bucket *self)
...
@@ -1164,8 +1160,11 @@ bucket_repr(Bucket *self)
static
PyObject
*
format
;
static
PyObject
*
format
;
PyObject
*
r
,
*
t
;
PyObject
*
r
,
*
t
;
UNLESS
(
format
)
UNLESS
(
format
=
PyString_FromString
(
MOD_NAME_PREFIX
"Bucket(%s)"
))
if
(
format
==
NULL
)
{
return
NULL
;
format
=
PyString_FromString
(
MOD_NAME_PREFIX
"Bucket(%s)"
);
if
(
format
==
NULL
)
return
NULL
;
}
UNLESS
(
t
=
PyTuple_New
(
1
))
return
NULL
;
UNLESS
(
t
=
PyTuple_New
(
1
))
return
NULL
;
UNLESS
(
r
=
bucket_items
(
self
,
NULL
))
goto
err
;
UNLESS
(
r
=
bucket_items
(
self
,
NULL
))
goto
err
;
PyTuple_SET_ITEM
(
t
,
0
,
r
);
PyTuple_SET_ITEM
(
t
,
0
,
r
);
...
@@ -1177,40 +1176,50 @@ err:
...
@@ -1177,40 +1176,50 @@ err:
return
NULL
;
return
NULL
;
}
}
static
PyExtensionClass
BucketType
=
{
static
PyTypeObject
BucketType
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
/* PyPersist_Type */
0
,
/*ob_size*/
0
,
/* ob_size */
MOD_NAME_PREFIX
"Bucket"
,
/*tp_name*/
MOD_NAME_PREFIX
"Bucket"
,
/* tp_name */
sizeof
(
Bucket
),
/*tp_basicsize*/
sizeof
(
Bucket
),
/* tp_basicsize */
0
,
/*tp_itemsize*/
0
,
/* tp_itemsize */
/*********** methods ***********************/
(
destructor
)
bucket_dealloc
,
/* tp_dealloc */
(
destructor
)
Bucket_dealloc
,
/*tp_dealloc*/
0
,
/* tp_print */
(
printfunc
)
0
,
/*tp_print*/
0
,
/* tp_getattr */
(
getattrfunc
)
0
,
/*obsolete tp_getattr*/
0
,
/* tp_setattr */
(
setattrfunc
)
0
,
/*obsolete tp_setattr*/
0
,
/* tp_compare */
(
cmpfunc
)
0
,
/*tp_compare*/
(
reprfunc
)
bucket_repr
,
/* tp_repr */
(
reprfunc
)
bucket_repr
,
/*tp_repr*/
0
,
/* tp_as_number */
0
,
/*tp_as_number*/
0
,
/* tp_as_sequence */
0
,
/*tp_as_sequence*/
&
Bucket_as_mapping
,
/* tp_as_mapping */
&
Bucket_as_mapping
,
/*tp_as_mapping*/
0
,
/* tp_hash */
(
hashfunc
)
0
,
/*tp_hash*/
0
,
/* tp_call */
(
ternaryfunc
)
0
,
/*tp_call*/
0
,
/* tp_str */
(
reprfunc
)
0
,
/*tp_str*/
0
,
/* tp_getattro */
(
getattrofunc
)
0
,
/*tp_getattro*/
0
,
/* tp_setattro */
0
,
/*tp_setattro*/
0
,
/* tp_as_buffer */
/* XXX need to define traverse and clear functions */
/* Space for future expansion */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
0L
,
0L
,
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Mapping type implemented as sorted list of items"
,
0
,
/* tp_doc */
METHOD_CHAIN
(
Bucket_methods
),
0
,
/* tp_traverse */
EXTENSIONCLASS_BASICNEW_FLAG
0
,
/* tp_clear */
#ifdef PERSISTENT
0
,
/* tp_richcompare */
|
PERSISTENT_TYPE_FLAG
0
,
/* tp_weaklistoffset */
#endif
0
,
/* tp_iter */
|
EXTENSIONCLASS_NOINSTDICT_FLAG
,
0
,
/* tp_iternext */
Bucket_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
PyType_GenericNew
,
/* tp_new */
};
};
static
int
static
int
nextBucket
(
SetIteration
*
i
)
nextBucket
(
SetIteration
*
i
)
{
{
...
...
src/BTrees/IIBTree.py
View file @
63970e79
...
@@ -17,6 +17,6 @@ from _IIBTree import *
...
@@ -17,6 +17,6 @@ from _IIBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# We don't really want _ names in pickles, so update all of the __module__
# references.
# references.
for
o
in
globals
().
values
():
##
for o in globals().values():
if
hasattr
(
o
,
'__module__'
):
##
if hasattr(o, '__module__'):
o
.
__module__
=
__name__
##
o.__module__=__name__
src/BTrees/IOBTree.py
View file @
63970e79
...
@@ -17,6 +17,6 @@ from _IOBTree import *
...
@@ -17,6 +17,6 @@ from _IOBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# We don't really want _ names in pickles, so update all of the __module__
# references.
# references.
for
o
in
globals
().
values
():
##
for o in globals().values():
if
hasattr
(
o
,
'__module__'
):
##
if hasattr(o, '__module__'):
o
.
__module__
=
__name__
##
o.__module__=__name__
src/BTrees/OIBTree.py
View file @
63970e79
...
@@ -17,6 +17,6 @@ from _OIBTree import *
...
@@ -17,6 +17,6 @@ from _OIBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# We don't really want _ names in pickles, so update all of the __module__
# references.
# references.
for
o
in
globals
().
values
():
##
for o in globals().values():
if
hasattr
(
o
,
'__module__'
):
##
if hasattr(o, '__module__'):
o
.
__module__
=
__name__
##
o.__module__=__name__
src/BTrees/OOBTree.py
View file @
63970e79
...
@@ -17,6 +17,21 @@ from _OOBTree import *
...
@@ -17,6 +17,21 @@ from _OOBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# We don't really want _ names in pickles, so update all of the __module__
# references.
# references.
for
o
in
globals
().
values
():
##for o in globals().values():
if
hasattr
(
o
,
'__module__'
):
## print o
o
.
__module__
=
__name__
## if hasattr(o, '__module__'):
## o.__module__=__name__
# XXX can't figure out why _reduce() won't call our __getstate__.
import
copy_reg
def
pickle_OOBTree
(
t
):
return
t
.
__class__
,
t
.
__getstate__
()
def
unpickle_OOBTree
(
state
):
obj
=
OOBTree
.
__new__
(
OOBTree
,
None
)
obj
.
__setstate__
(
state
)
return
obj
copy_reg
.
pickle
(
OOBTree
,
pickle_OOBTree
)
src/BTrees/SetOpTemplate.c
View file @
63970e79
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
Set operations
Set operations
****************************************************************************/
****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.1
0 2002/02/11 23:40:40 gvanrossum
Exp $\n"
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.1
1 2002/02/20 23:59:51 jeremy
Exp $\n"
#ifdef INTSET_H
#ifdef INTSET_H
static
int
static
int
...
@@ -67,7 +67,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
...
@@ -67,7 +67,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
{
{
i
->
position
=
0
;
i
->
position
=
0
;
if
(
ExtensionClassSubclassInstance_Check
(
s
,
&
BucketType
))
if
(
PyObject_IsInstance
(
s
,
(
PyObject
*
)
&
BucketType
))
{
{
i
->
set
=
s
;
i
->
set
=
s
;
Py_INCREF
(
s
);
Py_INCREF
(
s
);
...
@@ -82,7 +82,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
...
@@ -82,7 +82,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i
->
hasValue
=
1
;
i
->
hasValue
=
1
;
}
}
else
if
(
ExtensionClassSubclassInstance_Check
(
s
,
&
SetType
))
else
if
(
PyObject_IsInstance
(
s
,
(
PyObject
*
)
&
SetType
))
{
{
i
->
set
=
s
;
i
->
set
=
s
;
Py_INCREF
(
s
);
Py_INCREF
(
s
);
...
@@ -90,7 +90,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
...
@@ -90,7 +90,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i
->
next
=
nextSet
;
i
->
next
=
nextSet
;
i
->
hasValue
=
0
;
i
->
hasValue
=
0
;
}
}
else
if
(
ExtensionClassSubclassInstance_Check
(
s
,
&
BTreeType
))
else
if
(
PyObject_IsInstance
(
s
,
(
PyObject
*
)
&
BTreeType
))
{
{
i
->
set
=
BTree_rangeSearch
(
BTREE
(
s
),
NULL
,
'i'
);
i
->
set
=
BTree_rangeSearch
(
BTREE
(
s
),
NULL
,
'i'
);
UNLESS
(
i
->
set
)
return
-
1
;
UNLESS
(
i
->
set
)
return
-
1
;
...
@@ -104,7 +104,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
...
@@ -104,7 +104,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i
->
next
=
nextTreeSetItems
;
i
->
next
=
nextTreeSetItems
;
i
->
hasValue
=
1
;
i
->
hasValue
=
1
;
}
}
else
if
(
ExtensionClassSubclassInstance_Check
(
s
,
&
TreeSetType
))
else
if
(
PyObject_IsInstance
(
s
,
(
PyObject
*
)
&
TreeSetType
))
{
{
i
->
set
=
BTree_rangeSearch
(
BTREE
(
s
),
NULL
,
'k'
);
i
->
set
=
BTree_rangeSearch
(
BTREE
(
s
),
NULL
,
'k'
);
UNLESS
(
i
->
set
)
return
-
1
;
UNLESS
(
i
->
set
)
return
-
1
;
...
...
src/BTrees/SetTemplate.c
View file @
63970e79
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
****************************************************************************/
****************************************************************************/
#define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.1
3 2002/02/11 23:40:40 gvanrossum
Exp $\n"
#define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.1
4 2002/02/20 23:59:51 jeremy
Exp $\n"
static
PyObject
*
static
PyObject
*
Set_insert
(
Bucket
*
self
,
PyObject
*
args
)
Set_insert
(
Bucket
*
self
,
PyObject
*
args
)
...
@@ -236,37 +236,48 @@ static PySequenceMethods set_as_sequence = {
...
@@ -236,37 +236,48 @@ static PySequenceMethods set_as_sequence = {
(
intintobjargproc
)
0
,
/*sq_ass_slice*/
(
intintobjargproc
)
0
,
/*sq_ass_slice*/
};
};
static
PyExtensionClass
SetType
=
{
static
PyTypeObject
SetType
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
/* PyPersist_Type */
0
,
/*ob_size*/
0
,
/* ob_size */
MOD_NAME_PREFIX
"Set"
,
/*tp_name*/
MOD_NAME_PREFIX
"Set"
,
/* tp_name */
sizeof
(
Bucket
),
/*tp_basicsize*/
sizeof
(
Bucket
),
/* tp_basicsize */
0
,
/*tp_itemsize*/
0
,
/* tp_itemsize */
/*********** methods ***********************/
(
destructor
)
bucket_dealloc
,
/* tp_dealloc */
(
destructor
)
Bucket_dealloc
,
/*tp_dealloc*/
0
,
/* tp_print */
(
printfunc
)
0
,
/*tp_print*/
0
,
/* tp_getattr */
(
getattrfunc
)
0
,
/*obsolete tp_getattr*/
0
,
/* tp_setattr */
(
setattrfunc
)
0
,
/*obsolete tp_setattr*/
0
,
/* tp_compare */
(
cmpfunc
)
0
,
/*tp_compare*/
(
reprfunc
)
set_repr
,
/* tp_repr */
(
reprfunc
)
set_repr
,
/*tp_repr*/
0
,
/* tp_as_number */
0
,
/*tp_as_number*/
&
set_as_sequence
,
/* tp_as_sequence */
&
set_as_sequence
,
/*tp_as_sequence*/
0
,
/* tp_as_mapping */
0
,
/*tp_as_mapping*/
0
,
/* tp_hash */
(
hashfunc
)
0
,
/*tp_hash*/
0
,
/* tp_call */
(
ternaryfunc
)
0
,
/*tp_call*/
0
,
/* tp_str */
(
reprfunc
)
0
,
/*tp_str*/
0
,
/* tp_getattro */
(
getattrofunc
)
0
,
/*tp_getattro*/
0
,
/* tp_setattro */
0
,
/*tp_setattro*/
0
,
/* tp_as_buffer */
/* XXX need to define traverse and clear functions */
/* Space for future expansion */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
0L
,
0L
,
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Set implemented as sorted keys"
,
0
,
/* tp_doc */
METHOD_CHAIN
(
Set_methods
),
0
,
/* tp_traverse */
EXTENSIONCLASS_BASICNEW_FLAG
0
,
/* tp_clear */
#ifdef PERSISTENT
0
,
/* tp_richcompare */
|
PERSISTENT_TYPE_FLAG
0
,
/* tp_weaklistoffset */
#endif
0
,
/* tp_iter */
|
EXTENSIONCLASS_NOINSTDICT_FLAG
,
0
,
/* tp_iternext */
Set_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
PyType_GenericNew
,
/* tp_new */
};
};
static
int
static
int
...
...
src/BTrees/TreeSetTemplate.c
View file @
63970e79
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
****************************************************************************/
****************************************************************************/
#define TREESETTEMPLATE_C "$Id: TreeSetTemplate.c,v 1.1
1 2002/02/11 23:40:40 gvanrossum
Exp $\n"
#define TREESETTEMPLATE_C "$Id: TreeSetTemplate.c,v 1.1
2 2002/02/20 23:59:51 jeremy
Exp $\n"
static
PyObject
*
static
PyObject
*
TreeSet_insert
(
BTree
*
self
,
PyObject
*
args
)
TreeSet_insert
(
BTree
*
self
,
PyObject
*
args
)
...
@@ -127,35 +127,46 @@ static PyMappingMethods TreeSet_as_mapping = {
...
@@ -127,35 +127,46 @@ static PyMappingMethods TreeSet_as_mapping = {
(
inquiry
)
BTree_length
,
/*mp_length*/
(
inquiry
)
BTree_length
,
/*mp_length*/
};
};
static
PyExtensionClass
TreeSetType
=
{
static
PyTypeObject
TreeSetType
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
/* PyPersist_Type */
0
,
/*ob_size*/
0
,
/* ob_size */
MOD_NAME_PREFIX
"TreeSet"
,
/*tp_name*/
MOD_NAME_PREFIX
"TreeSet"
,
/* tp_name */
sizeof
(
BTree
),
/*tp_basicsize*/
sizeof
(
BTree
),
/* tp_basicsize */
0
,
/*tp_itemsize*/
0
,
/* tp_itemsize */
/************* methods ********************/
(
destructor
)
BTree_dealloc
,
/* tp_dealloc */
(
destructor
)
BTree_dealloc
,
/*tp_dealloc*/
0
,
/* tp_print */
(
printfunc
)
0
,
/*tp_print*/
0
,
/* tp_getattr */
(
getattrfunc
)
0
,
/*obsolete tp_getattr*/
0
,
/* tp_setattr */
(
setattrfunc
)
0
,
/*obsolete tp_setattr*/
0
,
/* tp_compare */
(
cmpfunc
)
0
,
/*tp_compare*/
0
,
/* tp_repr */
(
reprfunc
)
0
,
/*tp_repr*/
&
BTree_as_number_for_nonzero
,
/* tp_as_number */
&
BTree_as_number_for_nonzero
,
/*tp_as_number*/
0
,
/* tp_as_sequence */
0
,
/*tp_as_sequence*/
&
TreeSet_as_mapping
,
/* tp_as_mapping */
&
TreeSet_as_mapping
,
/*tp_as_mapping*/
0
,
/* tp_hash */
(
hashfunc
)
0
,
/*tp_hash*/
0
,
/* tp_call */
(
ternaryfunc
)
0
,
/*tp_call*/
0
,
/* tp_str */
(
reprfunc
)
0
,
/*tp_str*/
0
,
/* tp_getattro */
(
getattrofunc
)
0
,
0
,
/* tp_setattro */
0
,
/*tp_setattro*/
0
,
/* tp_as_buffer */
/* XXX need to define traverse and clear functions */
/* Space for future expansion */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
0L
,
0L
,
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Set implemented as sorted tree of items"
,
0
,
/* tp_doc */
METHOD_CHAIN
(
TreeSet_methods
),
0
,
/* tp_traverse */
EXTENSIONCLASS_BASICNEW_FLAG
0
,
/* tp_clear */
#ifdef PERSISTENT
0
,
/* tp_richcompare */
|
PERSISTENT_TYPE_FLAG
0
,
/* tp_weaklistoffset */
#endif
0
,
/* tp_iter */
|
EXTENSIONCLASS_NOINSTDICT_FLAG
,
0
,
/* tp_iternext */
TreeSet_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
PyType_GenericNew
,
/* tp_new */
};
};
src/BTrees/_IIBTree.c
View file @
63970e79
/* Setup template macros */
/* Setup template macros */
#define MASTER_ID "$Id: _IIBTree.c,v 1.
3 2001/04/02 16:31:05
jeremy Exp $\n"
#define MASTER_ID "$Id: _IIBTree.c,v 1.
4 2002/02/20 23:59:51
jeremy Exp $\n"
#define PERSISTENT
#define PERSISTENT
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
#include "intkeymacros.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#include "intvaluemacros.h"
#include "cPersistence.h"
#ifndef EXCLUDE_INTSET_SUPPORT
#ifndef EXCLUDE_INTSET_SUPPORT
#include "BTree/intSet.h"
#include "BTree/intSet.h"
#endif
#endif
...
...
src/BTrees/_IOBTree.c
View file @
63970e79
#define MASTER_ID "$Id: _IOBTree.c,v 1.
3 2001/04/02 16:31:05
jeremy Exp $\n"
#define MASTER_ID "$Id: _IOBTree.c,v 1.
4 2002/02/20 23:59:51
jeremy Exp $\n"
#define PERSISTENT
#define PERSISTENT
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
#include "intkeymacros.h"
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#include "objectvaluemacros.h"
#include "cPersistence.h"
#ifndef EXCLUDE_INTSET_SUPPORT
#ifndef EXCLUDE_INTSET_SUPPORT
#include "BTree/intSet.h"
#include "BTree/intSet.h"
#endif
#endif
...
...
src/BTrees/__init__.py
View file @
63970e79
import
ZODB
##
import ZODB
try
:
import
intSet
##
try: import intSet
except
:
pass
##
except: pass
else
:
del
intSet
##
else: del intSet
# Register interfaces
#
##
Register interfaces
try
:
import
Interface
##
try: import Interface
except
ImportError
:
pass
# Don't register interfaces if no scarecrow
##
except ImportError: pass # Don't register interfaces if no scarecrow
else
:
##
else:
import
Interfaces
##
import Interfaces
del
Interfaces
##
del Interfaces
del
Interface
##
del Interface
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment