1
0
Fork 0

Fixed OperationCursor and SkiplistIndex. The builder in OperationCursor did not retain the _buffer.

This commit is contained in:
Michael Hackstein 2016-03-15 08:56:37 +01:00
parent a4edc8dd49
commit 5d61b709bb
5 changed files with 12 additions and 12 deletions

View File

@ -294,6 +294,7 @@ bool IndexBlock::initIndexes() {
THROW_ARANGO_EXCEPTION(_cursor->code); THROW_ARANGO_EXCEPTION(_cursor->code);
} }
} else { } else {
_cursor = nullptr;
// We were not able to initialize any index with this condition // We were not able to initialize any index with this condition
return false; return false;
} }
@ -341,6 +342,8 @@ void IndexBlock::startNextCursor() {
if (_currentIndex < _indexes.size()) { if (_currentIndex < _indexes.size()) {
// This check will work as long as _indexes.size() < MAX_SIZE_T // This check will work as long as _indexes.size() < MAX_SIZE_T
_cursor = createCursor(); _cursor = createCursor();
} else {
_cursor = nullptr;
} }
} }

View File

@ -913,6 +913,7 @@ IndexIterator* SkiplistIndex::iteratorForCondition(
} }
// We have to add the value always, the key was added before // We have to add the value always, the key was added before
value->toVelocyPackValue(searchValues); value->toVelocyPackValue(searchValues);
searchValues.close();
} }
// Now handle the next element, which might be a range // Now handle the next element, which might be a range

View File

@ -28,8 +28,6 @@
using namespace arangodb; using namespace arangodb;
void OperationCursor::reset() { void OperationCursor::reset() {
_builder.clear();
if (_indexIterator != nullptr) { if (_indexIterator != nullptr) {
_indexIterator->reset(); _indexIterator->reset();
_hasMore = true; _hasMore = true;
@ -62,11 +60,10 @@ int OperationCursor::getMore(uint64_t batchSize, bool useExternals) {
// You requested more even if you should have checked it before. // You requested more even if you should have checked it before.
return TRI_ERROR_FORBIDDEN; return TRI_ERROR_FORBIDDEN;
} }
// We restart the builder VPackBuilder builder(buffer);
_builder.clear();
VPackArrayBuilder guard(&_builder); VPackArrayBuilder guard(&builder);
TRI_doc_mptr_t* mptr = nullptr; TRI_doc_mptr_t* mptr = nullptr;
// TODO: Improve this for baby awareness // TODO: Improve this for baby awareness
while (batchSize > 0 && _limit > 0 && (mptr = _indexIterator->next()) != nullptr) { while (batchSize > 0 && _limit > 0 && (mptr = _indexIterator->next()) != nullptr) {
@ -74,10 +71,10 @@ int OperationCursor::getMore(uint64_t batchSize, bool useExternals) {
--_limit; --_limit;
#if 0 #if 0
if (useExternals) { if (useExternals) {
_builder.add(VPackValue(mptr->vpack(), VPackValueType::External)); builder.add(VPackValue(mptr->vpack(), VPackValueType::External));
} else { } else {
#endif #endif
_builder.add(VPackSlice(mptr->vpack())); builder.add(VPackSlice(mptr->vpack()));
#if 0 #if 0
} }
#endif #endif

View File

@ -44,7 +44,6 @@ struct OperationCursor : public OperationResult {
private: private:
std::shared_ptr<IndexIterator> _indexIterator; std::shared_ptr<IndexIterator> _indexIterator;
arangodb::velocypack::Builder _builder;
bool _hasMore; bool _hasMore;
uint64_t _limit; uint64_t _limit;
uint64_t const _originalLimit; uint64_t const _originalLimit;
@ -53,11 +52,11 @@ struct OperationCursor : public OperationResult {
public: public:
explicit OperationCursor(int code) explicit OperationCursor(int code)
: OperationResult(code), _builder(buffer), _hasMore(false), _limit(0), _originalLimit(0), _batchSize(1000) { : OperationResult(code), _hasMore(false), _limit(0), _originalLimit(0), _batchSize(1000) {
} }
OperationCursor(int code, std::string const& message) OperationCursor(int code, std::string const& message)
: OperationResult(code, message), _builder(buffer), _hasMore(false), _limit(0), _originalLimit(0), _batchSize(1000) { : OperationResult(code, message), _hasMore(false), _limit(0), _originalLimit(0), _batchSize(1000) {
} }
OperationCursor(std::shared_ptr<VPackBuffer<uint8_t>> buffer, OperationCursor(std::shared_ptr<VPackBuffer<uint8_t>> buffer,
@ -66,7 +65,6 @@ struct OperationCursor : public OperationResult {
int code, int code,
bool wasSynchronous) bool wasSynchronous)
: OperationResult(buffer, handler, message, code, wasSynchronous), : OperationResult(buffer, handler, message, code, wasSynchronous),
_builder(buffer),
_hasMore(false), _hasMore(false),
_limit(0), _limit(0),
_originalLimit(0), _originalLimit(0),
@ -78,7 +76,6 @@ struct OperationCursor : public OperationResult {
: OperationResult(std::make_shared<VPackBuffer<uint8_t>>(), handler, "", : OperationResult(std::make_shared<VPackBuffer<uint8_t>>(), handler, "",
TRI_ERROR_NO_ERROR, false), TRI_ERROR_NO_ERROR, false),
_indexIterator(iterator), _indexIterator(iterator),
_builder(buffer),
_hasMore(true), _hasMore(true),
_limit(limit), // _limit is modified later on _limit(limit), // _limit is modified later on
_originalLimit(limit), _originalLimit(limit),

View File

@ -40,6 +40,7 @@ struct OperationResult {
explicit OperationResult(int code) explicit OperationResult(int code)
: customTypeHandler(), code(code), wasSynchronous(false) { : customTypeHandler(), code(code), wasSynchronous(false) {
buffer = std::make_shared<VPackBuffer<uint8_t>>();
if (code != TRI_ERROR_NO_ERROR) { if (code != TRI_ERROR_NO_ERROR) {
errorMessage = TRI_errno_string(code); errorMessage = TRI_errno_string(code);
} }
@ -48,6 +49,7 @@ struct OperationResult {
OperationResult(int code, std::string const& message) OperationResult(int code, std::string const& message)
: customTypeHandler(), errorMessage(message), code(code), : customTypeHandler(), errorMessage(message), code(code),
wasSynchronous(false) { wasSynchronous(false) {
buffer = std::make_shared<VPackBuffer<uint8_t>>();
TRI_ASSERT(code != TRI_ERROR_NO_ERROR); TRI_ASSERT(code != TRI_ERROR_NO_ERROR);
} }