1
0
Fork 0

Merge branch 'mjmh' of https://github.com/triAGENS/ArangoDB into mjmh

This commit is contained in:
Jan Steemann 2014-06-10 15:06:04 +02:00
commit 43600f712f
3 changed files with 14 additions and 14 deletions

View File

@ -1880,16 +1880,22 @@ static v8::Handle<v8::Value> JS_ByExampleQuery (v8::Arguments const& argv) {
v8::Handle<v8::Array> documents = v8::Array::New();
result->Set(v8::String::New("documents"), documents);
// .............................................................................
// ...........................................................................
// inside a read transaction
// .............................................................................
// ...........................................................................
trx.lockRead();
// find documents by example
vector<TRI_doc_mptr_t*> filtered
vector<TRI_doc_mptr_copy_t> filtered
= TRI_SelectByExample(trx.trxCollection(), n, pids, values);
trx.finish(res);
// ...........................................................................
// outside a read transaction
// ...........................................................................
// convert to list of shaped jsons
size_t total = filtered.size();
size_t count = 0;
@ -1903,7 +1909,7 @@ static v8::Handle<v8::Value> JS_ByExampleQuery (v8::Arguments const& argv) {
if (s < e) {
for (size_t j = s; j < e; ++j) {
TRI_doc_mptr_t* mptr = filtered[j];
TRI_doc_mptr_copy_t* mptr = &filtered[j];
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, mptr);
@ -1918,12 +1924,6 @@ static v8::Handle<v8::Value> JS_ByExampleQuery (v8::Arguments const& argv) {
}
}
trx.finish(res);
// .............................................................................
// outside a write transaction
// .............................................................................
result->Set(v8::String::New("total"), v8::Integer::New((int32_t) total));
result->Set(v8::String::New("count"), v8::Integer::New((int32_t) count));

View File

@ -5483,7 +5483,7 @@ static bool IsExampleMatch (TRI_transaction_collection_t*,
////////////////////////////////////////////////////////////////////////////////
std::vector<TRI_doc_mptr_t*> TRI_SelectByExample (
std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (
TRI_transaction_collection_t* trxCollection,
size_t length,
TRI_shape_pid_t* pids,
@ -5494,7 +5494,7 @@ std::vector<TRI_doc_mptr_t*> TRI_SelectByExample (
TRI_shaper_t* shaper = document->_shaper;
// use filtered to hold copies of the master pointer
std::vector<TRI_doc_mptr_t*> filtered;
std::vector<TRI_doc_mptr_copy_t> filtered;
// do a full scan
TRI_doc_mptr_t** ptr = (TRI_doc_mptr_t**) (document->_primaryIndex._table);
@ -5502,7 +5502,7 @@ std::vector<TRI_doc_mptr_t*> TRI_SelectByExample (
for (; ptr < end; ++ptr) {
if (*ptr != nullptr && IsExampleMatch(trxCollection, shaper, *ptr, length, pids, values)) {
filtered.push_back(*ptr);
filtered.push_back(**ptr);
}
}
return filtered;

View File

@ -986,7 +986,7 @@ struct TRI_index_s* TRI_EnsureFulltextIndexDocumentCollection (TRI_document_coll
/// @brief executes a select-by-example query
////////////////////////////////////////////////////////////////////////////////
std::vector<TRI_doc_mptr_t*> TRI_SelectByExample (
std::vector<TRI_doc_mptr_copy_t> TRI_SelectByExample (
struct TRI_transaction_collection_s*,
size_t,
TRI_shape_pid_t*,