From 1cc46c462648e96d93b9250f584450f4d84947c1 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Thu, 12 Jun 2014 10:26:24 +0200 Subject: [PATCH 1/2] copy WAL documents --- arangod/Utils/Transaction.h | 12 ------------ arangod/V8Server/v8-vocbase.cpp | 9 +++++---- arangod/VocBase/datafile.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/arangod/Utils/Transaction.h b/arangod/Utils/Transaction.h index 2a911778f5..8a255a018a 100644 --- a/arangod/Utils/Transaction.h +++ b/arangod/Utils/Transaction.h @@ -157,18 +157,6 @@ namespace triagens { return (_nestingLevel > 0); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not shaped json in this trx should be copied -//////////////////////////////////////////////////////////////////////////////// - - inline bool mustCopyShapedJson () const { - if (_trx != nullptr && _trx->_hasOperations) { - return true; - } - - return false; - } - //////////////////////////////////////////////////////////////////////////////// /// @brief get the status of the transaction //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index 4c6530e629..e4c094f900 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -9645,15 +9645,16 @@ v8::Handle TRI_WrapShapedJson (T& trx, v8::Isolate* isolate = v8::Isolate::GetCurrent(); TRI_v8_global_t* v8g = static_cast(isolate->GetData()); - bool doCopy = trx.mustCopyShapedJson(); - + void const* marker = document->getDataPtr(); + bool const doCopy = TRI_IsWalDataMarkerDatafile(marker); + if (doCopy) { // we'll create a full copy of the document TRI_document_collection_t* collection = trx.documentCollection(); TRI_shaper_t* shaper = collection->getShaper(); TRI_shaped_json_t json; - TRI_EXTRACT_SHAPED_JSON_MARKER(json, document->getDataPtr()); // PROTECTED by trx from above + TRI_EXTRACT_SHAPED_JSON_MARKER(json, marker); // PROTECTED by trx from above TRI_shape_t const* shape = shaper->lookupShapeId(shaper, json._sid); @@ -9692,7 +9693,7 @@ v8::Handle TRI_WrapShapedJson (T& trx, return scope.Close(result); } - void* data = const_cast(document->getDataPtr()); // PROTECTED by trx from above + void* data = const_cast(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)); diff --git a/arangod/VocBase/datafile.h b/arangod/VocBase/datafile.h index c46f1517c4..5022823b2d 100644 --- a/arangod/VocBase/datafile.h +++ b/arangod/VocBase/datafile.h @@ -608,6 +608,16 @@ void TRI_FreeDatafile (TRI_datafile_t*); // --SECTION-- public functions // ----------------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////// +/// @brief checks if a marker is a data marker in the WAL +//////////////////////////////////////////////////////////////////////////////// + +static inline bool TRI_IsWalDataMarkerDatafile (void const* marker) { + TRI_df_marker_t const* m = static_cast(marker); + + return (m->_type == TRI_WAL_MARKER_DOCUMENT || m->_type == TRI_WAL_MARKER_EDGE); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief returns the name for a marker //////////////////////////////////////////////////////////////////////////////// From bca5b999d921a79d14b0573be0f7af4de0beb74e Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Thu, 12 Jun 2014 10:26:53 +0200 Subject: [PATCH 2/2] removed fcall --- arangod/V8Server/v8-vocbase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index e4c094f900..19fc3dfebf 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -9640,12 +9640,13 @@ v8::Handle TRI_WrapShapedJson (T& trx, TRI_ASSERT(barrier != nullptr); TRI_ASSERT(document != nullptr); - TRI_ASSERT(document->getDataPtr() != nullptr); // PROTECTED by trx from above v8::Isolate* isolate = v8::Isolate::GetCurrent(); TRI_v8_global_t* v8g = static_cast(isolate->GetData()); void const* marker = document->getDataPtr(); + TRI_ASSERT(marker != nullptr); // PROTECTED by trx from above + bool const doCopy = TRI_IsWalDataMarkerDatafile(marker); if (doCopy) {