2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/iterator.h>
|
2005-03-10 03:19:04 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/operations.h>
|
|
|
|
#include <stasis/arrayCollection.h>
|
2008-04-13 04:02:57 +00:00
|
|
|
#include <stasis/logger/logMemory.h>
|
2005-03-10 03:19:04 +00:00
|
|
|
|
|
|
|
static lladdIterator_def_t iterators[MAX_ITERATOR_TYPES];
|
|
|
|
|
2008-03-01 19:34:12 +00:00
|
|
|
void lladdIterator_register(int type, lladdIterator_def_t info) {
|
2005-03-10 03:19:04 +00:00
|
|
|
assert(type < MAX_ITERATOR_TYPES);
|
|
|
|
iterators[type] = info;
|
|
|
|
}
|
2005-03-15 05:30:57 +00:00
|
|
|
static void noopTupDone(int xid, void * foo) { }
|
2005-03-10 03:19:04 +00:00
|
|
|
|
|
|
|
void iterator_init() {
|
|
|
|
lladdIterator_def_t array_def = {
|
2005-03-16 00:52:21 +00:00
|
|
|
arrayIterator_close,
|
|
|
|
arrayIterator_next,
|
|
|
|
arrayIterator_next,
|
|
|
|
arrayIterator_key,
|
|
|
|
arrayIterator_value,
|
2006-06-13 23:58:04 +00:00
|
|
|
noopTupDone,
|
2005-03-16 00:52:21 +00:00
|
|
|
noopTupDone
|
2005-03-10 03:19:04 +00:00
|
|
|
};
|
|
|
|
lladdIterator_register(ARRAY_ITERATOR, array_def);
|
2005-03-15 05:30:57 +00:00
|
|
|
lladdIterator_def_t logMemory_def = {
|
2005-03-16 00:52:21 +00:00
|
|
|
logMemory_Iterator_close,
|
|
|
|
logMemory_Iterator_next,
|
|
|
|
logMemory_Iterator_tryNext,
|
|
|
|
logMemory_Iterator_key,
|
|
|
|
logMemory_Iterator_value,
|
2005-03-17 04:38:55 +00:00
|
|
|
logMemory_Iterator_releaseTuple,
|
|
|
|
logMemory_Iterator_releaseLock,
|
2005-03-15 05:30:57 +00:00
|
|
|
};
|
|
|
|
lladdIterator_register(LOG_MEMORY_ITERATOR, logMemory_def);
|
2005-03-23 08:07:53 +00:00
|
|
|
lladdIterator_def_t pointer_def = {
|
|
|
|
lladdFifoPool_iterator_close,
|
|
|
|
lladdFifoPool_iterator_next,
|
|
|
|
lladdFifoPool_iterator_tryNext,
|
|
|
|
lladdFifoPool_iterator_key,
|
|
|
|
lladdFifoPool_iterator_value,
|
|
|
|
lladdFifoPool_iterator_tupleDone,
|
|
|
|
lladdFifoPool_iterator_releaseLock
|
|
|
|
};
|
|
|
|
lladdIterator_register(POINTER_ITERATOR, pointer_def);
|
2005-03-10 03:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//lladdIterator_t Titerator(int type, void * arg);
|
2005-03-16 00:52:21 +00:00
|
|
|
void Titerator_close (int xid, lladdIterator_t * it) { iterators[it->type].close(xid, it->impl); free(it); }
|
|
|
|
int Titerator_next (int xid, lladdIterator_t * it) { return iterators[it->type].next (xid, it->impl); }
|
|
|
|
int Titerator_tryNext(int xid, lladdIterator_t * it) { return iterators[it->type].tryNext (xid, it->impl); }
|
|
|
|
int Titerator_key (int xid, lladdIterator_t * it, byte ** key){ return iterators[it->type].key (xid, it->impl, key); }
|
2005-03-10 03:19:04 +00:00
|
|
|
int Titerator_value(int xid, lladdIterator_t * it, byte ** value){ return iterators[it->type].value(xid, it->impl, value); }
|
2005-03-15 05:30:57 +00:00
|
|
|
void Titerator_tupleDone(int xid, lladdIterator_t * it) { iterators[it->type].tupleDone(xid, it->impl); }
|
2005-03-17 04:38:55 +00:00
|
|
|
void Titerator_releaseLock(int xid, lladdIterator_t * it) { iterators[it->type].releaseLock(xid, it->impl); }
|