mirror of https://gitee.com/bigwinds/arangodb
added convenience functions
This commit is contained in:
parent
e26c306cfb
commit
442a5f25c6
|
@ -125,7 +125,7 @@ class DocumentAccessor {
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief extracts the pointer to the key from a marker
|
||||
/// @brief extracts the key from a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline std::string TRI_EXTRACT_MARKER_KEY (triagens::arango::Transaction* trx,
|
||||
|
@ -145,7 +145,7 @@ static inline std::string TRI_EXTRACT_MARKER_KEY (triagens::arango::Transaction*
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief extracts the pointer to the key from a marker
|
||||
/// @brief extracts the key from a marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline std::string TRI_EXTRACT_MARKER_KEY (triagens::arango::Transaction* trx,
|
||||
|
@ -183,6 +183,66 @@ static inline TRI_voc_rid_t TRI_EXTRACT_MARKER_RID (triagens::arango::Transactio
|
|||
return TRI_EXTRACT_MARKER_RID(trx, static_cast<TRI_df_marker_t const*>(mptr->getDataPtr()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief compares the key from a master pointer to the given key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline bool TRI_MATCHES_MARKER_KEY (triagens::arango::Transaction* trx,
|
||||
TRI_doc_mptr_t const* mptr,
|
||||
char const* key) {
|
||||
auto marker = static_cast<TRI_df_marker_t const*>(mptr->getDataPtr());
|
||||
|
||||
if (marker->_type == TRI_WAL_MARKER_VPACK_DOCUMENT) {
|
||||
auto b = reinterpret_cast<char const*>(marker) + sizeof(triagens::wal::vpack_document_marker_t);
|
||||
VPackSlice slice(reinterpret_cast<uint8_t const*>(b), trx->vpackOptions());
|
||||
VPackValueLength len;
|
||||
char const* p = slice.get(TRI_VOC_ATTRIBUTE_KEY).getString(len);
|
||||
if (len != strlen(key)) {
|
||||
return false;
|
||||
}
|
||||
return (memcmp(p, key, len) == 0);
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// invalid marker type
|
||||
TRI_ASSERT(false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief compares the key from a master pointer to the given key
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline bool TRI_MATCHES_MARKER_KEY (triagens::arango::Transaction* trx,
|
||||
TRI_doc_mptr_t const* left,
|
||||
TRI_doc_mptr_t const* right) {
|
||||
auto lm = static_cast<TRI_df_marker_t const*>(left->getDataPtr());
|
||||
auto rm = static_cast<TRI_df_marker_t const*>(right->getDataPtr());
|
||||
|
||||
if (lm->_type == TRI_WAL_MARKER_VPACK_DOCUMENT && rm->_type == TRI_WAL_MARKER_VPACK_DOCUMENT) {
|
||||
auto lb = reinterpret_cast<char const*>(lm) + sizeof(triagens::wal::vpack_document_marker_t);
|
||||
VPackSlice ls(reinterpret_cast<uint8_t const*>(lb), trx->vpackOptions());
|
||||
VPackValueLength llen;
|
||||
char const* p = ls.get(TRI_VOC_ATTRIBUTE_KEY).getString(llen);
|
||||
|
||||
auto rb = reinterpret_cast<char const*>(rm) + sizeof(triagens::wal::vpack_document_marker_t);
|
||||
VPackSlice rs(reinterpret_cast<uint8_t const*>(rb), trx->vpackOptions());
|
||||
VPackValueLength rlen;
|
||||
char const* q = rs.get(TRI_VOC_ATTRIBUTE_KEY).getString(rlen);
|
||||
|
||||
if (llen != rlen) {
|
||||
return false;
|
||||
}
|
||||
return (memcmp(p, q, llen) == 0);
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// invalid marker type
|
||||
TRI_ASSERT(false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue