clean up iterator interface; remove Titerator_releaseLock()
This commit is contained in:
parent
120665ae53
commit
09af29abad
5 changed files with 29 additions and 72 deletions
|
@ -5,3 +5,5 @@ ingroup
|
||||||
russell
|
russell
|
||||||
param
|
param
|
||||||
callbacks
|
callbacks
|
||||||
|
mutex
|
||||||
|
todo
|
||||||
|
|
|
@ -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_tupleDone(int xid, void * it) {
|
||||||
|
|
||||||
}
|
|
||||||
static void ts_releaseLock(int xid, void *it) {
|
|
||||||
|
|
||||||
} */
|
} */
|
||||||
/*static const lladdIterator_def_t ts_it = {
|
/*static const lladdIterator_def_t ts_it = {
|
||||||
ts_close, ts_next, ts_tnext, ts_key, ts_value, ts_tupleDone, noopTupDone
|
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;
|
kvt_impl * kvt = it;
|
||||||
Titerator_tupleDone(xid, 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;
|
kv_impl * kv = it;
|
||||||
Titerator_tupleDone(xid, 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) {
|
static void s_tupleDone(int xid, void * it) {
|
||||||
Titerator_tupleDone(xid, ((select_impl*)it)->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; }
|
if(impl->haveTup) { tupleFree(impl->tup); impl->haveTup = 0; }
|
||||||
Titerator_tupleDone(xid,impl->it);
|
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_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() {
|
void ReferentialAlgebra_init() {
|
||||||
lladdIterator_def_t select_def = {
|
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_register(SELECT_ITERATOR, select_def);
|
||||||
lladdIterator_def_t project_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_register(PROJECT_ITERATOR, project_def);
|
||||||
lladdIterator_def_t keyval_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_register(KEYVAL_ITERATOR, keyval_def);
|
||||||
lladdIterator_def_t keyvaltup_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_register(KEYVALTUP_ITERATOR, keyvaltup_def);
|
||||||
lladdIterator_def_t j_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);
|
lladdIterator_register(JOIN_ITERATOR, j_def);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,23 +16,21 @@ static void noopTupDone(int xid, void * foo) { }
|
||||||
|
|
||||||
void iterator_init() {
|
void iterator_init() {
|
||||||
lladdIterator_def_t array_def = {
|
lladdIterator_def_t array_def = {
|
||||||
arrayIterator_close,
|
arrayIterator_close,
|
||||||
arrayIterator_next,
|
arrayIterator_next,
|
||||||
arrayIterator_next,
|
arrayIterator_next,
|
||||||
arrayIterator_key,
|
arrayIterator_key,
|
||||||
arrayIterator_value,
|
arrayIterator_value,
|
||||||
noopTupDone,
|
noopTupDone,
|
||||||
noopTupDone
|
|
||||||
};
|
};
|
||||||
lladdIterator_register(ARRAY_ITERATOR, array_def);
|
lladdIterator_register(ARRAY_ITERATOR, array_def);
|
||||||
lladdIterator_def_t logMemory_def = {
|
lladdIterator_def_t logMemory_def = {
|
||||||
logMemory_Iterator_close,
|
logMemory_Iterator_close,
|
||||||
logMemory_Iterator_next,
|
logMemory_Iterator_next,
|
||||||
logMemory_Iterator_tryNext,
|
logMemory_Iterator_tryNext,
|
||||||
logMemory_Iterator_key,
|
logMemory_Iterator_key,
|
||||||
logMemory_Iterator_value,
|
logMemory_Iterator_value,
|
||||||
logMemory_Iterator_releaseTuple,
|
logMemory_Iterator_releaseTuple,
|
||||||
logMemory_Iterator_releaseLock,
|
|
||||||
};
|
};
|
||||||
lladdIterator_register(LOG_MEMORY_ITERATOR, logMemory_def);
|
lladdIterator_register(LOG_MEMORY_ITERATOR, logMemory_def);
|
||||||
lladdIterator_def_t pointer_def = {
|
lladdIterator_def_t pointer_def = {
|
||||||
|
@ -42,7 +40,6 @@ void iterator_init() {
|
||||||
lladdFifoPool_iterator_key,
|
lladdFifoPool_iterator_key,
|
||||||
lladdFifoPool_iterator_value,
|
lladdFifoPool_iterator_value,
|
||||||
lladdFifoPool_iterator_tupleDone,
|
lladdFifoPool_iterator_tupleDone,
|
||||||
lladdFifoPool_iterator_releaseLock
|
|
||||||
};
|
};
|
||||||
lladdIterator_register(POINTER_ITERATOR, pointer_def);
|
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_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); }
|
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_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); }
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ void LinearHashNTAInit() {
|
||||||
linearHashNTAIterator_key,
|
linearHashNTAIterator_key,
|
||||||
linearHashNTAIterator_value,
|
linearHashNTAIterator_value,
|
||||||
noopTupDone,
|
noopTupDone,
|
||||||
noopTupDone
|
|
||||||
};
|
};
|
||||||
lladdIterator_register(LINEAR_HASH_NTA_ITERATOR, linearHashNTA_def);
|
lladdIterator_register(LINEAR_HASH_NTA_ITERATOR, linearHashNTA_def);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
#include <stasis/transactional.h>
|
#include <stasis/transactional.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef __ITERATOR_H
|
#ifndef __ITERATOR_H
|
||||||
#define __ITERATOR_H
|
#define __ITERATOR_H
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// void * new(void * arg);
|
|
||||||
void (*close)(int xid, void * it);
|
void (*close)(int xid, void * it);
|
||||||
int (*next) (int xid, void * it);
|
int (*next) (int xid, void * it);
|
||||||
int (*tryNext) (int xid, void * it);
|
int (*tryNext) (int xid, void * it);
|
||||||
int (*key) (int xid, void * it, byte ** key);
|
int (*key) (int xid, void * it, byte ** key);
|
||||||
int (*value)(int xid, void * it, byte ** value);
|
int (*value)(int xid, void * it, byte ** value);
|
||||||
void (*tupleDone)(int xid, void * it);
|
void (*tupleDone)(int xid, void * it);
|
||||||
void (*releaseLock)(int xid, void *it);
|
|
||||||
} lladdIterator_def_t;
|
} lladdIterator_def_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
int type;
|
||||||
void * impl;
|
void * impl;
|
||||||
} lladdIterator_t;
|
} lladdIterator_t;
|
||||||
|
@ -26,8 +23,6 @@ void iterator_init();
|
||||||
|
|
||||||
void lladdIterator_register(int type, lladdIterator_def_t info);
|
void lladdIterator_register(int type, lladdIterator_def_t info);
|
||||||
|
|
||||||
//lladdIterator_t Titerator(int type, void * arg);
|
|
||||||
|
|
||||||
void Titerator_close(int xid, lladdIterator_t * it);
|
void Titerator_close(int xid, lladdIterator_t * it);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,39 +45,30 @@ int Titerator_next(int xid, lladdIterator_t * it);
|
||||||
|
|
||||||
@param xid transaction id
|
@param xid transaction id
|
||||||
|
|
||||||
@param it the iterator
|
@param it the iterator
|
||||||
|
|
||||||
@return 1 if the iterator position advanced, and releaseTuple must be called,
|
@return 1 if the iterator position advanced, and releaseTuple must be called,
|
||||||
0 if the iterator has been locked by another reader, no tuples are ready, or the iterator has been closed.
|
0 if the iterator has been locked by another reader, no tuples are ready, or the iterator has been closed.
|
||||||
|
|
||||||
@todo think more carefully about the return value of Titerator_tryNext(). I'm not convinced that a 0/1
|
@todo think more carefully about the return value of Titerator_tryNext(). I'm not convinced that a 0/1
|
||||||
return value is adequate.
|
return value is adequate.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Titerator_tryNext(int xid, lladdIterator_t * it);
|
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
|
This function allows the caller to access the current iterator
|
||||||
position. When an iterator is initialized, it is in the 'null'
|
position. When an iterator is initialized, it is in the 'null'
|
||||||
position. Therefore, this call may not be made until
|
position. Therefore, this call may not be made until
|
||||||
lladdIterator_next has been called. Calling this function after
|
lladdIterator_next has been called. Calling this function after
|
||||||
lladdIterator_next has returned zero, or raised a compensation
|
lladdIterator_next has returned zero, or raised a compensation
|
||||||
error will have undefined results.
|
error will have undefined results.
|
||||||
|
|
||||||
Iterator support for concurrent modification is implementation
|
Iterator support for concurrent modification is implementation
|
||||||
specfic and optional.
|
specific and optional.
|
||||||
|
|
||||||
@param xid transaction id
|
@param xid transaction id
|
||||||
@param it the iterator
|
@param it the iterator
|
||||||
@param key a pointer to the current key of the iterator. This
|
@param key a pointer to the current key of the iterator. This
|
||||||
memory is managed by the iterator implementation.
|
memory is managed by the iterator implementation.
|
||||||
|
|
||||||
@return the size of the value stored in key, or -1 if the
|
@return the size of the value stored in key, or -1 if the
|
||||||
|
@ -90,27 +76,22 @@ int Titerator_tryNext(int xid, lladdIterator_t * it);
|
||||||
(-1 is used to distinguish 'empty key' from 'no key')
|
(-1 is used to distinguish 'empty key' from 'no key')
|
||||||
|
|
||||||
@throw standard lladd error values
|
@throw standard lladd error values
|
||||||
|
|
||||||
@see lladdIterator_value
|
@see lladdIterator_value
|
||||||
*/
|
*/
|
||||||
int Titerator_key(int xid, lladdIterator_t * it, byte ** key);
|
int Titerator_key(int xid, lladdIterator_t * it, byte ** key);
|
||||||
/**
|
/**
|
||||||
Analagous to lladdIterator_key.
|
Analogous to lladdIterator_key.
|
||||||
|
|
||||||
@see lladdIterator_key.
|
@see lladdIterator_key.
|
||||||
*/
|
*/
|
||||||
int Titerator_value(int xid, lladdIterator_t * it, byte ** value);
|
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
|
call is required so that iterators can be reentrant. (Warning: Not
|
||||||
all iterators are reentrant.)
|
all iterators are reentrant.)
|
||||||
*/
|
*/
|
||||||
void Titerator_tupleDone(int xid, lladdIterator_t * it);
|
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
|
END_C_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue