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
b86388a1
Commit
b86388a1
authored
Sep 10, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
5343dd45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
26 deletions
+88
-26
src/ZODB/BTree.c
src/ZODB/BTree.c
+88
-26
No files found.
src/ZODB/BTree.c
View file @
b86388a1
...
...
@@ -11,7 +11,7 @@
static
char
BTree_module_documentation
[]
=
""
"
\n
$Id: BTree.c,v 1.
1 1997/09/08 18:42:21
jim Exp $"
"
\n
$Id: BTree.c,v 1.
2 1997/09/10 17:24:47
jim Exp $"
;
#define PERSISTENT
...
...
@@ -666,6 +666,7 @@ _bucket_set(Bucket *self, PyObject *key, PyObject *v)
#else
ASSIGN
(
self
->
data
[
i
].
value
,
v
);
#endif
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
PER_ALLOW_DEACTIVATION
(
self
);
return
0
;
}
...
...
@@ -682,6 +683,7 @@ _bucket_set(Bucket *self, PyObject *key, PyObject *v)
free
(
self
->
data
);
self
->
data
=
NULL
;
}
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
PER_ALLOW_DEACTIVATION
(
self
);
return
1
;
}
...
...
@@ -726,6 +728,7 @@ _bucket_set(Bucket *self, PyObject *key, PyObject *v)
#endif
self
->
len
++
;
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
PER_ALLOW_DEACTIVATION
(
self
);
return
1
;
...
...
@@ -965,25 +968,29 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value)
if
(
grew
<
0
)
goto
err
;
if
(
grew
)
if
(
value
)
/* got bigger */
{
d
->
count
++
;
self
->
count
++
;
if
(
d
->
count
>
MAX_SIZE
(
self
)
&&
BTree_grow
(
self
,
min
)
<
0
)
goto
err
;
}
else
/* got smaller */
{
d
->
count
--
;
self
->
count
--
;
if
(
!
d
->
count
)
{
self
->
len
--
;
Py_DECREF
(
d
->
value
);
DECREF_KEY
(
d
->
key
);
if
(
min
<
self
->
len
)
memmove
(
d
,
d
+
1
,
self
->
len
-
min
);
}
}
{
if
(
value
)
/* got bigger */
{
d
->
count
++
;
self
->
count
++
;
if
(
BUCKET
(
d
->
value
)
->
len
>
MAX_SIZE
(
self
)
&&
BTree_grow
(
self
,
min
)
<
0
)
goto
err
;
}
else
/* got smaller */
{
d
->
count
--
;
self
->
count
--
;
if
(
!
d
->
count
)
{
self
->
len
--
;
Py_DECREF
(
d
->
value
);
DECREF_KEY
(
d
->
key
);
if
(
min
<
self
->
len
)
memmove
(
d
,
d
+
1
,
self
->
len
-
min
);
}
}
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
}
PER_ALLOW_DEACTIVATION
(
self
);
return
grew
;
...
...
@@ -1086,6 +1093,24 @@ bucket_items(Bucket *self, PyObject *args)
Py_DECREF
(
r
);
return
NULL
;
}
#ifdef PERSISTENT
static
PyObject
*
bucket__p___reinit__
(
Bucket
*
self
,
PyObject
*
args
)
{
int
i
;
/* Note that this implementation is broken, in that it doesn't
account for subclass needs. */
for
(
i
=
self
->
len
;
--
i
>=
0
;
)
{
DECREF_KEY
(
self
->
data
[
i
].
key
);
DECREF_VALUE
(
self
->
data
[
i
].
value
);
}
self
->
len
=
0
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
#endif
static
PyObject
*
bucket_clear
(
Bucket
*
self
,
PyObject
*
args
)
...
...
@@ -1100,8 +1125,13 @@ bucket_clear(Bucket *self, PyObject *args)
DECREF_VALUE
(
self
->
data
[
i
].
value
);
}
self
->
len
=
0
;
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
PER_ALLOW_DEACTIVATION
(
self
);
RETURN_NONE
;
err:
PER_ALLOW_DEACTIVATION
(
self
);
return
NULL
;
}
static
int
...
...
@@ -1109,8 +1139,8 @@ _BTree_clear(BTree *self)
{
int
i
;
UNLESS
(
self
->
data
)
return
0
;
PER_USE_OR_RETURN
(
self
,
-
1
);
for
(
i
=
self
->
len
;
--
i
>=
0
;
)
{
DECREF_KEY
(
self
->
data
[
i
].
key
);
...
...
@@ -1119,16 +1149,36 @@ _BTree_clear(BTree *self)
i
=
BTree_ini
(
self
);
PER_ALLOW_DEACTIVATION
(
self
);
return
i
;
}
#ifdef PERSISTENT
static
PyObject
*
BTree_
clear
(
BTree
*
self
,
PyObject
*
args
)
BTree_
_p___reinit__
(
BTree
*
self
,
PyObject
*
args
)
{
/* Note that this implementation is broken, in that it doesn't
account for subclass needs. */
if
(
_BTree_clear
(
self
)
<
0
)
return
NULL
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
#endif
static
PyObject
*
BTree_clear
(
BTree
*
self
,
PyObject
*
args
)
{
PER_USE_OR_RETURN
(
self
,
NULL
);
if
(
_BTree_clear
(
self
)
<
0
)
goto
err
;
if
(
PER_CHANGED
(
self
)
<
0
)
goto
err
;
PER_ALLOW_DEACTIVATION
(
self
);
RETURN_NONE
;
err:
PER_ALLOW_DEACTIVATION
(
self
);
return
NULL
;
}
static
PyObject
*
...
...
@@ -1220,7 +1270,7 @@ bucket_setstate(Bucket *self, PyObject *args)
PER_PREVENT_DEACTIVATION
(
self
);
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
r
))
goto
err
;
UNLESS
(
PyArg_ParseTuple
(
r
,
"O"
,
&
keys
,
&
values
))
goto
err
;
UNLESS
(
PyArg_ParseTuple
(
r
,
"O
O
"
,
&
keys
,
&
values
))
goto
err
;
if
((
l
=
PyObject_Length
(
keys
))
<
0
)
goto
err
;
#ifdef INTKEY
...
...
@@ -1331,6 +1381,10 @@ static struct PyMethodDef Bucket_methods[] = {
{
"map"
,
(
PyCFunction
)
bucket_map
,
METH_VARARGS
,
"map(keys) -- map a sorted sequence of keys into values
\n\n
"
"Invalid keys are skipped"
},
#ifdef PERSISTENT
{
"_p___reinit__"
,
(
PyCFunction
)
bucket__p___reinit__
,
METH_VARARGS
,
"_p___reinit__() -- Reinitialize from a newly created copy"
},
#endif
{
NULL
,
NULL
}
/* sentinel */
};
...
...
@@ -1399,6 +1453,7 @@ BTree_setstate(BTree *self, PyObject *args)
KEY_PARSE
"Oi"
,
&
(
d
->
key
),
&
(
d
->
value
),
&
(
d
->
count
)))
goto
err
;
Py_INCREF
(
d
->
value
);
self
->
count
+=
d
->
count
;
}
...
...
@@ -1486,6 +1541,10 @@ static struct PyMethodDef BTree_methods[] = {
{
"map"
,
(
PyCFunction
)
BTree_map
,
METH_VARARGS
,
"map(keys) -- map a sorted sequence of keys into values
\n\n
"
"Invalid keys are skipped"
},
#ifdef PERSISTENT
{
"_p___reinit__"
,
(
PyCFunction
)
BTree__p___reinit__
,
METH_VARARGS
,
"_p___reinit__() -- Reinitialize from a newly created copy"
},
#endif
{
NULL
,
NULL
}
/* sentinel */
};
...
...
@@ -1650,7 +1709,7 @@ initBTree()
#endif
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
1
$"
;
char
*
rev
=
"$Revision: 1.
2
$"
;
UNLESS
(
PyExtensionClassCAPI
=
PyCObject_Import
(
"ExtensionClass"
,
"CAPI"
))
return
;
...
...
@@ -1710,6 +1769,9 @@ initBTree()
Revision Log:
$Log: BTree.c,v $
Revision 1.2 1997/09/10 17:24:47 jim
*** empty log message ***
Revision 1.1 1997/09/08 18:42:21 jim
initial BTree
...
...
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