Commit 8b38c474 authored by Jim Fulton's avatar Jim Fulton

Added support for intSets in set operations, for now.

parent 1da6792b
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
static char BTree_module_documentation[] = static char BTree_module_documentation[] =
"" ""
"\n$Id: BTreeModuleTemplate.c,v 1.3 2001/02/19 17:36:04 jim Exp $" "\n$Id: BTreeModuleTemplate.c,v 1.4 2001/02/19 18:15:10 jim Exp $"
; ;
#ifdef PERSISTENT #ifdef PERSISTENT
...@@ -357,6 +357,12 @@ INITMODULE () ...@@ -357,6 +357,12 @@ INITMODULE ()
BTreeItemsType.ob_type=&PyType_Type; BTreeItemsType.ob_type=&PyType_Type;
#ifdef INTSET_H
UNLESS(d = PyImport_ImportModule("intSet")) return;
UNLESS(intSetType = PyObject_GetAttrString (d, "intSet")) return;
Py_DECREF (d);
#endif
/* Create the module and add the functions */ /* Create the module and add the functions */
m = Py_InitModule4(PREFIX "BTree", module_methods, m = Py_InitModule4(PREFIX "BTree", module_methods,
BTree_module_documentation, BTree_module_documentation,
...@@ -366,7 +372,7 @@ INITMODULE () ...@@ -366,7 +372,7 @@ INITMODULE ()
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
PyDict_SetItemString(d, "__version__", PyDict_SetItemString(d, "__version__",
PyString_FromString("$Revision: 1.3 $")); PyString_FromString("$Revision: 1.4 $"));
PyExtensionClass_Export(d,PREFIX "Bucket", BucketType); PyExtensionClass_Export(d,PREFIX "Bucket", BucketType);
PyExtensionClass_Export(d,PREFIX "BTree", BTreeType); PyExtensionClass_Export(d,PREFIX "BTree", BTreeType);
......
...@@ -9,4 +9,6 @@ ...@@ -9,4 +9,6 @@
#include "intkeymacros.h" #include "intkeymacros.h"
#include "intvaluemacros.h" #include "intvaluemacros.h"
#include "cPersistence.h"
#include "BTree/intSet.h"
#include "BTreeModuleTemplate.c" #include "BTreeModuleTemplate.c"
...@@ -8,4 +8,6 @@ ...@@ -8,4 +8,6 @@
#include "intkeymacros.h" #include "intkeymacros.h"
#include "objectvaluemacros.h" #include "objectvaluemacros.h"
#include "cPersistence.h"
#include "BTree/intSet.h"
#include "BTreeModuleTemplate.c" #include "BTreeModuleTemplate.c"
...@@ -87,6 +87,29 @@ ...@@ -87,6 +87,29 @@
Set operations Set operations
****************************************************************************/ ****************************************************************************/
#ifdef INTSET_H
static int
nextIntSet(SetIteration *i)
{
UNLESS(PER_USE(INTSET(i->set))) return -1;
if (i->position >= 0)
{
if (i->position < INTSET(i->set)->len)
{
i->key = INTSET(i->set)->data[i->position];
i->position ++;
}
else
i->position = -1;
}
PER_ALLOW_DEACTIVATION(INTSET(i->set));
return 0;
}
#endif
static int static int
initSetIteration(SetIteration *i, PyObject *s, int w, int *merge) initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
{ {
...@@ -107,6 +130,14 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge) ...@@ -107,6 +130,14 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i->hasValue=1; i->hasValue=1;
} }
else if (ExtensionClassSubclassInstance_Check(s, &SetType))
{
i->set = s;
Py_INCREF(s);
i->next=nextSet;
i->hasValue=0;
}
else if (ExtensionClassSubclassInstance_Check(s, &BTreeType)) else if (ExtensionClassSubclassInstance_Check(s, &BTreeType))
{ {
i->set=BTree_rangeSearch(BTREE(s), NULL, 'i'); i->set=BTree_rangeSearch(BTREE(s), NULL, 'i');
...@@ -121,14 +152,6 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge) ...@@ -121,14 +152,6 @@ 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, &SetType))
{
i->set = s;
Py_INCREF(s);
i->next=nextSet;
i->hasValue=0;
}
else if (ExtensionClassSubclassInstance_Check(s, &TreeSetType)) else if (ExtensionClassSubclassInstance_Check(s, &TreeSetType))
{ {
i->set=BTree_rangeSearch(BTREE(s), NULL, 'k'); i->set=BTree_rangeSearch(BTREE(s), NULL, 'k');
...@@ -137,6 +160,16 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge) ...@@ -137,6 +160,16 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i->next=nextTreeSetItems; i->next=nextTreeSetItems;
i->hasValue=0; i->hasValue=0;
} }
#ifdef INTSET_H
else if (s->ob_type==(PyTypeObject*)intSetType)
{
i->set = s;
Py_INCREF(s);
i->next=nextIntSet;
i->hasValue=0;
}
#endif
else else
{ {
PyErr_SetString(PyExc_TypeError, "invalid argument"); PyErr_SetString(PyExc_TypeError, "invalid argument");
......
*shared* *shared*
OOBTree OOBTree.c -I../../Components/ExtensionClass -I../ZODB OOBTree OOBTree.c -I../../Components/ExtensionClass -I../ZODB
OIBTree OIBTree.c -I../../Components/ExtensionClass -I../ZODB OIBTree OIBTree.c -I../../Components/ExtensionClass -I../ZODB
IIBTree IIBTree.c -I../../Components/ExtensionClass -I../ZODB IIBTree IIBTree.c -I../../Components/ExtensionClass -I../ZODB -I../../Components
IOBTree IOBTree.c -I../../Components/ExtensionClass -I../ZODB IOBTree IOBTree.c -I../../Components/ExtensionClass -I../ZODB -I../../Components
import ZODB import ZODB
try: import intSet
except: pass
else: del intSet
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment