1
0
Fork 0

cleanup, remove deprecated stuff

This commit is contained in:
Frank Celler 2012-05-10 09:45:11 +02:00
parent 32110b4ba8
commit baf039b608
18 changed files with 42 additions and 5078 deletions

View File

@ -235,7 +235,6 @@ avocado_SOURCES = \
VocBase/query-order.c \
VocBase/query-parse.c \
VocBase/query-result.c \
VocBase/query.c \
VocBase/shadow-data.c \
VocBase/simple-collection.c \
VocBase/synchroniser.c \

View File

@ -413,7 +413,7 @@ am_avocado_OBJECTS = Admin/ApplicationAdminServer.$(OBJEXT) \
VocBase/query-locks.$(OBJEXT) VocBase/query-memory.$(OBJEXT) \
VocBase/query-node.$(OBJEXT) VocBase/query-order.$(OBJEXT) \
VocBase/query-parse.$(OBJEXT) VocBase/query-result.$(OBJEXT) \
VocBase/query.$(OBJEXT) VocBase/shadow-data.$(OBJEXT) \
VocBase/shadow-data.$(OBJEXT) \
VocBase/simple-collection.$(OBJEXT) \
VocBase/synchroniser.$(OBJEXT) VocBase/voc-shaper.$(OBJEXT) \
VocBase/vocbase.$(OBJEXT)
@ -868,7 +868,6 @@ avocado_SOURCES = \
VocBase/query-order.c \
VocBase/query-parse.c \
VocBase/query-result.c \
VocBase/query.c \
VocBase/shadow-data.c \
VocBase/simple-collection.c \
VocBase/synchroniser.c \
@ -1943,8 +1942,6 @@ VocBase/query-parse.$(OBJEXT): VocBase/$(am__dirstamp) \
VocBase/$(DEPDIR)/$(am__dirstamp)
VocBase/query-result.$(OBJEXT): VocBase/$(am__dirstamp) \
VocBase/$(DEPDIR)/$(am__dirstamp)
VocBase/query.$(OBJEXT): VocBase/$(am__dirstamp) \
VocBase/$(DEPDIR)/$(am__dirstamp)
VocBase/shadow-data.$(OBJEXT): VocBase/$(am__dirstamp) \
VocBase/$(DEPDIR)/$(am__dirstamp)
VocBase/simple-collection.$(OBJEXT): VocBase/$(am__dirstamp) \
@ -2243,7 +2240,6 @@ mostlyclean-compile:
-rm -f VocBase/query-order.$(OBJEXT)
-rm -f VocBase/query-parse.$(OBJEXT)
-rm -f VocBase/query-result.$(OBJEXT)
-rm -f VocBase/query.$(OBJEXT)
-rm -f VocBase/shadow-data.$(OBJEXT)
-rm -f VocBase/simple-collection.$(OBJEXT)
-rm -f VocBase/synchroniser.$(OBJEXT)
@ -2492,7 +2488,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/query-order.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/query-parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/query-result.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/query.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/shadow-data.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/simple-collection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@VocBase/$(DEPDIR)/synchroniser.Po@am__quote@

View File

@ -166,78 +166,6 @@ bool TRI_DefineJsonArrayExecutionContext (TRI_js_exec_context_t context,
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief defines documents in a join/where - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_DefineWhereExecutionContextX (TRI_js_exec_context_t context,
const TRI_select_join_t* join,
const size_t level,
const bool isJoin) {
js_exec_context_t* ctx;
TRI_doc_mptr_t* document;
ctx = (js_exec_context_t*) context;
for (size_t i = 0; i <= level; i++) {
TRI_join_part_t* part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part->_type != JOIN_TYPE_LIST || (isJoin && (level == i))) {
// part is a single-document container
document = (TRI_doc_mptr_t*) part->_singleDocument;
if (!document) {
ctx->_arguments->Set(v8::String::New(part->_alias), v8::Null());
}
else {
v8::Handle<v8::Value> result;
bool ok = TRI_ObjectDocumentPointer(part->_collection->_collection, document, &result);
if (!ok) {
return false;
}
ctx->_arguments->Set(v8::String::New(part->_alias), result);
}
if (part->_extraData._size) {
// make extra values available
ctx->_arguments->Set(v8::String::New(part->_extraData._alias), v8::Number::New(*((double*) part->_extraData._singleValue)));
}
}
else {
// part is a multi-document container
v8::Handle<v8::Array> array = v8::Array::New();
size_t pos = 0;
for (size_t n = 0; n < part->_listDocuments._length; n++) {
document = (TRI_doc_mptr_t*) part->_listDocuments._buffer[n];
if (document) {
v8::Handle<v8::Value> result;
bool ok = TRI_ObjectDocumentPointer(part->_collection->_collection, document, &result);
if (!ok) {
return false;
}
array->Set(pos++, result);
}
}
ctx->_arguments->Set(v8::String::New(part->_alias), array);
if (part->_extraData._size) {
// make extra values available
v8::Handle<v8::Array> array = v8::Array::New();
uint32_t pos = 0;
for (size_t n = 0; n < part->_extraData._listValues._length; n++) {
double* data = (double*) part->_extraData._listValues._buffer[n];
if (data) {
v8::Handle<v8::Value> result;
array->Set(pos++, v8::Number::New(*data));
}
}
ctx->_arguments->Set(v8::String::New(part->_extraData._alias), array);
}
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief defines documents in a join/where
////////////////////////////////////////////////////////////////////////////////
@ -536,30 +464,6 @@ bool TRI_ExecuteExecutionContext (TRI_js_exec_context_t context, void* storage)
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context for a condition - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_ExecuteConditionExecutionContextX (TRI_js_exec_context_t context, bool* r) {
js_exec_context_t* ctx;
ctx = (js_exec_context_t*) context;
// convert back into a handle
v8::Persistent<v8::Function> func = ctx->_func;
// and execute the function
v8::Handle<v8::Value> args[] = { ctx->_arguments };
v8::Handle<v8::Value> result = func->Call(func, 1, args);
if (result.IsEmpty()) {
return false;
}
*r = TRI_ObjectToBoolean(result);
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context for a condition
////////////////////////////////////////////////////////////////////////////////

View File

@ -58,15 +58,6 @@ bool TRI_DefineJsonArrayExecutionContext (TRI_js_exec_context_t,
TRI_json_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief defines documents in a join/where - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_DefineWhereExecutionContextX (TRI_js_exec_context_t,
const TRI_select_join_t*,
const size_t,
const bool);
////////////////////////////////////////////////////////////////////////////////
/// @brief defines documents in a join/where
////////////////////////////////////////////////////////////////////////////////
@ -101,25 +92,12 @@ bool TRI_DefineCompareExecutionContext (TRI_js_exec_context_t,
TRI_sr_documents_t*,
TRI_sr_documents_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_ExecuteExecutionContextX (TRI_js_exec_context_t, void* storage);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context
////////////////////////////////////////////////////////////////////////////////
bool TRI_ExecuteExecutionContext (TRI_js_exec_context_t, void* storage);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context for a condition - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_ExecuteConditionExecutionContextX (TRI_js_exec_context_t, bool* result);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes an execution context for a condition
////////////////////////////////////////////////////////////////////////////////

View File

@ -63,9 +63,6 @@ typedef struct TRI_v8_global_s {
TRI_v8_global_s ()
: JSGeneralCursors(),
JSQueries(), // DEPRECATED
JSCursors(), // DEPRECATED
JSWheres(), // DEPRECATED
JSBarriers(),
Actions(),
ActionsLock(),
@ -73,11 +70,8 @@ typedef struct TRI_v8_global_s {
EdgesColTempl(),
ErrorTempl(),
GeneralCursorTempl(),
QueryTempl(), // DEPRECATED
WhereTempl(), // DEPRECATED
VocbaseColTempl(),
VocbaseTempl(),
SLOperatorTempl(), // DEPRECATED
DictionaryTempl(),
CollectionQueryType(),
OutputFuncName(),
@ -104,24 +98,6 @@ typedef struct TRI_v8_global_s {
std::map< void*, v8::Persistent<v8::Value> > JSGeneralCursors;
////////////////////////////////////////////////////////////////////////////////
/// @brief query mapping for weak pointers - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
std::map< void*, v8::Persistent<v8::Value> > JSQueries;
////////////////////////////////////////////////////////////////////////////////
/// @brief cursor mapping for weak pointers - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
std::map< void*, v8::Persistent<v8::Value> > JSCursors;
////////////////////////////////////////////////////////////////////////////////
/// @brief where clause mapping for weak pointers - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
std::map< void*, v8::Persistent<v8::Value> > JSWheres;
////////////////////////////////////////////////////////////////////////////////
/// @brief barrier mapping for weak pointers
////////////////////////////////////////////////////////////////////////////////
@ -189,24 +165,6 @@ typedef struct TRI_v8_global_s {
v8::Persistent<v8::ObjectTemplate> GeneralCursorTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief query template - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
v8::Persistent<v8::ObjectTemplate> QueryTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief cursor template - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
v8::Persistent<v8::ObjectTemplate> CursorTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief where clause template - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
v8::Persistent<v8::ObjectTemplate> WhereTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief TRI_vocbase_col_t template
////////////////////////////////////////////////////////////////////////////////
@ -225,12 +183,6 @@ typedef struct TRI_v8_global_s {
v8::Persistent<v8::ObjectTemplate> ShapedJsonTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief skiplistoperator template - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
v8::Persistent<v8::ObjectTemplate> SLOperatorTempl;
////////////////////////////////////////////////////////////////////////////////
/// @brief dictionary template
////////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -35,11 +35,6 @@
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- EXECUTION CONTEXT
// -----------------------------------------------------------------------------
@ -48,6 +43,11 @@ extern "C" {
// --SECTION-- public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript execution context
////////////////////////////////////////////////////////////////////////////////
@ -55,29 +55,18 @@ extern "C" {
typedef void* TRI_js_exec_context_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief execution context of a query
///
/// In order to execute a query, you need an execution context. The results are
/// only valid as long as the context exists. After freeing the context you
/// should no longer access the result cursor or the result documents.
///
/// When creating an execution context, parts of clauses might use JavaScript.
/// A JavaScript execution context is created for these clauses.
/// @}
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_rc_context_s { // DEPRECATED
TRI_doc_collection_t* _primary;
TRI_js_exec_context_t _selectClause;
TRI_js_exec_context_t _whereClause;
TRI_js_exec_context_t _orderClause;
}
TRI_rc_context_t;
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new execution context
////////////////////////////////////////////////////////////////////////////////

View File

@ -43,37 +43,6 @@
// --SECTION-- type independent functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new base data data feeder struct - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static TRI_data_feeder_t* CreateDataFeederX (const TRI_data_feeder_type_e type,
const TRI_doc_collection_t* collection,
const TRI_join_t* join,
size_t level) {
TRI_data_feeder_t* feeder;
feeder = (TRI_data_feeder_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_t), false);
if (!feeder) {
return NULL;
}
feeder->_type = type;
feeder->_level = level;
feeder->_join = (TRI_select_join_t*) join;
feeder->_part = (TRI_join_part_t*) ((TRI_select_join_t*) join)->_parts._buffer[level];
feeder->_collection = collection;
feeder->_ranges = NULL;
feeder->_state = NULL;
feeder->init = NULL;
feeder->rewind = NULL;
feeder->current = NULL;
feeder->free = NULL;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new base data data feeder struct
////////////////////////////////////////////////////////////////////////////////
@ -218,36 +187,6 @@ static void FreeFeederTableScan (TRI_data_feeder_t* feeder) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new table scan data feeder - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederTableScanX (const TRI_doc_collection_t* collection,
TRI_join_t* join,
size_t level) {
TRI_data_feeder_t* feeder;
feeder = CreateDataFeederX(FEEDER_TABLE_SCAN, collection, join, level);
if (!feeder) {
return NULL;
}
feeder->_state = (TRI_data_feeder_table_scan_t*)
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_table_scan_t), false);
if (!feeder->_state) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
return NULL;
}
feeder->init = InitFeederTableScan;
feeder->rewind = RewindFeederTableScan;
feeder->current = CurrentFeederTableScan;
feeder->free = FreeFeederTableScan;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new table scan data feeder
////////////////////////////////////////////////////////////////////////////////
@ -445,36 +384,6 @@ static void FreeFeederPrimaryLookup (TRI_data_feeder_t* feeder) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new primary index data feeder - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederPrimaryLookupX (const TRI_doc_collection_t* collection,
TRI_join_t* join,
size_t level) {
TRI_data_feeder_t* feeder;
feeder = CreateDataFeederX(FEEDER_PRIMARY_LOOKUP, collection, join, level);
if (!feeder) {
return NULL;
}
feeder->_state = (TRI_data_feeder_primary_lookup_t*)
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_primary_lookup_t), false);
if (!feeder->_state) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
return NULL;
}
// init feeder
feeder->init = InitFeederPrimaryLookup;
feeder->rewind = RewindFeederPrimaryLookup;
feeder->current = CurrentFeederPrimaryLookup;
feeder->free = FreeFeederPrimaryLookup;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new primary index data feeder
////////////////////////////////////////////////////////////////////////////////
@ -694,35 +603,6 @@ static void FreeFeederHashLookup (TRI_data_feeder_t* feeder) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for hash lookups - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederHashLookupX (const TRI_doc_collection_t* collection,
TRI_join_t* join,
size_t level) {
TRI_data_feeder_t* feeder;
feeder = CreateDataFeederX(FEEDER_HASH_LOOKUP, collection, join, level);
if (!feeder) {
return NULL;
}
feeder->_state = (TRI_data_feeder_hash_lookup_t*)
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_hash_lookup_t), false);
if (!feeder->_state) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
return NULL;
}
feeder->init = InitFeederHashLookup;
feeder->rewind = RewindFeederHashLookup;
feeder->current = CurrentFeederHashLookup;
feeder->free = FreeFeederHashLookup;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for hash lookups
////////////////////////////////////////////////////////////////////////////////
@ -1157,35 +1037,6 @@ static void FreeFeederSkiplistLookup (TRI_data_feeder_t* feeder) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for skiplist lookups - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederSkiplistLookupX (const TRI_doc_collection_t* collection,
TRI_join_t* join,
size_t level) {
TRI_data_feeder_t* feeder;
feeder = CreateDataFeederX(FEEDER_SKIPLIST_LOOKUP, collection, join, level);
if (!feeder) {
return NULL;
}
feeder->_state = (TRI_data_feeder_skiplist_lookup_t*)
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_skiplist_lookup_t), false);
if (!feeder->_state) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
return NULL;
}
feeder->init = InitFeederSkiplistLookup;
feeder->rewind = RewindFeederSkiplistLookup;
feeder->current = CurrentFeederSkiplistLookup;
feeder->free = FreeFeederSkiplistLookup;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for skiplist lookups
////////////////////////////////////////////////////////////////////////////////
@ -1329,42 +1180,6 @@ static void FreeFeederGeoLookup (TRI_data_feeder_t* feeder) {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for geo lookups - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederGeoLookupX (const TRI_doc_collection_t* collection,
TRI_join_t* join,
size_t level,
QL_ast_query_geo_restriction_t* restriction) {
TRI_data_feeder_t* feeder;
TRI_data_feeder_geo_lookup_t* state;
feeder = CreateDataFeederX(FEEDER_GEO_LOOKUP, collection, join, level);
if (!feeder) {
return NULL;
}
feeder->_state = (TRI_data_feeder_geo_lookup_t*)
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_data_feeder_geo_lookup_t), false);
state = (TRI_data_feeder_geo_lookup_t*) feeder->_state;
if (!state) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, feeder);
return NULL;
}
state->_restriction = restriction;
feeder->init = InitFeederGeoLookup;
feeder->rewind = RewindFeederGeoLookup;
feeder->current = CurrentFeederGeoLookup;
feeder->free = FreeFeederGeoLookup;
return feeder;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder for geo lookups
////////////////////////////////////////////////////////////////////////////////

View File

@ -280,14 +280,6 @@ typedef struct TRI_data_feeder_table_scan_s {
}
TRI_data_feeder_table_scan_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (table scan) - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederTableScanX (const TRI_doc_collection_t*,
TRI_join_t*,
size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (table scan)
////////////////////////////////////////////////////////////////////////////////
@ -317,14 +309,6 @@ typedef struct TRI_data_feeder_primary_lookup_s {
TRI_data_feeder_primary_lookup_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (primary index lookup) - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederPrimaryLookupX (const TRI_doc_collection_t*,
TRI_join_t*,
size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (primary index lookup)
////////////////////////////////////////////////////////////////////////////////
@ -355,14 +339,6 @@ typedef struct TRI_data_feeder_hash_lookup_s {
}
TRI_data_feeder_hash_lookup_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (hash index lookup) - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederHashLookupX (const TRI_doc_collection_t*,
TRI_join_t*,
size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (hash index lookup)
////////////////////////////////////////////////////////////////////////////////
@ -395,14 +371,6 @@ typedef struct TRI_data_feeder_skiplist_lookup_s {
}
TRI_data_feeder_skiplist_lookup_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (skiplist lookup) - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederSkiplistLookupX (const TRI_doc_collection_t*,
TRI_join_t*,
size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (skiplist lookup)
////////////////////////////////////////////////////////////////////////////////
@ -430,15 +398,6 @@ typedef struct TRI_data_feeder_geo_lookup_s {
}
TRI_data_feeder_geo_lookup_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (geo index lookup) - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_data_feeder_t* TRI_CreateDataFeederGeoLookupX (const TRI_doc_collection_t*,
TRI_join_t*,
size_t,
QL_ast_query_geo_restriction_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new data feeder (geo index lookup)
////////////////////////////////////////////////////////////////////////////////

View File

@ -67,85 +67,6 @@ static void LogIndexString(TRI_index_t const* idx,
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Determine which geo indexes to use in a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static TRI_data_feeder_t* DetermineGeoIndexUsageX (const TRI_vocbase_t* vocbase,
const TRI_select_join_t* join,
const size_t level,
const TRI_join_part_t* part) {
assert(false);
#if 0
TRI_vector_pointer_t* indexDefinitions;
TRI_index_definition_t* indexDefinition;
TRI_data_feeder_t* feeder = NULL;
size_t i;
assert(part->_geoRestriction);
indexDefinitions = TRI_GetCollectionIndexes(vocbase, part->_collectionName);
if (!indexDefinitions) {
return feeder;
}
// enum all indexes
for (i = 0; i < indexDefinitions->_length; i++) {
indexDefinition = (TRI_index_definition_t*) indexDefinitions->_buffer[i];
if (indexDefinition->_type != TRI_IDX_TYPE_GEO_INDEX) {
// ignore all indexes except geo indexes here
continue;
}
if (indexDefinition->_fields->_length != 2) {
continue;
}
if (strcmp(indexDefinition->_fields->_buffer[0],
part->_geoRestriction->_compareLat._field) != 0) {
continue;
}
if (strcmp(indexDefinition->_fields->_buffer[1],
part->_geoRestriction->_compareLon._field) != 0) {
continue;
}
feeder =
TRI_CreateDataFeederGeoLookupX((TRI_doc_collection_t*) part->_collection,
(TRI_join_t*) join,
level,
part->_geoRestriction);
if (feeder) {
// set up addtl data for feeder
feeder->_indexId = indexDefinition->_iid;
break;
}
}
TRI_FreeIndexDefinitions(indexDefinitions);
return feeder;
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Determine which indexes to use in a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static TRI_data_feeder_t* DetermineIndexUsageX (const TRI_vocbase_t* vocbase,
const TRI_select_join_t* join,
const size_t level,
const TRI_join_part_t* part) {
return TRI_CreateDataFeederTableScanX((TRI_doc_collection_t*) part->_collection->_collection,
(TRI_join_t*) join,
level);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief determines which geo indexes to use in a query
////////////////////////////////////////////////////////////////////////////////
@ -461,107 +382,6 @@ static inline TRI_select_part_e GetValueDataPartType(const TRI_join_type_e type)
return RESULT_PART_VALUE_SINGLE;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new select result from a join definition - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_select_result_t* TRI_JoinSelectResultX (const TRI_vocbase_t* vocbase,
TRI_select_join_t* join) {
TRI_select_result_t* result;
TRI_vector_pointer_t* dataparts;
TRI_select_datapart_t* datapart;
TRI_join_part_t* part;
size_t i;
bool error = false;
dataparts = (TRI_vector_pointer_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vector_pointer_t), false);
if (!dataparts) {
return NULL;
}
TRI_InitVectorPointer(dataparts, TRI_UNKNOWN_MEM_ZONE);
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part) {
datapart = TRI_CreateDataPart(part->_alias,
part->_collection->_collection,
GetDocumentDataPartType(part->_type),
0,
part->_mustMaterialize._select,
part->_mustMaterialize._order);
if (datapart) {
TRI_PushBackVectorPointer(dataparts, datapart);
// if result contains some artificial extra data, create an additional
// result part for it
if (part->_extraData._size) {
datapart = TRI_CreateDataPart(part->_extraData._alias,
NULL,
GetValueDataPartType(part->_type),
part->_extraData._size,
part->_mustMaterialize._select,
part->_mustMaterialize._order);
if (datapart) {
TRI_PushBackVectorPointer(dataparts, datapart);
}
else {
error = true;
}
}
}
else {
error = true;
}
// determine the access type (index usage/full table scan) for collection
if (part->_geoRestriction) {
part->_feeder = DetermineGeoIndexUsageX(vocbase, join, i, part);
}
else {
part->_feeder = DetermineIndexUsageX(vocbase, join, i, part);
}
if (!part->_feeder) {
error = true;
}
}
else {
error = true;
}
}
// set up the data structures to retrieve the result documents
result = TRI_CreateSelectResult(dataparts);
if (!result) {
error = true;
}
if (error) {
// clean up
for (i = 0; i < dataparts->_length; i++) {
datapart = (TRI_select_datapart_t*) dataparts->_buffer[i];
if (datapart) {
datapart->free(datapart);
}
}
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part->_feeder) {
part->_feeder->free(part->_feeder);
part->_feeder = NULL;
}
}
TRI_DestroyVectorPointer(dataparts);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, dataparts);
return NULL;
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Free join data parts
////////////////////////////////////////////////////////////////////////////////
@ -716,37 +536,6 @@ TRI_select_result_t* TRI_JoinSelectResult (TRI_query_instance_t* const instance)
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Check an ON condition for a join - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static inline bool CheckJoinClauseX (const TRI_select_join_t const* join,
const size_t level) {
TRI_join_part_t* part;
bool whereResult;
part = (TRI_join_part_t*) join->_parts._buffer[level];
TRI_DefineWhereExecutionContextX(part->_context, join, level, true);
TRI_ExecuteConditionExecutionContextX(part->_context, &whereResult);
return whereResult;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Check a WHERE condition - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static inline bool CheckWhereClauseX (const TRI_rc_context_t *context,
const TRI_select_join_t const* join,
const size_t level) {
bool whereResult;
TRI_DefineWhereExecutionContextX(context->_whereClause, join, level, false);
TRI_ExecuteConditionExecutionContextX(context->_whereClause, &whereResult);
return whereResult;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Check an ON condition for a join
////////////////////////////////////////////////////////////////////////////////
@ -783,165 +572,6 @@ static inline bool CheckWhereClause (TRI_query_instance_t* const instance,
return whereResult;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Execute join part recursively - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static void RecursiveJoinX (TRI_select_result_t* results,
TRI_select_join_t* join,
const size_t level,
TRI_qry_where_t *where,
TRI_rc_context_t *context,
TRI_voc_size_t *skip,
TRI_voc_ssize_t *limit) {
TRI_join_part_t* part;
TRI_data_feeder_t* feeder;
size_t numJoins;
bool joinMatch = false;
if (*limit == 0) {
return;
}
numJoins = join->_parts._length - 1;
assert(level <= numJoins);
part = (TRI_join_part_t*) join->_parts._buffer[level];
feeder = part->_feeder;
feeder->rewind(feeder);
// distinction between aggregates (list joins) and
// non-aggregates (inner join, left join)
if (part->_type == JOIN_TYPE_LIST) {
// join type is aggregate (list join)
assert(level > 0);
TRI_ClearVectorPointer(&part->_listDocuments);
TRI_ClearVectorPointer(&part->_extraData._listValues);
while (true) {
// get next document
if (!feeder->current(feeder)) {
// end of documents in collection
// exit this join
break;
}
if (part->_context) {
// check ON clause
if (!CheckJoinClauseX(join, level)) {
continue;
}
}
// push documents into vector
TRI_PushBackVectorPointer(&part->_listDocuments, part->_singleDocument);
TRI_PushBackVectorPointer(&part->_extraData._listValues, part->_extraData._singleValue);
}
// all documents collected in vector
if (level == numJoins) {
// last join was executed
if (where != 0) {
// check WHERE clause for full row
if (!CheckWhereClauseX(context, join, level)) {
return;
}
}
// apply SKIP limits
if (*skip > 0) {
(*skip)--;
return;
}
// full match, now add documents to result sets
TRI_AddJoinSelectResultX(results, join);
(*limit)--;
// apply LIMIT
if (*limit == 0) {
return;
}
}
else {
// recurse into next join
RecursiveJoinX(results, join, level + 1, where, context, skip, limit);
}
return;
// end of list join
}
// join type is non-aggregate
while (true) {
// get next document
if (!feeder->current(feeder)) {
// end of documents in collection
// exit this join
break;
}
if (level > 0 && part->_context) {
// check ON clause
if (!CheckJoinClauseX(join, level)) {
if (part->_type == JOIN_TYPE_OUTER) {
// set document to null in outer join
part->_singleDocument = NULL;
part->_extraData._singleValue = NULL;
// left join: if we are not at the last document of the left
// joined collection, we continue
// if we are at the last document and there hasn't been a
// match, we must still include the left document if the where
// condition matches
if (joinMatch) {
continue;
}
}
else {
// inner join: always go to next record
continue;
}
}
joinMatch = true;
}
if (level == numJoins) {
// last join was executed
if (where != 0) {
// check WHERE clause for full row
if (!CheckWhereClauseX(context, join, level)) {
continue;
}
}
// apply SKIP limits
if (*skip > 0) {
(*skip)--;
continue;
}
// full match, now add documents to result sets
TRI_AddJoinSelectResultX(results, join);
(*limit)--;
// apply LIMIT
if (*limit == 0) {
return;
}
}
else {
// recurse into next join
RecursiveJoinX(results, join, level + 1, where, context, skip, limit);
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Forward declaration
////////////////////////////////////////////////////////////////////////////////
@ -1131,55 +761,6 @@ static void DeinitJoin (TRI_query_instance_t* const instance) {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Execute joins - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_ExecuteJoinsX (TRI_select_result_t* results,
TRI_select_join_t* join,
TRI_qry_where_t* where,
TRI_rc_context_t* context,
const TRI_voc_size_t skip,
const TRI_voc_ssize_t limit) {
TRI_join_part_t* part;
TRI_voc_size_t _skip;
TRI_voc_ssize_t _limit;
size_t i;
// set skip and limit to initial values
// (values will be decreased during join execution)
_skip = skip;
_limit = limit;
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
assert(part->_feeder);
part->_feeder->init(part->_feeder);
}
// execute the join
RecursiveJoinX(results, join, 0, where, context, &_skip, &_limit);
// deallocate vectors for list joins (would be done later anyway, but we can
// free the memory here already)
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part->_type == JOIN_TYPE_LIST) {
TRI_DestroyVectorPointer(&part->_listDocuments);
part->_listDocuments._buffer = NULL;
TRI_DestroyVectorPointer(&part->_extraData._listValues);
part->_extraData._listValues._buffer = NULL;
}
if (part->_feeder) {
// free data feeder early, we don't need it any longer
part->_feeder->free(part->_feeder);
part->_feeder = NULL;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Execute joins
////////////////////////////////////////////////////////////////////////////////

View File

@ -44,30 +44,12 @@ extern "C" {
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new select result from a join definition - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_select_result_t* TRI_JoinSelectResultX (const TRI_vocbase_t*,
TRI_select_join_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new select result from a join definition
////////////////////////////////////////////////////////////////////////////////
TRI_select_result_t* TRI_JoinSelectResult (TRI_query_instance_t* const);
////////////////////////////////////////////////////////////////////////////////
/// @brief Execute joins - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_ExecuteJoinsX (TRI_select_result_t*,
TRI_select_join_t*,
TRI_qry_where_t*,
TRI_rc_context_t*,
const TRI_voc_size_t,
const TRI_voc_ssize_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief Execute joins
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,173 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief joins
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2012, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "VocBase/query-join.h"
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief get size of extra data in standard join parts - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static size_t GetExtraDataSizeVoid (TRI_join_part_t* part) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get size of extra data in geo join parts - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static size_t GetExtraDataSizeGeo (TRI_join_part_t* part) {
return sizeof(double);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Free join part memory - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static void FreePart (TRI_join_part_t* part) {
if (part->_alias) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, part->_alias);
}
if (part->_ranges) {
// TODO: free ranges
}
if (part->_collectionName) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, part->_collectionName);
}
if (part->_feeder) {
part->_feeder->free(part->_feeder);
}
if (part->_context) {
TRI_FreeExecutionContext(part->_context);
}
if (part->_listDocuments._buffer) {
TRI_DestroyVectorPointer(&part->_listDocuments);
}
TRI_Free(TRI_UNKNOWN_MEM_ZONE, part);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Free join memory - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
static void FreeSelectJoin (TRI_select_join_t* join) {
TRI_join_part_t* part;
size_t i;
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
part->free(part);
}
TRI_DestroyVectorPointer(&join->_parts);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, join);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Add a part to a select join - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_AddPartSelectJoinX (TRI_select_join_t* join,
const TRI_join_type_e type,
TRI_vector_pointer_t* ranges,
char* collectionName,
char* alias,
QL_ast_query_geo_restriction_t* geoRestriction) {
TRI_join_part_t* part;
assert(join != NULL);
part = (TRI_join_part_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_join_part_t), false);
if (!part) {
return false;
}
// initialize vector for list joins
TRI_InitVectorPointer(&part->_listDocuments, TRI_UNKNOWN_MEM_ZONE);
part->_context = NULL;
part->_singleDocument = NULL;
part->_feeder = NULL;
part->_type = type;
part->_ranges = ranges;
part->_collection = NULL;
part->_collectionName = TRI_DuplicateString(collectionName);
part->_alias = TRI_DuplicateString(alias);
part->_geoRestriction = geoRestriction;
// determine size of extra data to store
if (part->_geoRestriction) {
part->_extraData._size = GetExtraDataSizeGeo(part);
part->_extraData._alias = part->_geoRestriction->_alias;
}
else {
part->_extraData._size = GetExtraDataSizeVoid(part);
part->_extraData._alias = NULL;
}
part->free = FreePart;
TRI_PushBackVectorPointer(&join->_parts, part);
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new join - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_select_join_t* TRI_CreateSelectJoin (void) {
TRI_select_join_t* join;
join = (TRI_select_join_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_select_join_t), false);
if (!join) {
return NULL;
}
TRI_InitVectorPointer(&join->_parts, TRI_UNKNOWN_MEM_ZONE);
join->free = FreeSelectJoin;
return join;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -97,36 +97,6 @@ typedef struct TRI_join_part_s {
}
TRI_join_part_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief join container data structure for select queries - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_select_join_s {
TRI_vector_pointer_t _parts;
TRI_vocbase_t* _vocbase;
void (*free) (struct TRI_select_join_s*);
}
TRI_select_join_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Add a part to a select join - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_AddPartSelectJoinX (TRI_select_join_t*,
const TRI_join_type_e,
TRI_vector_pointer_t*,
char*,
char*,
QL_ast_query_geo_restriction_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief Create a new join - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_select_join_t* TRI_CreateSelectJoin (void);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -292,49 +292,6 @@ static bool IncreaseDocumentsStorageSelectResult (TRI_select_result_t* result,
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the required storage size for a row result of a join - DEPRECATED
///
/// A result row of a join might contain data from multiple collections. Results
/// might also be single documents or multiple documents, depending on the join
/// type.
/// This function will calculate the total required size to store all documents
/// of all collections of the row result.
////////////////////////////////////////////////////////////////////////////////
static size_t GetJoinDocumentSizeX (const TRI_select_join_t* join) {
TRI_join_part_t* part;
size_t i, n, total;
total = 0;
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part->_type == JOIN_TYPE_LIST) {
n = part->_listDocuments._length;
// adjust for extra data
total += part->_extraData._size * n;
}
else {
n = 1;
}
// number of documents
total += sizeof(TRI_select_size_t);
// document pointers
total += (size_t) (sizeof(TRI_sr_documents_t) * n);
// adjust for extra data
if (part->_extraData._size) {
total += sizeof(TRI_select_size_t);
total += part->_extraData._size;
}
}
return total;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the required storage size for a row result of a join
///
@ -384,104 +341,6 @@ static size_t GetJoinDocumentSize (const TRI_query_instance_t* const instance) {
return total;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Add documents from a join to the result set - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_AddJoinSelectResultX (TRI_select_result_t* result, TRI_select_join_t* join) {
TRI_sr_index_t* indexPtr;
TRI_sr_documents_t* docPtr;
TRI_select_size_t* numPtr;
TRI_join_part_t* part;
TRI_doc_mptr_t* document;
size_t numNeeded;
size_t bytesNeeded;
size_t i, j;
// need space for one pointer
numNeeded = 1;
if (result->_index._numUsed + numNeeded > result->_index._numAllocated) {
if (!IncreaseIndexStorageSelectResult(result, numNeeded)) {
return false;
}
}
bytesNeeded = GetJoinDocumentSizeX(join);
if (result->_documents._bytesUsed + bytesNeeded > result->_documents._bytesAllocated) {
if (!IncreaseDocumentsStorageSelectResult(result, bytesNeeded)) {
return false;
}
}
// store pointer to document in index
docPtr = result->_documents._current;
indexPtr = (TRI_sr_index_t*) result->_index._current;
*indexPtr++ = (TRI_sr_index_t) docPtr;
result->_index._current = (TRI_sr_index_t*) indexPtr;
result->_index._numUsed++;
// store document data
numPtr = (TRI_select_size_t*) docPtr;
for (i = 0; i < join->_parts._length; i++) {
part = (TRI_join_part_t*) join->_parts._buffer[i];
if (part->_type == JOIN_TYPE_LIST) {
// multiple documents
*numPtr++ = part->_listDocuments._length;
docPtr = (TRI_sr_documents_t*) numPtr;
for (j = 0; j < part->_listDocuments._length; j++) {
document = (TRI_doc_mptr_t*) part->_listDocuments._buffer[j];
*docPtr++ = (TRI_sr_documents_t) document->_data;
}
if (part->_extraData._size) {
// copy extra data
assert(part->_listDocuments._length == part->_extraData._listValues._length);
numPtr = (TRI_select_size_t*) docPtr;
*numPtr++ = part->_listDocuments._length;
docPtr = (TRI_sr_documents_t*) numPtr;
for (j = 0; j < part->_extraData._listValues._length; j++) {
memcpy(docPtr, part->_extraData._listValues._buffer[j], part->_extraData._size);
docPtr = (TRI_sr_documents_t*) ((uint8_t*) docPtr + part->_extraData._size);
}
}
}
else {
// single document
*numPtr++ = 1;
docPtr = (TRI_sr_documents_t*) numPtr;
document = (TRI_doc_mptr_t*) part->_singleDocument;
if (document) {
*docPtr++ = (TRI_sr_documents_t) document->_data;
}
else {
// document is null
*docPtr++ = 0;
}
if (part->_extraData._size) {
// copy extra data
numPtr = (TRI_select_size_t*) docPtr;
*numPtr++ = 1;
docPtr = (TRI_sr_documents_t*) numPtr;
memcpy(docPtr, part->_extraData._singleValue, part->_extraData._size);
docPtr = (TRI_sr_documents_t*) ((uint8_t*) docPtr + part->_extraData._size);
}
}
numPtr = (TRI_select_size_t*) docPtr;
}
result->_documents._bytesUsed += bytesNeeded;
result->_documents._current = (TRI_sr_documents_t*) numPtr;
result->_numRows++;
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Add documents from a join to the result set
////////////////////////////////////////////////////////////////////////////////

View File

@ -148,12 +148,6 @@ typedef struct TRI_select_result_s {
}
TRI_select_result_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief Add documents from a join to the result set - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
bool TRI_AddJoinSelectResultX (TRI_select_result_t*, TRI_select_join_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief Add documents from a join to the result set
////////////////////////////////////////////////////////////////////////////////
@ -193,14 +187,10 @@ TRI_select_result_t* TRI_CreateSelectResult (TRI_vector_pointer_t*);
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_rc_result_s {
TRI_rc_context_t* _context; // TODO: REMOVE
TRI_js_exec_context_t* _orderContext;
TRI_doc_mptr_t* _primary; // TODO: REMOVE
TRI_select_result_t* _selectResult;
TRI_sr_documents_t* _dataPtr;
TRI_json_t _augmention; // TODO: REMOVE
}
TRI_rc_result_t;

View File

@ -1,207 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief where conditions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Jan Steemann
/// @author Copyright 2012, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_DURHAM_VOC_BASE_WHERE_H
#define TRIAGENS_DURHAM_VOC_BASE_WHERE_H 1
#include "VocBase/vocbase.h"
#include "VocBase/document-collection.h"
#include "VocBase/index.h"
#include "VocBase/query-context.h"
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief where clause type
////////////////////////////////////////////////////////////////////////////////
typedef enum {
TRI_QRY_WHERE_BOOLEAN,
TRI_QRY_WHERE_GENERAL,
TRI_QRY_WHERE_HASH_CONSTANT,
TRI_QRY_WHERE_PRIORITY_QUEUE_CONSTANT,
TRI_QRY_WHERE_SKIPLIST_CONSTANT,
TRI_QRY_WHERE_WITHIN_CONSTANT,
TRI_QRY_WHERE_PRIMARY_CONSTANT
}
TRI_qry_where_type_e;
////////////////////////////////////////////////////////////////////////////////
/// @brief abstract where clause
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_s {
TRI_qry_where_type_e _type;
struct TRI_qry_where_s* (*clone) (struct TRI_qry_where_s const*);
void (*free) (struct TRI_qry_where_s*);
}
TRI_qry_where_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief abstract where clause for conditions
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_cond_s {
TRI_qry_where_t base;
}
TRI_qry_where_cond_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief constant where clause
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_boolean_s {
TRI_qry_where_cond_t base;
bool _value;
}
TRI_qry_where_boolean_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript where clause
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_general_s {
TRI_qry_where_cond_t base;
char* _code;
}
TRI_qry_where_general_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief abstract primary index where clause
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_primary_s {
TRI_qry_where_t base;
TRI_voc_did_t (*did) (struct TRI_qry_where_primary_s*, TRI_rc_context_t*);
}
TRI_qry_where_primary_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief primary index where clause with a constant document identifier
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_primary_const_s {
TRI_qry_where_primary_t base;
TRI_voc_did_t _did;
}
TRI_qry_where_primary_const_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief geo index where clause
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_within_s {
TRI_qry_where_t base;
TRI_idx_iid_t _iid;
char* _nameDistance;
double* (*coordinates) (struct TRI_qry_where_within_s*, TRI_rc_context_t*);
double (*radius) (struct TRI_qry_where_within_s*, TRI_rc_context_t*);
}
TRI_qry_where_within_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief geo index where clause with a constant document identifier
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_within_const_s {
TRI_qry_where_within_t base;
double _coordinates[2];
double _radius;
}
TRI_qry_where_within_const_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief hash index where
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_hash_const_s {
TRI_qry_where_t base;
TRI_idx_iid_t _iid;
TRI_json_t* _parameters; // a json list object
}
TRI_qry_where_hash_const_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief skiplist index where
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_priorityqueue_const_s {
TRI_qry_where_t base;
TRI_idx_iid_t _iid;
TRI_json_t* _parameters;
}
TRI_qry_where_priorityqueue_const_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief skiplist index where
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_where_skiplist_const_s {
TRI_qry_where_t base;
TRI_idx_iid_t _iid;
//TRI_json_t* _parameters;
// simple operator
TRI_sl_operator_t* _operator;
}
TRI_qry_where_skiplist_const_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

File diff suppressed because it is too large Load Diff

View File

@ -1,438 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief query
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_DURHAM_VOC_BASE_QUERY_H
#define TRIAGENS_DURHAM_VOC_BASE_QUERY_H 1
#include "VocBase/vocbase.h"
#include "ShapedJson/shaped-json.h"
#include "VocBase/document-collection.h"
#include "VocBase/index.h"
#include "VocBase/query-join.h"
#include "VocBase/query-where.h"
#include "VocBase/query-order.h"
#include "VocBase/query-cursor.h"
#include "VocBase/query-base.h"
#include "SkipLists/sl-operator.h"
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////////////
/// @page BuildExecuteQuery Building and Executing a Query
///
/// @section LifeCycleQuery Life-Cycle of a Query
///
/// The query life-cycle starts with a string describing the query in the
/// Avocado query language. For example:
///
/// @verbinclude query1
///
/// In order to get the result the following steps are taken.
///
/// - the query is parsed
/// - an @CODE{TRI_query_t} representation is constructed
///
/// Later the query is executed:
///
/// - an @CODE{TRI_rc_context_t} is created
/// - the query is executed in this context
/// - a @CODE{TRI_rc_cursor_t} is returned
///
/// Later the result are accessed:
///
/// - the @CODE{next} method returns a @CODE{TRI_rc_result_t}
/// - which can be convert into a JSON or JavaScript object using
/// the @CODE{TRI_qry_select_t}
///
/// @section QueryRepresentation Query Representation
///
/// @copydetails TRI_query_t
///
/// @subsection QueryRepresentationSelect Query Select Representation
///
/// @copydetails TRI_qry_select_t
///
/// @section QueryExecution Query Execution
///
/// @subsection QueryContext Query Execution Context
///
/// @copydetails TRI_rc_context_t
///
/// @subsection ResultCursor Result Cursor
///
/// @copydetails TRI_rc_cursor_t
///
/// @subsection QueryResult Building the Query Result
///
/// @copydetails TRI_rc_result_t
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief select clause type - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
typedef enum {
TRI_QRY_SELECT_DOCUMENT,
TRI_QRY_SELECT_GENERAL
}
TRI_qry_select_type_e;
////////////////////////////////////////////////////////////////////////////////
/// @brief abstract select clause - DEPRECATED
///
/// A description of the @CODE{select} statement of the Avocado query language.
/// This class is respsonible for taking an element of type
/// @CODE{TRI_rc_result_t} as returned by the cursor and transforming it into
/// either a shaped json object of type @CODE{TRI_shaped_json_t} or a JavaScript
/// object of type @CODE{v8::Value}. The returned objects are either freed when
/// the @CODE{TRI_rc_result_t} is deleted or are garbage collected in case of
/// JavaScript.
///
/// The following implementations exist.
///
/// @copydetails TRI_qry_select_direct_t
///
/// @copydetails TRI_qry_select_general_t
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_select_s {
TRI_qry_select_type_e _type;
struct TRI_qry_select_s* (*clone) (struct TRI_qry_select_s const*);
void (*free) (struct TRI_qry_select_s*);
TRI_shaped_json_t* (*shapedJson) (struct TRI_qry_select_s*, TRI_rc_result_t*);
bool (*toJavaScript) (struct TRI_qry_select_s*, TRI_rc_result_t*, void*);
}
TRI_qry_select_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief built-in select clause for a single, unaltered document - DEPRECATED
///
/// If a query returns a document unaltered, then @CODE{TRI_qry_select_direct_t}
/// can be used. It extracts a given document from the result set and returns
/// this document without any modification. The member @CODE{_variable} contains
/// the variable identifier of the result document of the next result to use.
///
/// For example
///
/// @verbinclude query2
///
/// will generate a query whose select part consists of an instance of
/// @CODE{TRI_qry_select_direct_t}.
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_select_direct_s {
TRI_qry_select_t base;
}
TRI_qry_select_direct_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript select clause - DEPRECATED
///
/// If a query returns a newly created document, then
/// @CODE{TRI_qry_select_general_t} can be used. It uses the V8 engine to
/// compute the document. The member @CODE{_code} contains the JavaScript code
/// used to generate the document. When this code is executed, then the result
/// documents of the next result are passed into the JavaScript code bound to
/// variables.
///
/// For example
///
/// @verbinclude query3
///
/// will generate new documents containing only @LIT{name} and @LIT{email}.
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_qry_select_general_s {
TRI_qry_select_t base;
char* _code;
}
TRI_qry_select_general_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief general query - DEPRECATED
///
/// A query is built using the fluent-interface or the Avocado Query
/// Language. It is of type @CODE{TRI_query_t}. After the query is built, it can
/// be executed. An execution returns a result cursor of type
/// @CODE{TRI_rc_cursor_t}. An execution requires a context of type
/// @CODE{TRI_rc_context_t}. All result are only vaild for the life-time of this
/// context.
///
/// It is possible to execute the same query multiple times - even in
/// parallel. However, each execution run requires it's own context.
///
/// A query contains the following parts:
///
/// - a description of the result in @CODE{_select}
/// - the primary collection for the query in @CODE{_primary}
/// - a list of joins in @CODE{_joins}
/// - a description of the where clause in @CODE{_where}
/// - an optional order by clause in @CODE{_order}
/// - a number limiting the number of returned documents in @CODE{_limit}
/// - a number of documents to skip in @CODE{_skip}
///
/// The @CODE{_select} is of type @CODE{TRI_qry_select_t}. This is in general a
/// representation of the part following the @CODE{select} statement. There are
/// at least two implementions. The first one uses a built-in evaluator to
/// generate the result document from the next set of selected documents. The
/// second one uses the V8 engine to generate the result.
///
/// The @CODE{_primary} is of type @CODE{TRI_doc_collection_t}. This is the
/// collection following the @CODE{from} statement. The Avocado query language
/// only supports one collection after the @CODE{from}, this is the primary
/// collection of the query. All other collections must be joined with this
/// primary collection.
///
/// The @CODE{_joins} attributes contains a vector of joined collections
/// together with the join condition. The vector elements are of type
/// @CODE{TRI_qry_join_t}.
///
/// The @CODE{_where} attributes contains a description of the where
/// clause. There are at least two implementations. The first one uses a
/// built-in evaluator to evaluate the predicate. The second one uses the V8
/// engine.
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_query_s {
TRI_vocbase_t* _vocbase;
TRI_qry_select_t* _select;
TRI_doc_collection_t* _primary;
TRI_qry_where_t* _where;
TRI_select_join_t* _joins;
TRI_voc_size_t _skip;
TRI_voc_ssize_t _limit;
}
TRI_query_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief the result cursor - DEPRECATED
///
/// The result of a query execution. The metod @FN{next} returns the next
/// result documents. There is one document for the primary collection and a
/// list of documents for a list join. The next result documents are delivered
/// as instance of @CODE{TRI_rc_result_t}. You must call the @FN{free} method
/// for these instances.
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_rc_cursor_s {
TRI_rc_context_t* _context;
TRI_qry_select_t* _select;
TRI_select_result_t* _selectResult;
TRI_js_exec_context_t* _selectContext;
TRI_vector_pointer_t _containers;
TRI_voc_size_t _scannedIndexEntries;
TRI_voc_size_t _scannedDocuments;
TRI_voc_size_t _matchedDocuments;
void (*free) (struct TRI_rc_cursor_s*);
TRI_rc_result_t* (*next)(struct TRI_rc_cursor_s*);
bool (*hasNext)(struct TRI_rc_cursor_s*);
}
TRI_rc_cursor_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_query_t* TRI_CreateHashQuery (const TRI_qry_where_t*, TRI_doc_collection_t*);
TRI_query_t* TRI_CreatePriorityQueueQuery (const TRI_qry_where_t*, TRI_doc_collection_t*);
TRI_query_t* TRI_CreateSkiplistQuery (const TRI_qry_where_t*, TRI_doc_collection_t*);
TRI_query_t* TRI_CreateQuery (TRI_vocbase_t*,
TRI_qry_select_t*,
TRI_qry_where_t*,
TRI_select_join_t*,
TRI_voc_size_t,
TRI_voc_ssize_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief frees a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeQuery (TRI_query_t* query);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a context - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_rc_context_t* TRI_CreateContextQuery (TRI_query_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief frees a context - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeContextQuery (TRI_rc_context_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query selection for unaltered documents - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_select_t* TRI_CreateQuerySelectDocument (void);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query selection for general, generated documents - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_select_t* TRI_CreateQuerySelectGeneral (char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition for constant conditions - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWhereBoolean (bool where);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition for general, JavaScript conditions - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWhereGeneral (char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition for a hash with constant parameters - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWhereHashConstant (TRI_idx_iid_t, TRI_json_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition for a priority queue with constant parameters - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWherePQConstant (TRI_idx_iid_t, TRI_json_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition for a hash with constant parameters - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWhereSkiplistConstant (TRI_idx_iid_t, TRI_sl_operator_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition using the primary index and a constant - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWherePrimaryConstant (TRI_voc_did_t did);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a query condition using an geo index and a constants - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_qry_where_t* TRI_CreateQueryWhereWithinConstant (TRI_idx_iid_t iid,
char const* nameDistance,
double latitiude,
double longitude,
double radius);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief read locks all collections of a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_ReadLockCollectionsQuery (TRI_query_t* query);
////////////////////////////////////////////////////////////////////////////////
/// @brief read unlocks all collections of a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
void TRI_ReadUnlockCollectionsQuery (TRI_query_t* query);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds a gc marker for all collections
////////////////////////////////////////////////////////////////////////////////
void TRI_AddCollectionsCursor (TRI_rc_cursor_t* cursor, TRI_query_t* query);
////////////////////////////////////////////////////////////////////////////////
/// @brief read unlocks all collections of a query
////////////////////////////////////////////////////////////////////////////////
void TRI_RemoveCollectionsCursor (TRI_rc_cursor_t* cursor);
////////////////////////////////////////////////////////////////////////////////
/// @brief executes a query - DEPRECATED
////////////////////////////////////////////////////////////////////////////////
TRI_rc_cursor_t* TRI_ExecuteQueryAql (TRI_query_t*, TRI_rc_context_t*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End: