mirror of https://gitee.com/bigwinds/arangodb
fixed edges
This commit is contained in:
parent
045ed83270
commit
c5103e28b3
|
@ -10009,11 +10009,17 @@ static v8::Handle<v8::Object> AddBasicDocumentAttributes (T& trx,
|
|||
TRI_df_marker_type_t type = ((TRI_df_marker_t*) document->_data)->_type;
|
||||
|
||||
if (type == TRI_DOC_MARKER_KEY_EDGE) {
|
||||
TRI_doc_edge_key_marker_t* marker = (TRI_doc_edge_key_marker_t*) document->_data;
|
||||
TRI_doc_edge_key_marker_t const* marker = static_cast<TRI_doc_edge_key_marker_t const*>(document->_data);
|
||||
|
||||
result->Set(v8g->_FromKey, V8DocumentId(trx.resolver().getCollectionNameCluster(marker->_fromCid), ((char*) marker) + marker->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(trx.resolver().getCollectionNameCluster(marker->_toCid), ((char*) marker) + marker->_offsetToKey));
|
||||
}
|
||||
else if (type == TRI_WAL_MARKER_EDGE) {
|
||||
triagens::wal::edge_marker_t const* marker = static_cast<triagens::wal::edge_marker_t const*>(document->_data);
|
||||
|
||||
result->Set(v8g->_FromKey, V8DocumentId(trx.resolver().getCollectionNameCluster(marker->_fromCid), ((char const*) marker) + marker->_offsetFromKey));
|
||||
result->Set(v8g->_ToKey, V8DocumentId(trx.resolver().getCollectionNameCluster(marker->_toCid), ((char const*) marker) + marker->_offsetToKey));
|
||||
}
|
||||
|
||||
return scope.Close(result);
|
||||
}
|
||||
|
|
|
@ -2209,6 +2209,11 @@ static int RemoveDocumentShapedJson (TRI_transaction_collection_t* trxCollection
|
|||
bool lock,
|
||||
bool forceSync) {
|
||||
assert(key != nullptr);
|
||||
|
||||
if (rid == 0) {
|
||||
// generate new revision id
|
||||
rid = static_cast<TRI_voc_rid_t>(TRI_NewTickServer());
|
||||
}
|
||||
|
||||
TRI_primary_collection_t* primary = trxCollection->_collection->_collection;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ Marker::Marker (TRI_df_marker_type_e type,
|
|||
: _buffer(new char[size]),
|
||||
_size(size) {
|
||||
|
||||
TRI_df_marker_t* m = reinterpret_cast<TRI_df_marker_t*>(base());
|
||||
TRI_df_marker_t* m = reinterpret_cast<TRI_df_marker_t*>(begin());
|
||||
m->_type = type;
|
||||
m->_size = static_cast<TRI_voc_size_t>(size);
|
||||
m->_crc = 0;
|
||||
|
@ -97,7 +97,7 @@ Marker::~Marker () {
|
|||
void Marker::storeSizedString (size_t offset,
|
||||
char const* value,
|
||||
size_t length) {
|
||||
char* p = static_cast<char*>(base()) + offset;
|
||||
char* p = static_cast<char*>(begin()) + offset;
|
||||
|
||||
// store actual key
|
||||
memcpy(p, value, length);
|
||||
|
@ -122,7 +122,7 @@ BeginTransactionMarker::BeginTransactionMarker (TRI_voc_tick_t databaseId,
|
|||
: Marker(TRI_WAL_MARKER_BEGIN_TRANSACTION,
|
||||
sizeof(transaction_begin_marker_t)) {
|
||||
|
||||
transaction_begin_marker_t* m = reinterpret_cast<transaction_begin_marker_t*>(base());
|
||||
transaction_begin_marker_t* m = reinterpret_cast<transaction_begin_marker_t*>(begin());
|
||||
|
||||
m->_databaseId = databaseId;
|
||||
m->_transactionId = transactionId;
|
||||
|
@ -152,7 +152,7 @@ CommitTransactionMarker::CommitTransactionMarker (TRI_voc_tick_t databaseId,
|
|||
: Marker(TRI_WAL_MARKER_COMMIT_TRANSACTION,
|
||||
sizeof(transaction_commit_marker_t)) {
|
||||
|
||||
transaction_commit_marker_t* m = reinterpret_cast<transaction_commit_marker_t*>(base());
|
||||
transaction_commit_marker_t* m = reinterpret_cast<transaction_commit_marker_t*>(begin());
|
||||
|
||||
m->_databaseId = databaseId;
|
||||
m->_transactionId = transactionId;
|
||||
|
@ -182,7 +182,7 @@ AbortTransactionMarker::AbortTransactionMarker (TRI_voc_tick_t databaseId,
|
|||
: Marker(TRI_WAL_MARKER_ABORT_TRANSACTION,
|
||||
sizeof(transaction_abort_marker_t)) {
|
||||
|
||||
transaction_abort_marker_t* m = reinterpret_cast<transaction_abort_marker_t*>(base());
|
||||
transaction_abort_marker_t* m = reinterpret_cast<transaction_abort_marker_t*>(begin());
|
||||
|
||||
m->_databaseId = databaseId;
|
||||
m->_transactionId = transactionId;
|
||||
|
@ -216,7 +216,7 @@ DocumentMarker::DocumentMarker (TRI_voc_tick_t databaseId,
|
|||
TRI_shaped_json_t const* shapedJson)
|
||||
: Marker(TRI_WAL_MARKER_DOCUMENT,
|
||||
sizeof(document_marker_t) + alignedSize(key.size() + 1) + legend.getSize() + shapedJson->_data.length) {
|
||||
document_marker_t* m = reinterpret_cast<document_marker_t*>(base());
|
||||
document_marker_t* m = reinterpret_cast<document_marker_t*>(begin());
|
||||
m->_databaseId = databaseId;
|
||||
m->_collectionId = collectionId;
|
||||
m->_rid = revisionId;
|
||||
|
@ -230,13 +230,13 @@ DocumentMarker::DocumentMarker (TRI_voc_tick_t databaseId,
|
|||
|
||||
// store legend
|
||||
{
|
||||
char* p = static_cast<char*>(base()) + m->_offsetLegend;
|
||||
char* p = static_cast<char*>(begin()) + m->_offsetLegend;
|
||||
legend.dump(p);
|
||||
}
|
||||
|
||||
// store shapedJson
|
||||
{
|
||||
char* p = static_cast<char*>(base()) + m->_offsetJson;
|
||||
char* p = static_cast<char*>(begin()) + m->_offsetJson;
|
||||
memcpy(p, shapedJson->_data.data, static_cast<size_t>(shapedJson->_data.length));
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ DocumentMarker::~DocumentMarker () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DocumentMarker::dump () const {
|
||||
document_marker_t* m = reinterpret_cast<document_marker_t*>(base());
|
||||
document_marker_t* m = reinterpret_cast<document_marker_t*>(begin());
|
||||
|
||||
std::cout << "WAL DOCUMENT MARKER FOR DB " << m->_databaseId
|
||||
<< ", COLLECTION " << m->_collectionId
|
||||
|
@ -265,12 +265,10 @@ void DocumentMarker::dump () const {
|
|||
<< ", OFFSETKEY: " << m->_offsetKey
|
||||
<< ", OFFSETLEGEND: " << m->_offsetLegend
|
||||
<< ", OFFSETJSON: " << m->_offsetJson
|
||||
<< ", KEYLENGTH: " << keyLength()
|
||||
<< ", SIZE: " << size()
|
||||
<< "\n";
|
||||
|
||||
std::cout << "BINARY: '" << stringifyPart(base(), size()) << "'\n";
|
||||
std::cout << "KEY: '" << stringifyPart(key(), keyLength()) << "'\n";
|
||||
std::cout << "BINARY: '" << stringifyPart(begin(), size()) << "'\n";
|
||||
std::cout << "LEGEND: '" << stringifyPart(legend(), legendLength()) << "'\n";
|
||||
std::cout << "LEGEND HEX: '" << hexifyPart(legend(), legendLength()) << "'\n";
|
||||
std::cout << "JSON: '" << stringifyPart(json(), jsonLength()) << "'\n";
|
||||
|
@ -342,7 +340,7 @@ EdgeMarker::EdgeMarker (TRI_voc_tick_t databaseId,
|
|||
: Marker(TRI_WAL_MARKER_EDGE,
|
||||
sizeof(edge_marker_t) + alignedSize(key.size() + 1) + alignedSize(strlen(edge->_fromKey) + 1) + alignedSize(strlen(edge->_toKey) + 1) + legend.getSize() + shapedJson->_data.length) {
|
||||
|
||||
edge_marker_t* m = reinterpret_cast<edge_marker_t*>(base());
|
||||
edge_marker_t* m = reinterpret_cast<edge_marker_t*>(begin());
|
||||
|
||||
m->_databaseId = databaseId;
|
||||
m->_collectionId = collectionId;
|
||||
|
@ -364,13 +362,13 @@ EdgeMarker::EdgeMarker (TRI_voc_tick_t databaseId,
|
|||
|
||||
// store legend
|
||||
{
|
||||
char* p = static_cast<char*>(base()) + m->_offsetLegend;
|
||||
char* p = static_cast<char*>(begin()) + m->_offsetLegend;
|
||||
legend.dump(p);
|
||||
}
|
||||
|
||||
// store shapedJson
|
||||
{
|
||||
char* p = static_cast<char*>(base()) + m->_offsetJson;
|
||||
char* p = static_cast<char*>(begin()) + m->_offsetJson;
|
||||
memcpy(p, shapedJson->_data.data, static_cast<size_t>(shapedJson->_data.length));
|
||||
}
|
||||
|
||||
|
@ -389,18 +387,30 @@ EdgeMarker::~EdgeMarker () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EdgeMarker::dump () const {
|
||||
edge_marker_t* m = reinterpret_cast<edge_marker_t*>(base());
|
||||
edge_marker_t* m = reinterpret_cast<edge_marker_t*>(begin());
|
||||
|
||||
std::cout << "WAL EDGE MARKER FOR DB " << m->_databaseId
|
||||
<< ", COLLECTION " << m->_collectionId
|
||||
<< ", REV: " << m->_rid
|
||||
<< ", TRX: " << m->_tid
|
||||
<< ", KEY: " << ((char*) base() + m->_offsetKey)
|
||||
<< ", REV: " << rid()
|
||||
<< ", TRX: " << tid()
|
||||
<< ", KEY: " << key()
|
||||
<< ", FROMCID " << m->_fromCid
|
||||
<< ", TOCID " << m->_toCid
|
||||
<< ", FROMKEY: " << ((char*) base() + m->_offsetFromKey)
|
||||
<< ", TOKEY: " << ((char*) base() + m->_offsetFromKey)
|
||||
<< ", FROMKEY: " << fromKey()
|
||||
<< ", TOKEY: " << toKey()
|
||||
<< ", OFFSETKEY: " << m->_offsetKey
|
||||
<< ", OFFSETFROM: " << m->_offsetFromKey
|
||||
<< ", OFFSETTO: " << m->_offsetToKey
|
||||
<< ", OFFSETLEGEND: " << m->_offsetLegend
|
||||
<< ", OFFSETJSON: " << m->_offsetJson
|
||||
<< ", SIZE: " << size()
|
||||
<< "\n";
|
||||
|
||||
std::cout << "BINARY: '" << stringifyPart(begin(), size()) << "'\n";
|
||||
std::cout << "LEGEND: '" << stringifyPart(legend(), legendLength()) << "'\n";
|
||||
std::cout << "LEGEND HEX: '" << hexifyPart(legend(), legendLength()) << "'\n";
|
||||
std::cout << "JSON: '" << stringifyPart(json(), jsonLength()) << "'\n";
|
||||
std::cout << "JSON HEX: '" << hexifyPart(json(), jsonLength()) << "'\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -480,7 +490,7 @@ RemoveMarker::RemoveMarker (TRI_voc_tick_t databaseId,
|
|||
std::string const& key)
|
||||
: Marker(TRI_WAL_MARKER_REMOVE,
|
||||
sizeof(remove_marker_t) + alignedSize(key.size() + 1)) {
|
||||
remove_marker_t* m = reinterpret_cast<remove_marker_t*>(base());
|
||||
remove_marker_t* m = reinterpret_cast<remove_marker_t*>(begin());
|
||||
m->_databaseId = databaseId;
|
||||
m->_collectionId = collectionId;
|
||||
m->_rid = revisionId;
|
||||
|
@ -503,14 +513,16 @@ RemoveMarker::~RemoveMarker () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoveMarker::dump () const {
|
||||
remove_marker_t* m = reinterpret_cast<remove_marker_t*>(base());
|
||||
remove_marker_t* m = reinterpret_cast<remove_marker_t*>(begin());
|
||||
|
||||
std::cout << "WAL REMOVE MARKER FOR DB " << m->_databaseId
|
||||
<< ", COLLECTION " << m->_collectionId
|
||||
<< ", REV: " << m->_rid
|
||||
<< ", TRX: " << m->_tid
|
||||
<< ", KEY: " << (((char*) base()) + sizeof(remove_marker_t))
|
||||
<< ", KEY: " << key()
|
||||
<< "\n";
|
||||
|
||||
std::cout << "BINARY: '" << stringifyPart(begin(), size()) << "'\n";
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
@ -150,12 +150,16 @@ namespace triagens {
|
|||
return static_cast<void*>(_buffer);
|
||||
}
|
||||
|
||||
inline char* base () const {
|
||||
inline char* begin () const {
|
||||
return _buffer;
|
||||
}
|
||||
|
||||
inline char* end () const {
|
||||
return _buffer + _size;
|
||||
}
|
||||
|
||||
inline char* payload () const {
|
||||
return base() + sizeof(TRI_df_marker_t);
|
||||
return begin() + sizeof(TRI_df_marker_t);
|
||||
}
|
||||
|
||||
inline uint32_t size () const {
|
||||
|
@ -268,36 +272,41 @@ namespace triagens {
|
|||
~DocumentMarker ();
|
||||
|
||||
public:
|
||||
|
||||
inline TRI_voc_rid_t rid () const {
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return m->_rid;
|
||||
}
|
||||
|
||||
inline TRI_voc_rid_t tid () const {
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return m->_tid;
|
||||
}
|
||||
|
||||
inline char const* key () const {
|
||||
// pointer to key
|
||||
return base() + sizeof(document_marker_t);
|
||||
return begin() + sizeof(document_marker_t);
|
||||
}
|
||||
|
||||
inline size_t keyLength () const {
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(base());
|
||||
return static_cast<size_t>(m->_offsetLegend - m->_offsetKey);
|
||||
}
|
||||
|
||||
inline char const* legend () const {
|
||||
// pointer to legend
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(base());
|
||||
return base() + m->_offsetLegend;
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return begin() + m->_offsetLegend;
|
||||
}
|
||||
|
||||
inline size_t legendLength () const {
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(base());
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return static_cast<size_t>(m->_offsetJson - m->_offsetLegend);
|
||||
}
|
||||
|
||||
inline char const* json () const {
|
||||
// pointer to json
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(base());
|
||||
return base() + m->_offsetJson;
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return begin() + m->_offsetJson;
|
||||
}
|
||||
|
||||
inline size_t jsonLength () const {
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(base());
|
||||
document_marker_t const* m = reinterpret_cast<document_marker_t const*>(begin());
|
||||
return static_cast<size_t>(size() - m->_offsetJson);
|
||||
}
|
||||
|
||||
|
@ -330,6 +339,55 @@ namespace triagens {
|
|||
TRI_shaped_json_t const*);
|
||||
|
||||
~EdgeMarker ();
|
||||
|
||||
inline TRI_voc_rid_t rid () const {
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return m->_rid;
|
||||
}
|
||||
|
||||
inline TRI_voc_rid_t tid () const {
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return m->_tid;
|
||||
}
|
||||
|
||||
inline char const* key () const {
|
||||
// pointer to key
|
||||
return begin() + sizeof(edge_marker_t);
|
||||
}
|
||||
|
||||
inline char const* fromKey () const {
|
||||
// pointer to _from key
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return begin() + m->_offsetFromKey;
|
||||
}
|
||||
|
||||
inline char const* toKey () const {
|
||||
// pointer to _to key
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return begin() + m->_offsetToKey;
|
||||
}
|
||||
|
||||
inline char const* legend () const {
|
||||
// pointer to legend
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return begin() + m->_offsetLegend;
|
||||
}
|
||||
|
||||
inline size_t legendLength () const {
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return static_cast<size_t>(m->_offsetJson - m->_offsetLegend);
|
||||
}
|
||||
|
||||
inline char const* json () const {
|
||||
// pointer to json
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return begin() + m->_offsetJson;
|
||||
}
|
||||
|
||||
inline size_t jsonLength () const {
|
||||
edge_marker_t const* m = reinterpret_cast<edge_marker_t const*>(begin());
|
||||
return static_cast<size_t>(size() - m->_offsetJson);
|
||||
}
|
||||
|
||||
void dump () const;
|
||||
|
||||
|
@ -362,11 +420,16 @@ namespace triagens {
|
|||
|
||||
inline char const* key () const {
|
||||
// pointer to key
|
||||
return base() + sizeof(remove_marker_t);
|
||||
return begin() + sizeof(remove_marker_t);
|
||||
}
|
||||
|
||||
inline TRI_voc_rid_t tid () const {
|
||||
remove_marker_t const* m = reinterpret_cast<remove_marker_t const*>(begin());
|
||||
return m->_tid;
|
||||
}
|
||||
|
||||
inline TRI_voc_rid_t rid () const {
|
||||
remove_marker_t const* m = reinterpret_cast<remove_marker_t const*>(base());
|
||||
remove_marker_t const* m = reinterpret_cast<remove_marker_t const*>(begin());
|
||||
return m->_rid;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue