2005-03-10 03:19:04 +00:00
|
|
|
#include <lladd/iterator.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <lladd/operations.h>
|
|
|
|
#include <lladd/arrayCollection.h>
|
2005-03-15 05:30:57 +00:00
|
|
|
#include "logger/logMemory.h"
|
2005-03-10 03:19:04 +00:00
|
|
|
|
|
|
|
static lladdIterator_def_t iterators[MAX_ITERATOR_TYPES];
|
|
|
|
|
|
|
|
static void lladdIterator_register(int type, lladdIterator_def_t info) {
|
|
|
|
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 linearHashNTA_def = {
|
2005-03-15 05:30:57 +00:00
|
|
|
linearHashNTAIterator_close, linearHashNTAIterator_next, linearHashNTAIterator_key, linearHashNTAIterator_value, noopTupDone
|
2005-03-10 03:19:04 +00:00
|
|
|
};
|
|
|
|
lladdIterator_register(LINEAR_HASH_NTA_ITERATOR, linearHashNTA_def);
|
|
|
|
lladdIterator_def_t array_def = {
|
2005-03-15 05:30:57 +00:00
|
|
|
arrayIterator_close, arrayIterator_next, arrayIterator_key, arrayIterator_value, 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 = {
|
|
|
|
logMemory_Iterator_close, logMemory_Iterator_next, logMemory_Iterator_key, logMemory_Iterator_value, noopTupDone
|
|
|
|
};
|
|
|
|
lladdIterator_register(LOG_MEMORY_ITERATOR, logMemory_def);
|
2005-03-10 03:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//lladdIterator_t Titerator(int type, void * arg);
|
|
|
|
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_key (int xid, lladdIterator_t * it, byte ** key) { return iterators[it->type].key (xid, it->impl, key); }
|
|
|
|
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); }
|