From dc0c2044243bd01a64e084b5f26636fa4fcba9e2 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Fri, 29 Aug 2014 23:54:22 +0200 Subject: [PATCH] Store documents in a skiplist index even if some indexed attrs are empty. --- arangod/VocBase/index.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arangod/VocBase/index.cpp b/arangod/VocBase/index.cpp index a5c7653c6d..7163b57e67 100644 --- a/arangod/VocBase/index.cpp +++ b/arangod/VocBase/index.cpp @@ -1275,7 +1275,14 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex, TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(skiplistIndex->base._collection->getShaper(), shapedJson._sid, shape); // ONLY IN INDEX, PROTECTED by RUNTIME if (acc == nullptr || acc->_resultSid == TRI_SHAPE_ILLEGAL) { - return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING; + // OK, the document does not contain the attributed needed by + // the index, so let's fake a JSON null: + skiplistElement->_subObjects[j]._sid = TRI_SHAPE_NULL; + skiplistElement->_subObjects[j]._length = 0; + skiplistElement->_subObjects[j]._offset = 0; + continue; + // This used to be: + // return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING; } @@ -1339,6 +1346,10 @@ static int InsertSkiplistIndex (TRI_index_t* idx, // most likely the cause of this error is that the 'shape' of the document // does not match the 'shape' of the index structure -- so the document // is ignored. So not really an error at all. + // Changed: empty attributes are currently always treated as if they + // were bound to null, so TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING + // cannot happen at all. When we have a sparse skiplist index, this + // can reappear, therefore we leave the case distinction below in. // ........................................................................... if (res != TRI_ERROR_NO_ERROR) {