clean up iterator interface; remove Titerator_releaseLock()

This commit is contained in:
Sears Russell 2009-06-28 18:54:57 +00:00
parent 120665ae53
commit 09af29abad
5 changed files with 29 additions and 72 deletions

View file

@ -5,3 +5,5 @@ ingroup
russell
param
callbacks
mutex
todo

View file

@ -92,9 +92,6 @@ static int ts_value(int xid, void * it, byte ** val) {
}
static void ts_tupleDone(int xid, void * it) {
}
static void ts_releaseLock(int xid, void *it) {
} */
/*static const lladdIterator_def_t ts_it = {
ts_close, ts_next, ts_tnext, ts_key, ts_value, ts_tupleDone, noopTupDone
@ -218,10 +215,6 @@ static void kvt_tupleDone(int xid, void * it) {
kvt_impl * kvt = it;
Titerator_tupleDone(xid, kvt->it);
}
static void kvt_releaseLock(int xid, void *it) {
kvt_impl * kvt = it;
Titerator_releaseLock(xid, kvt->it);
}
//////////////////////////////////////////////////////////////////////////////////
/// ///
@ -301,10 +294,6 @@ static void kv_tupleDone(int xid, void * it) {
kv_impl * kv = it;
Titerator_tupleDone(xid, kv->it);
}
static void kv_releaseLock(int xid, void *it) {
kv_impl * kv = it;
Titerator_releaseLock(xid, kv->it);
}
//////////////////////////////////////////////////////////////////////////////////
/// ///
@ -480,9 +469,6 @@ static int s_value(int xid, void * it, byte ** val) {
static void s_tupleDone(int xid, void * it) {
Titerator_tupleDone(xid, ((select_impl*)it)->it);
}
static void s_releaseLock(int xid, void *it) {
Titerator_releaseLock(xid, ((select_impl*)it)->it);
}
//////////////////////////////////////////////////////////////////////////////////
/// ///
@ -564,10 +550,6 @@ static void p_tupleDone(int xid, void * it) {
if(impl->haveTup) { tupleFree(impl->tup); impl->haveTup = 0; }
Titerator_tupleDone(xid,impl->it);
}
static void p_releaseLock(int xid, void *it) {
project_impl * impl = it;
Titerator_releaseLock(xid,impl->it);
}
//////////////////////////////////////////////////////////////////////////////////
/// ///
@ -786,9 +768,6 @@ static int j_value(int xid, void * it, byte ** val) {
}
static void j_tupleDone(int xid, void * it) {
}
static void j_releaseLock(int xid, void *it) {
// noop
}
//////////////////////////////////////////////////////////////////////////////////
/// ///
@ -838,23 +817,23 @@ lladdIterator_t* ReferentialAlgebra_ExecuteQuery(int xid,
*/
void ReferentialAlgebra_init() {
lladdIterator_def_t select_def = {
s_close, s_next, s_tryNext, s_key, s_value, s_tupleDone, s_releaseLock
s_close, s_next, s_tryNext, s_key, s_value, s_tupleDone
};
lladdIterator_register(SELECT_ITERATOR, select_def);
lladdIterator_def_t project_def = {
p_close, p_next, p_tryNext, p_key, p_value, p_tupleDone, p_releaseLock
p_close, p_next, p_tryNext, p_key, p_value, p_tupleDone
};
lladdIterator_register(PROJECT_ITERATOR, project_def);
lladdIterator_def_t keyval_def = {
kv_close, kv_next, kv_tryNext, kv_key, kv_value, kv_tupleDone, kv_releaseLock
kv_close, kv_next, kv_tryNext, kv_key, kv_value, kv_tupleDone,
};
lladdIterator_register(KEYVAL_ITERATOR, keyval_def);
lladdIterator_def_t keyvaltup_def = {
kvt_close, kvt_next, kvt_tryNext, kvt_key, kvt_value, kvt_tupleDone, kvt_releaseLock
kvt_close, kvt_next, kvt_tryNext, kvt_key, kvt_value, kvt_tupleDone,
};
lladdIterator_register(KEYVALTUP_ITERATOR, keyvaltup_def);
lladdIterator_def_t j_def = {
j_close, j_next, j_tryNext, j_key, j_value, j_tupleDone, j_releaseLock
j_close, j_next, j_tryNext, j_key, j_value, j_tupleDone
};
lladdIterator_register(JOIN_ITERATOR, j_def);
}

View file

@ -22,7 +22,6 @@ void iterator_init() {
arrayIterator_key,
arrayIterator_value,
noopTupDone,
noopTupDone
};
lladdIterator_register(ARRAY_ITERATOR, array_def);
lladdIterator_def_t logMemory_def = {
@ -32,7 +31,6 @@ void iterator_init() {
logMemory_Iterator_key,
logMemory_Iterator_value,
logMemory_Iterator_releaseTuple,
logMemory_Iterator_releaseLock,
};
lladdIterator_register(LOG_MEMORY_ITERATOR, logMemory_def);
lladdIterator_def_t pointer_def = {
@ -42,7 +40,6 @@ void iterator_init() {
lladdFifoPool_iterator_key,
lladdFifoPool_iterator_value,
lladdFifoPool_iterator_tupleDone,
lladdFifoPool_iterator_releaseLock
};
lladdIterator_register(POINTER_ITERATOR, pointer_def);
}
@ -55,4 +52,3 @@ int Titerator_tryNext(int xid, lladdIterator_t * it) { return itera
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); }
void Titerator_tupleDone(int xid, lladdIterator_t * it) { iterators[it->type].tupleDone(xid, it->impl); }
void Titerator_releaseLock(int xid, lladdIterator_t * it) { iterators[it->type].releaseLock(xid, it->impl); }

View file

@ -50,7 +50,6 @@ void LinearHashNTAInit() {
linearHashNTAIterator_key,
linearHashNTAIterator_value,
noopTupDone,
noopTupDone
};
lladdIterator_register(LINEAR_HASH_NTA_ITERATOR, linearHashNTA_def);
}

View file

@ -1,20 +1,17 @@
#include <stasis/transactional.h>
#ifndef __ITERATOR_H
#define __ITERATOR_H
BEGIN_C_DECLS
typedef struct {
// void * new(void * arg);
void (*close)(int xid, void * it);
int (*next) (int xid, void * it);
int (*tryNext) (int xid, void * it);
int (*key) (int xid, void * it, byte ** key);
int (*value)(int xid, void * it, byte ** value);
void (*tupleDone)(int xid, void * it);
void (*releaseLock)(int xid, void *it);
} lladdIterator_def_t;
typedef struct {
@ -26,8 +23,6 @@ void iterator_init();
void lladdIterator_register(int type, lladdIterator_def_t info);
//lladdIterator_t Titerator(int type, void * arg);
void Titerator_close(int xid, lladdIterator_t * it);
/**
@ -58,17 +53,8 @@ int Titerator_next(int xid, lladdIterator_t * it);
@todo think more carefully about the return value of Titerator_tryNext(). I'm not convinced that a 0/1
return value is adequate.
*/
int Titerator_tryNext(int xid, lladdIterator_t * it);
/**
NOTE: next acquires a mutex, releaseTuple releases mutex,
next key value --atomic
provides , allows iterator to clean up if necessary
> such as release lock
*/
//int (*releaseTuple)(int xid, void * it);
/**
This function allows the caller to access the current iterator
position. When an iterator is initialized, it is in the 'null'
@ -78,7 +64,7 @@ int Titerator_tryNext(int xid, lladdIterator_t * it);
error will have undefined results.
Iterator support for concurrent modification is implementation
specfic and optional.
specific and optional.
@param xid transaction id
@param it the iterator
@ -95,22 +81,17 @@ int Titerator_tryNext(int xid, lladdIterator_t * it);
*/
int Titerator_key(int xid, lladdIterator_t * it, byte ** key);
/**
Analagous to lladdIterator_key.
Analogous to lladdIterator_key.
@see lladdIterator_key.
*/
int Titerator_value(int xid, lladdIterator_t * it, byte ** value);
/**
Iterator callers must call this before calling next(). A seperate
Iterator callers must call this before calling next(). A separate
call is required so that iterators can be reentrant. (Warning: Not
all iterators are reentrant.)
*/
void Titerator_tupleDone(int xid, lladdIterator_t * it);
/**
@todo what is Titerator_releaseLock for?!? It's never called, and
I can't remember why it's here... Delete it?
*/
void Titerator_releaseLock(int xid, lladdIterator_t * it);
END_C_DECLS