mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'aql2' of ssh://github.com/triAGENS/ArangoDB into aql2
This commit is contained in:
commit
135cce3250
|
@ -1103,7 +1103,7 @@ static v8::Handle<v8::Value> ExecuteSkiplistQuery (v8::Arguments const& argv,
|
|||
while (limit > 0) {
|
||||
TRI_skiplist_index_element_t* indexElement = skiplistIterator->_next(skiplistIterator);
|
||||
|
||||
if (indexElement == NULL) {
|
||||
if (indexElement == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1112,7 +1112,7 @@ static v8::Handle<v8::Value> ExecuteSkiplistQuery (v8::Arguments const& argv,
|
|||
if (total > skip && count < limit) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx,
|
||||
col->_cid,
|
||||
(TRI_doc_mptr_t const*) indexElement->_document);
|
||||
((TRI_doc_mptr_t const*) indexElement->_document)->getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -1306,18 +1306,18 @@ static v8::Handle<v8::Value> ExecuteBitarrayQuery (v8::Arguments const& argv,
|
|||
TRI_voc_size_t count = 0;
|
||||
bool error = false;
|
||||
|
||||
if (indexIterator != NULL) {
|
||||
if (indexIterator != nullptr) {
|
||||
while (limit > 0) {
|
||||
TRI_doc_mptr_t* data = (TRI_doc_mptr_t*) indexIterator->_next(indexIterator);
|
||||
|
||||
if (data == NULL) {
|
||||
if (data == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
++total;
|
||||
|
||||
if (total > skip && count < limit) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, data);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, data->getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -1418,7 +1418,7 @@ static int StoreGeoResult (V8ReadTransaction& trx,
|
|||
// copy the documents
|
||||
bool error = false;
|
||||
for (gtr = tmp, i = 0; gtr < gnd; ++gtr, ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, (TRI_doc_mptr_t const*) gtr->_data);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, ((TRI_doc_mptr_t const*) gtr->_data)->getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -1533,7 +1533,7 @@ static v8::Handle<v8::Value> EdgesQuery (TRI_edge_direction_e direction,
|
|||
}
|
||||
|
||||
for (size_t j = 0; j < edges.size(); ++j) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &edges[j]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, edges[j].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
// error
|
||||
|
@ -1576,7 +1576,7 @@ static v8::Handle<v8::Value> EdgesQuery (TRI_edge_direction_e direction,
|
|||
}
|
||||
|
||||
for (size_t j = 0; j < edges.size(); ++j) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &edges[j]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, edges[j].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -1660,7 +1660,7 @@ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
|
|||
result->Set(v8::String::New("documents"), documents);
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &docs[i]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, docs[i].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
|
@ -1736,7 +1736,7 @@ static v8::Handle<v8::Value> JS_OffsetQuery (v8::Arguments const& argv) {
|
|||
result->Set(v8::String::New("documents"), documents);
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
v8::Handle<v8::Value> document = WRAP_SHAPED_JSON(trx, col->_cid, &docs[i]);
|
||||
v8::Handle<v8::Value> document = WRAP_SHAPED_JSON(trx, col->_cid, docs[i].getDataPtr());
|
||||
|
||||
if (document.IsEmpty()) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
|
@ -1802,7 +1802,7 @@ static v8::Handle<v8::Value> JS_AnyQuery (v8::Arguments const& argv) {
|
|||
return scope.Close(v8::Null());
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &document);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, document.getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
|
@ -1917,9 +1917,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_copy_t* mptr = &filtered[j];
|
||||
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, mptr);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, filtered[j].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -2030,7 +2028,7 @@ static v8::Handle<v8::Value> ByExampleHashIndexQuery (V8ReadTransaction& trx,
|
|||
|
||||
if (s < e) {
|
||||
for (size_t i = s; i < e; ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, list._documents[i]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, list._documents[i]->getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -2434,7 +2432,7 @@ static v8::Handle<v8::Value> JS_FirstQuery (v8::Arguments const& argv) {
|
|||
uint32_t j = 0;
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &documents[i]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, documents[i].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
// error
|
||||
|
@ -2451,7 +2449,7 @@ static v8::Handle<v8::Value> JS_FirstQuery (v8::Arguments const& argv) {
|
|||
return scope.Close(v8::Null());
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> result = WRAP_SHAPED_JSON(trx, col->_cid, &documents[0]);
|
||||
v8::Handle<v8::Value> result = WRAP_SHAPED_JSON(trx, col->_cid, documents[0].getDataPtr());
|
||||
|
||||
if (result.IsEmpty()) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
|
@ -2533,7 +2531,7 @@ static v8::Handle<v8::Value> FulltextQuery (V8ReadTransaction& trx,
|
|||
bool error = false;
|
||||
|
||||
for (uint32_t i = 0; i < queryResult->_numDocuments; ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, (TRI_doc_mptr_t const*) queryResult->_documents[i]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, collection->_cid, ((TRI_doc_mptr_t const*) queryResult->_documents[i])->getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
error = true;
|
||||
|
@ -2671,7 +2669,7 @@ static v8::Handle<v8::Value> JS_LastQuery (v8::Arguments const& argv) {
|
|||
uint32_t j = 0;
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, &documents[i]);
|
||||
v8::Handle<v8::Value> doc = WRAP_SHAPED_JSON(trx, col->_cid, documents[i].getDataPtr());
|
||||
|
||||
if (doc.IsEmpty()) {
|
||||
// error
|
||||
|
@ -2688,7 +2686,7 @@ static v8::Handle<v8::Value> JS_LastQuery (v8::Arguments const& argv) {
|
|||
return scope.Close(v8::Null());
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> result = WRAP_SHAPED_JSON(trx, col->_cid, &documents[0]);
|
||||
v8::Handle<v8::Value> result = WRAP_SHAPED_JSON(trx, col->_cid, documents[0].getDataPtr());
|
||||
|
||||
if (result.IsEmpty()) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
|
|
|
@ -1993,7 +1993,7 @@ static v8::Handle<v8::Value> DocumentVocbaseCol (bool useCollection,
|
|||
TRI_ASSERT(trx.hasBarrier());
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
result = TRI_WrapShapedJson<V8ReadTransaction>(trx, col->_cid, &document);
|
||||
result = TRI_WrapShapedJson<V8ReadTransaction>(trx, col->_cid, document.getDataPtr());
|
||||
}
|
||||
|
||||
FREE_STRING(TRI_CORE_MEM_ZONE, key);
|
||||
|
@ -10329,15 +10329,14 @@ template<class T>
|
|||
static v8::Handle<v8::Object> AddBasicDocumentAttributes (T& trx,
|
||||
TRI_v8_global_t* v8g,
|
||||
TRI_voc_cid_t cid,
|
||||
TRI_doc_mptr_t const* mptr,
|
||||
TRI_df_marker_t const* marker,
|
||||
v8::Handle<v8::Object> result) {
|
||||
v8::HandleScope scope;
|
||||
TRI_ASSERT(marker != nullptr);
|
||||
|
||||
TRI_ASSERT(mptr != nullptr);
|
||||
|
||||
TRI_voc_rid_t rid = mptr->_rid;
|
||||
char const* docKey = TRI_EXTRACT_MARKER_KEY(mptr); // PROTECTED by trx from above
|
||||
TRI_voc_rid_t rid = TRI_EXTRACT_MARKER_RID(marker);
|
||||
TRI_ASSERT(rid > 0);
|
||||
|
||||
char const* docKey = TRI_EXTRACT_MARKER_KEY(marker);
|
||||
TRI_ASSERT(docKey != nullptr);
|
||||
|
||||
CollectionNameResolver const* resolver = trx.resolver();
|
||||
|
@ -10345,22 +10344,23 @@ static v8::Handle<v8::Object> AddBasicDocumentAttributes (T& trx,
|
|||
result->Set(v8g->_RevKey, V8RevisionId(rid), v8::ReadOnly);
|
||||
result->Set(v8g->_KeyKey, v8::String::New(docKey), v8::ReadOnly);
|
||||
|
||||
TRI_df_marker_type_t type = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr())->_type; // PROTECTED by trx from above
|
||||
TRI_df_marker_type_t type = marker->_type;
|
||||
char const* base = reinterpret_cast<char const*>(marker);
|
||||
|
||||
if (type == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
TRI_doc_edge_key_marker_t const* marker = static_cast<TRI_doc_edge_key_marker_t const*>(mptr->getDataPtr()); // PROTECTED by trx from above
|
||||
TRI_doc_edge_key_marker_t const* m = reinterpret_cast<TRI_doc_edge_key_marker_t const*>(marker);
|
||||
|
||||
result->Set(v8g->_FromKey, V8DocumentId(resolver->getCollectionNameCluster(marker->_fromCid), ((char*) marker) + marker->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(resolver->getCollectionNameCluster(marker->_toCid), ((char*) marker) + marker->_offsetToKey));
|
||||
result->Set(v8g->_FromKey, V8DocumentId(resolver->getCollectionNameCluster(m->_fromCid), base + m->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(resolver->getCollectionNameCluster(m->_toCid), base + m->_offsetToKey));
|
||||
}
|
||||
else if (type == TRI_WAL_MARKER_EDGE) {
|
||||
triagens::wal::edge_marker_t const* marker = static_cast<triagens::wal::edge_marker_t const*>(mptr->getDataPtr()); // PROTECTED by trx from above
|
||||
triagens::wal::edge_marker_t const* m = reinterpret_cast<triagens::wal::edge_marker_t const*>(marker);
|
||||
|
||||
result->Set(v8g->_FromKey, V8DocumentId(resolver->getCollectionNameCluster(marker->_fromCid), ((char const*) marker) + marker->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(resolver->getCollectionNameCluster(marker->_toCid), ((char const*) marker) + marker->_offsetToKey));
|
||||
result->Set(v8g->_FromKey, V8DocumentId(resolver->getCollectionNameCluster(m->_fromCid), base + m->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(resolver->getCollectionNameCluster(m->_toCid), base + m->_offsetToKey));
|
||||
}
|
||||
|
||||
return scope.Close(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -10370,22 +10370,9 @@ static v8::Handle<v8::Object> AddBasicDocumentAttributes (T& trx,
|
|||
template<class T>
|
||||
v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
||||
TRI_voc_cid_t cid,
|
||||
TRI_df_marker_t const* marker) {
|
||||
// TODO: implement!
|
||||
return v8::Object::New();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief wraps a TRI_shaped_json_t
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
||||
TRI_voc_cid_t cid,
|
||||
TRI_doc_mptr_t const* document) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
void const* data) {
|
||||
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(data);
|
||||
TRI_ASSERT(marker != nullptr);
|
||||
|
||||
TRI_barrier_t* barrier = trx.barrier();
|
||||
TRI_ASSERT(barrier != nullptr);
|
||||
|
@ -10393,9 +10380,6 @@ v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
|||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
TRI_v8_global_t* v8g = static_cast<TRI_v8_global_t*>(isolate->GetData());
|
||||
|
||||
void const* marker = document->getDataPtr();
|
||||
TRI_ASSERT(marker != nullptr); // PROTECTED by trx from above
|
||||
|
||||
bool const doCopy = TRI_IsWalDataMarkerDatafile(marker);
|
||||
|
||||
if (doCopy) {
|
||||
|
@ -10409,27 +10393,13 @@ v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
|||
TRI_shape_t const* shape = shaper->lookupShapeId(shaper, json._sid);
|
||||
|
||||
if (shape == nullptr) {
|
||||
return scope.Close(v8::Object::New());
|
||||
return v8::Object::New();
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> result = v8::Object::New();
|
||||
result = AddBasicDocumentAttributes<T>(trx, v8g, cid, document, result);
|
||||
result = AddBasicDocumentAttributes<T>(trx, v8g, cid, marker, result);
|
||||
|
||||
v8::Handle<v8::Value> shaped = TRI_JsonShapeData(shaper, shape, json._data.data, json._data.length);
|
||||
|
||||
if (! shaped.IsEmpty()) {
|
||||
// now copy the shaped json attributes into the result
|
||||
// this is done to ensure proper order (_key, _id, _rev etc. come first)
|
||||
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(shaped);
|
||||
v8::Handle<v8::Array> names = array->GetOwnPropertyNames();
|
||||
uint32_t const n = names->Length();
|
||||
for (uint32_t j = 0; j < n; ++j) {
|
||||
v8::Handle<v8::Value> key = names->Get(j);
|
||||
result->Set(key, array->Get(key));
|
||||
}
|
||||
}
|
||||
|
||||
return scope.Close(result);
|
||||
return TRI_JsonShapeData(result, shaper, shape, json._data.data, json._data.length);
|
||||
}
|
||||
|
||||
// we'll create a document stub, with a pointer into the datafile
|
||||
|
@ -10439,14 +10409,12 @@ v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
|||
|
||||
if (result.IsEmpty()) {
|
||||
// error
|
||||
return scope.Close(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void* data = const_cast<void*>(marker); // PROTECTED by trx from above
|
||||
|
||||
// point the 0 index Field to the c++ pointer for unwrapping later
|
||||
result->SetInternalField(SLOT_CLASS_TYPE, v8::Integer::New(WRP_SHAPED_JSON_TYPE));
|
||||
result->SetInternalField(SLOT_CLASS, v8::External::New(data));
|
||||
result->SetInternalField(SLOT_CLASS, v8::External::New((void*) marker));
|
||||
|
||||
// tell everyone else that this barrier is used by an external
|
||||
reinterpret_cast<TRI_barrier_blocker_t*>(barrier)->_usedByExternal = true;
|
||||
|
@ -10469,7 +10437,7 @@ v8::Handle<v8::Value> TRI_WrapShapedJson (T& trx,
|
|||
result->SetInternalField(SLOT_BARRIER, i->second);
|
||||
}
|
||||
|
||||
return scope.Close(AddBasicDocumentAttributes<T>(trx, v8g, cid, document, result));
|
||||
return AddBasicDocumentAttributes<T>(trx, v8g, cid, marker, result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -76,16 +76,7 @@ TRI_index_t* TRI_LookupIndexByHandle (triagens::arango::CollectionNameResolver c
|
|||
template<class T>
|
||||
v8::Handle<v8::Value> TRI_WrapShapedJson (T&,
|
||||
TRI_voc_cid_t,
|
||||
TRI_df_marker_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief wraps a TRI_shaped_json_t
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
v8::Handle<v8::Value> TRI_WrapShapedJson (T&,
|
||||
TRI_voc_cid_t,
|
||||
TRI_doc_mptr_t const*);
|
||||
void const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the private WRP_VOCBASE_COL_TYPE value
|
||||
|
|
|
@ -554,20 +554,7 @@ static inline char const* TRI_EXTRACT_MARKER_KEY (TRI_df_marker_t const* marker)
|
|||
|
||||
static inline char const* TRI_EXTRACT_MARKER_KEY (TRI_doc_mptr_t const* mptr) {
|
||||
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr()); // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
|
||||
if (marker->_type == TRI_DOC_MARKER_KEY_DOCUMENT || marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
return ((char const*) mptr->getDataPtr()) + ((TRI_doc_document_key_marker_t const*) mptr->getDataPtr())->_offsetKey; // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
}
|
||||
else if (marker->_type == TRI_WAL_MARKER_DOCUMENT || marker->_type == TRI_WAL_MARKER_EDGE) {
|
||||
return ((char const*) mptr->getDataPtr()) + ((triagens::wal::document_marker_t const*) mptr->getDataPtr())->_offsetKey; // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// invalid marker type
|
||||
TRI_ASSERT(false);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
return TRI_EXTRACT_MARKER_KEY(marker);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -576,20 +563,7 @@ static inline char const* TRI_EXTRACT_MARKER_KEY (TRI_doc_mptr_t const* mptr) {
|
|||
|
||||
static inline char const* TRI_EXTRACT_MARKER_KEY (TRI_doc_mptr_copy_t const* mptr) {
|
||||
TRI_df_marker_t const* marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr()); // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
|
||||
if (marker->_type == TRI_DOC_MARKER_KEY_DOCUMENT || marker->_type == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
return ((char const*) mptr->getDataPtr()) + ((TRI_doc_document_key_marker_t const*) mptr->getDataPtr())->_offsetKey; // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
}
|
||||
else if (marker->_type == TRI_WAL_MARKER_DOCUMENT || marker->_type == TRI_WAL_MARKER_EDGE) {
|
||||
return ((char const*) mptr->getDataPtr()) + ((triagens::wal::document_marker_t const*) mptr->getDataPtr())->_offsetKey; // PROTECTED by TRI_EXTRACT_MARKER_KEY search
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// invalid marker type
|
||||
TRI_ASSERT(false);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
return TRI_EXTRACT_MARKER_KEY(marker);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -55,10 +55,16 @@ static int FillShapeValueJson (TRI_shaper_t* shaper,
|
|||
vector< v8::Handle<v8::Object> >& seenObjects,
|
||||
bool create);
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeData (TRI_shaper_t* shaper,
|
||||
TRI_shape_t const* shape,
|
||||
char const* data,
|
||||
size_t size);
|
||||
static v8::Handle<v8::Value> JsonShapeData (v8::Handle<v8::Value>&,
|
||||
TRI_shaper_t*,
|
||||
TRI_shape_t const*,
|
||||
char const*,
|
||||
size_t);
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeData (TRI_shaper_t*,
|
||||
TRI_shape_t const*,
|
||||
char const*,
|
||||
size_t);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private types
|
||||
|
@ -972,7 +978,114 @@ static v8::Handle<v8::Value> JsonShapeDataLongString (TRI_shaper_t* shaper,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a data array blob into a json object
|
||||
/// @brief merges a data array blob into an existing json object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeDataArray (v8::Handle<v8::Value>& value,
|
||||
TRI_shaper_t* shaper,
|
||||
TRI_shape_t const* shape,
|
||||
char const* data,
|
||||
size_t size) {
|
||||
TRI_array_shape_t const* s;
|
||||
TRI_shape_aid_t const* aids;
|
||||
TRI_shape_sid_t const* sids;
|
||||
TRI_shape_size_t const* offsetsF;
|
||||
TRI_shape_size_t const* offsetsV;
|
||||
TRI_shape_size_t f;
|
||||
TRI_shape_size_t i;
|
||||
TRI_shape_size_t n;
|
||||
TRI_shape_size_t v;
|
||||
shape_cache_t shapeCache;
|
||||
char const* qtr;
|
||||
|
||||
v8::Handle<v8::Object> array = v8::Handle<v8::Object>::Cast(value);
|
||||
|
||||
s = (TRI_array_shape_t const*) shape;
|
||||
f = s->_fixedEntries;
|
||||
v = s->_variableEntries;
|
||||
n = f + v;
|
||||
|
||||
qtr = (char const*) shape;
|
||||
|
||||
qtr += sizeof(TRI_array_shape_t);
|
||||
|
||||
sids = (TRI_shape_sid_t const*) qtr;
|
||||
qtr += n * sizeof(TRI_shape_sid_t);
|
||||
|
||||
aids = (TRI_shape_aid_t const*) qtr;
|
||||
qtr += n * sizeof(TRI_shape_aid_t);
|
||||
|
||||
offsetsF = (TRI_shape_size_t const*) qtr;
|
||||
shapeCache._sid = 0;
|
||||
shapeCache._shape = 0;
|
||||
|
||||
for (i = 0; i < f; ++i, ++sids, ++aids, ++offsetsF) {
|
||||
TRI_shape_sid_t sid = *sids;
|
||||
|
||||
TRI_shape_t const* subshape;
|
||||
if (sid == shapeCache._sid && shapeCache._sid > 0) {
|
||||
subshape = shapeCache._shape;
|
||||
}
|
||||
else {
|
||||
shapeCache._shape = subshape = shaper->lookupShapeId(shaper, sid);
|
||||
shapeCache._sid = sid;
|
||||
}
|
||||
|
||||
if (subshape == 0) {
|
||||
LOG_WARNING("cannot find shape #%u", (unsigned int) sid);
|
||||
continue;
|
||||
}
|
||||
|
||||
TRI_shape_aid_t aid = *aids;
|
||||
char const* name = shaper->lookupAttributeId(shaper, aid);
|
||||
|
||||
if (name == 0) {
|
||||
LOG_WARNING("cannot find attribute #%u", (unsigned int) aid);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TRI_shape_size_t offset = *offsetsF;
|
||||
v8::Handle<v8::Value> element = JsonShapeData(shaper, subshape, data + offset, offsetsF[1] - offset);
|
||||
array->Set(v8::String::New(name), element);
|
||||
}
|
||||
|
||||
offsetsV = (TRI_shape_size_t const*) data;
|
||||
|
||||
for (i = 0; i < v; ++i, ++sids, ++aids, ++offsetsV) {
|
||||
TRI_shape_sid_t sid = *sids;
|
||||
|
||||
TRI_shape_t const* subshape;
|
||||
if (sid == shapeCache._sid && shapeCache._sid > 0) {
|
||||
subshape = shapeCache._shape;
|
||||
}
|
||||
else {
|
||||
shapeCache._shape = subshape = shaper->lookupShapeId(shaper, sid);
|
||||
shapeCache._sid = sid;
|
||||
}
|
||||
|
||||
if (subshape == 0) {
|
||||
LOG_WARNING("cannot find shape #%u", (unsigned int) sid);
|
||||
continue;
|
||||
}
|
||||
|
||||
TRI_shape_aid_t aid = *aids;
|
||||
char const* name = shaper->lookupAttributeId(shaper, aid);
|
||||
|
||||
if (name == 0) {
|
||||
LOG_WARNING("cannot find attribute #%u", (unsigned int) aid);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TRI_shape_size_t offset = *offsetsV;
|
||||
v8::Handle<v8::Value> element = JsonShapeData(shaper, subshape, data + offset, offsetsV[1] - offset);
|
||||
array->Set(v8::String::New(name), element);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a data array blob into a new json object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeDataArray (TRI_shaper_t* shaper,
|
||||
|
@ -1229,7 +1342,24 @@ static v8::Handle<v8::Value> JsonShapeDataHomogeneousSizedList (TRI_shaper_t* sh
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a data blob into a json object
|
||||
/// @brief merges a data blob into an existing json object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeData (v8::Handle<v8::Value>& value,
|
||||
TRI_shaper_t* shaper,
|
||||
TRI_shape_t const* shape,
|
||||
char const* data,
|
||||
size_t size) {
|
||||
if (shape == nullptr) {
|
||||
return v8::Null();
|
||||
}
|
||||
|
||||
TRI_ASSERT(shape->_type == TRI_SHAPE_ARRAY);
|
||||
return JsonShapeDataArray(value, shaper, shape, data, size);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a data blob into a new json object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JsonShapeData (TRI_shaper_t* shaper,
|
||||
|
@ -1415,7 +1545,19 @@ v8::Handle<v8::Value> TRI_ObjectJson (TRI_json_t const* json) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a TRI_shaped_json_t into a V8 object
|
||||
/// @brief converts a TRI_shaped_json_t into an existing V8 object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
v8::Handle<v8::Value> TRI_JsonShapeData (v8::Handle<v8::Value> value,
|
||||
TRI_shaper_t* shaper,
|
||||
TRI_shape_t const* shape,
|
||||
char const* data,
|
||||
size_t size) {
|
||||
return JsonShapeData(value, shaper, shape, data, size);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a TRI_shaped_json_t into a new V8 object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
v8::Handle<v8::Value> TRI_JsonShapeData (TRI_shaper_t* shaper,
|
||||
|
|
|
@ -58,7 +58,17 @@ v8::Handle<v8::Array> TRI_ArrayAssociativePointer (TRI_associative_pointer_t con
|
|||
v8::Handle<v8::Value> TRI_ObjectJson (TRI_json_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a TRI_shaped_json_t into a V8 object
|
||||
/// @brief converts a TRI_shaped_json_t into an existing V8 object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
v8::Handle<v8::Value> TRI_JsonShapeData (v8::Handle<v8::Value>,
|
||||
TRI_shaper_t*,
|
||||
TRI_shape_t const*,
|
||||
char const* data,
|
||||
size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts a TRI_shaped_json_t into a new V8 object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
v8::Handle<v8::Value> TRI_JsonShapeData (TRI_shaper_t*,
|
||||
|
|
Loading…
Reference in New Issue