8000 Feature/cleanup internal (#4680) · ashang/arangodb@3cf03cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 3cf03cf

Browse files
authored
Feature/cleanup internal (arangodb#4680)
1 parent 4f0de29 commit 3cf03cf

37 files changed

+166
-209
lines changed

arangod/Aql/CalculationBlock.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "CalculationBlock.h"
2525
#include "Aql/AqlItemBlock.h"
26+
#include "Aql/BaseExpressionContext.h"
2627
#include "Aql/ExecutionEngine.h"
2728
#include "Aql/Functions.h"
2829
#include "Aql/Query.h"
@@ -123,7 +124,8 @@ void CalculationBlock::executeExpression(AqlItemBlock* result) {
123124

124125
// execute the expression
125126
bool mustDestroy;
126-
AqlValue a = _expression->execute(_trx, result, i, _inVars, _inRegs, mustDestroy);
127+
BaseExpressionContext ctx(i, result, _inVars, _inRegs);
128+
AqlValue a = _expression->execute(_trx, &ctx, mustDestroy);
127129
AqlValueGuard guard(a, mustDestroy);
128130

129131
TRI_IF_FAILURE("CalculationBlock::executeExpression") {

arangod/Aql/Expression.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,6 @@ AqlValue Expression::execute(transaction::Methods* trx, ExpressionContext* ctx,
158158
"invalid expression type");
159159
}
160160

161-
/// @brief execute the expression
162-
/// TODO DEPRECATED
163-
AqlValue Expression::execute(transaction::Methods* trx,
164-
AqlItemBlock const* argv, size_t startPos,
165-
std::vector<Variable const*> const& vars,
166-
std::vector<RegisterId> const& regs,
167-
bool& mustDestroy) {
168-
BaseExpressionContext ctx(startPos, argv, vars, regs);
169-
return execute(trx, &ctx, mustDestroy);
170-
}
171-
172161
/// @brief replace variables in the expression with other variables
173162
void Expression::replaceVariables(
174163
std::unordered_map<VariableId, Variable const*> const& replacements) {
@@ -913,8 +902,8 @@ AqlValue Expression::executeSimpleExpressionFCall(
913902
VPackFunctionParameters parameters{arena};
914903

915904
// same here
916-
SmallVector<uint64_t>::allocator_type::arena_type arena2;
917-
SmallVector<uint64_t> destroyParameters{arena2};
905+
SmallVector<uint8_t>::allocator_type::arena_type arena2;
906+
SmallVector<uint8_t> destroyParameters{arena2};
918907
parameters.reserve(n);
919908
destroyParameters.reserve(n);
920909

arangod/Aql/Expression.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ class Expression {
124124
AqlValue execute(transaction::Methods* trx, ExpressionContext* ctx,
125125
bool& mustDestroy);
126126

127-
/// @brief execute the expression
128-
/// DEPRECATED
129-
AqlValue execute(transaction::Methods* trx, AqlItemBlock const*, size_t,
130-
std::vector<Variable const*> const&,
131-
std::vector<RegisterId> const&, bool& mustDestroy);
132-
133127
/// @brief check whether this is a JSON expression
134128
inline bool isJson() {
135129
if (_type == UNPROCESSED) {

arangod/Aql/Function.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ struct Function {
4646
/// @brief destroy the function
4747
~Function();
4848

49-
/// @brief checks if the function has been deprecated
50-
inline bool isDeprecated() const {
51-
// currently there are no deprecated functions
52-
return false;
53-
}
54-
5549
inline bool hasImplementation() const {
5650
return implementation != nullptr;
5751
}

arangod/Aql/Functions.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,33 +4161,34 @@ AqlValue Functions::PregelResult(arangodb::aql::Query* query, transaction::Metho
41614161
}
41624162

41634163
AqlValue Functions::Assert(arangodb::aql::Query* query, transaction::Methods* trx,
4164-
VPackFunctionParameters const& parameters) {
4164+
VPackFunctionParameters const& parameters) {
41654165
ValidateParameters(parameters, "ASSERT", 2, 2);
41664166
auto const expr = ExtractFunctionParameterValue(parameters, 0);
41674167
auto const message = ExtractFunctionParameterValue(parameters, 1);
4168-
if(!message.isString()){
4168+
4169+
if (!message.isString()) {
41694170
RegisterInvalidArgumentWarning(query, "ASSERT");
41704171
return AqlValue(AqlValueHintNull());
41714172
}
4172-
if(!expr.toBoolean()){
4173+
if (!expr.toBoolean()) {
41734174
std::string msg = message.slice().copyString();
4174-
query->registerError(TRI_ERROR_QUERY_USER_ASSERT,msg.data());
4175+
query->registerError(TRI_ERROR_QUERY_USER_ASSERT, msg.data());
41754176
}
41764177
return AqlValue(AqlValueHintBool(true));
4177-
41784178
}
41794179

41804180
AqlValue Functions::Warn(arangodb::aql::Query* query, transaction::Methods* trx,
4181-
VPackFunctionParameters const& parameters) {
4182-
4181+
VPackFunctionParameters const& parameters) {
41834182
ValidateParameters(parameters, "WARN", 2, 2);
41844183
auto const expr = ExtractFunctionParameterValue(parameters, 0);
41854184
auto const message = ExtractFunctionParameterValue(parameters, 1);
4186-
if(!message.isString()){
4185+
4186+
if (!message.isString()) {
41874187
RegisterInvalidArgumentWarning(query, "WARN");
41884188
return AqlValue(AqlValueHintNull());
41894189
}
4190-
if(!expr.toBoolean()){
4190+
4191+
if (!expr.toBoolean()) {
41914192
std::string msg = message.slice().copyString();
41924193
query->registerWarning(TRI_ERROR_QUERY_USER_WARN, msg.data());
41934194
return AqlValue(AqlValueHintBool(false));

arangod/Aql/IndexBlock.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "IndexBlock.h"
2626
#include "Aql/AqlItemBlock.h"
27+
#include "Aql/BaseExpressionContext.h"
2728
#include "Aql/Collection.h"
2829
#include "Aql/Condition.h"
2930
#include "Aql/ExecutionEngine.h"
@@ -133,8 +134,8 @@ void IndexBlock::executeExpressions() {
133134
auto exp = toReplace->expression;
134135

135136
bool mustDestroy;
136-
AqlValue a = exp->execute(_trx, cur, _pos, _inVars[posInExpressions],
137-
_inRegs[posInExpressions], mustDestroy);
137+
BaseExpressionContext ctx(_pos, cur, _inVars[posInExpressions], _inRegs[posInExpressions]);
138+
AqlValue a = exp->execute(_trx, &ctx, mustDestroy);
138139
AqlValueGuard guard(a, mustDestroy);
139140

140141
AqlValueMaterializer materializer(_trx);

arangod/Aql/ModificationBlocks.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ AqlItemBlock* RemoveBlock::work(std::vector<AqlItemBlock*>& blocks) {
397397
// Do not send request just increase the row
398398
dstRow += n;
399399
}
400-
// done with a block
401-
// now free it already
400< 93C6 code class="diff-text syntax-highlighted-line addition">+
401+
// done with block. now unlink it and return it to block manager
402402
(*it) = nullptr;
403-
delete res;
403+
returnBlock(res);
404404
}
405405

406406
return result.release();
@@ -531,9 +531,10 @@ AqlItemBlock* InsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
531531
ep->_options.ignoreErrors);
532532
}
533533
}
534-
// now free it already
534+
535+
// done with block. now unlink it and return it to block manager
535536
(*it) = nullptr;
536-
delete res;
537+
returnBlock(res);
537538
}
538539

539540
return result.release();
@@ -731,11 +732,10 @@ AqlItemBlock* UpdateBlock::work(std::vector<AqlItemBlock*>& blocks) {
731732
dstRow += n;
732733
}
733734
}
734-
// done with a block
735735

736-
// now free it already
736+
// done with block. now unlink it and return it to block manager
737737
(*it) = nullptr;
738-
delete res;
738+
returnBlock(res);
739739
}
740740

741741
return result.release();
@@ -985,9 +985,9 @@ AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
985985
}
986986
}
987987

988-
// now free it already
988+
// done with block. now unlink it and return it to block manager
989989
(*it) = nullptr;
990-
delete res;
990+
returnBlock(res);
991991
}
992992

993993
return result.release();
@@ -1182,11 +1182,9 @@ AqlItemBlock* ReplaceBlock::work(std::vector<AqlItemBlock*>& blocks) {
11821182
}
11831183
}
11841184

1185-
// done with a block
1186-
1187-
// now free it already
1185+
// done with block. now unlink it and return it to block manager
11881186
(*it) = nullptr;
1189-
delete res;
1187+
returnBlock(res);
11901188
}
11911189

11921190
return result.release();

arangod/Indexes/IndexIterator.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,18 @@
2222
////////////////////////////////////////////////////////////////////////////////
2323

2424
#include "IndexIterator.h"
10000 25-
#include "Basics/StringUtils.h"
26-
#include "Cluster/ServerState.h"
2725
#include "Indexes/Index.h"
28-
#include "Utils/CollectionNameResolver.h"
2926
#include "VocBase/LogicalCollection.h"
30-
#include "VocBase/ManagedDocumentResult.h"
3127

3228
using namespace arangodb;
3329

3430
IndexIterator::IndexIterator(LogicalCollection* collection,
3531
transaction::Methods* trx,
36-
ManagedDocumentResult* mmdr,
3732
arangodb::Index const* index)
3833
: _collection(collection),
39-
_trx(trx),
40-
_mmdr(mmdr ? mmdr : new ManagedDocumentResult),
41-
_context(trx, collection, _mmdr, index->fields().size()),
42-
_responsible(mmdr == nullptr) {
34+
_trx(trx) {
4335
TRI_ASSERT(_collection != nullptr);
4436
TRI_ASSERT(_trx != nullptr);
45-
TRI_ASSERT(_mmdr != nullptr);
46-
}
47-
48-
IndexIterator::IndexIterator(LogicalCollection* collection,
49-
transaction::Methods* trx,
50-
arangodb::Index const* index)
51-
: _collection(collection),
52-
_trx(trx),
53-
_mmdr(nullptr),
54-
_context(trx, collection, nullptr, index->fields().size()),
55-
_responsible(false) {
56-
TRI_ASSERT(_collection != nullptr);
57-
TRI_ASSERT(_trx != nullptr);
58-
}
59-
60-
/// @brief default destructor. Does not free anything
61-
IndexIterator::~IndexIterator() {
62-
if (_responsible) {
63-
delete _mmdr;
64-
}
6537
}
6638

6739
bool IndexIterator::nextDocument(DocumentCallback const& cb, size_t limit) {
@@ -123,7 +95,7 @@ bool MultiIndexIterator::next(LocalDocumentIdCallback const& callback, size_t li
12395
/// @brief Reset the cursor
12496
/// This will reset ALL internal iterators and start all over again
12597
void MultiIndexIterator::reset() {
126-
_current = _iterators.at(0);
98+
_current = _iterators[0];
12799
_currentIdx = 0;
128100
for (auto& it : _iterators) {
129101
it->reset();

arangod/Indexes/IndexIterator.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,13 @@
4646
#define ARANGOD_INDEXES_INDEX_ITERATOR_H 1
4747

4848
#include "Basics/Common.h"
49-
#include "Indexes/IndexLookupContext.h"
5049
#include "VocBase/LocalDocumentId.h"
5150
#include "VocBase/vocbase.h"
5251

5352
namespace arangodb {
5453
class Index;
5554
class LogicalCollection;
56-
class ManagedDocumentResult;
55+
5756
namespace transaction {
5857
class Methods;
5958
}
@@ -73,10 +72,9 @@ class IndexIterator {
7372
IndexIterator& operator=(IndexIterator const&) = delete;
7473
IndexIterator() = delete;
7574

76-
IndexIterator(LogicalCollection*, transaction::Methods*, ManagedDocumentResult*, arangodb::Index const*);
7775
IndexIterator(LogicalCollection*, transaction::Methods*, arangodb::Index const*);
7876

79-
virtual ~IndexIterator();
77+
virtual ~IndexIterator() {}
8078

8179
virtual char const* typeName() const = 0;
8280

@@ -99,9 +97,6 @@ class IndexIterator {
9997
protected:
10098
LogicalCollection* _collection;
10199
transaction::Methods* _trx;
102-
ManagedDocumentResult* _mmdr;
103-
IndexLookupContext _context;
104-
bool _responsible;
105100
};
106101

107102
/// @brief Special iterator if the condition cannot have any result
@@ -134,12 +129,11 @@ class MultiIndexIterator final : public IndexIterator {
134129

135130
public:
136131
MultiIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
137-
ManagedDocumentResult* mmdr,
138132
arangodb::Index const* index,
139133
std::vector<IndexIterator*> const& iterators)
140-
: IndexIterator(collection, trx, mmdr, index), _iterators(iterators), _currentIdx(0), _current(nullptr) {
134+
: IndexIterator(collection, trx, index), _iterators(iterators), _currentIdx(0), _current(nullptr) {
141135
if (!_iterators.empty()) {
142-
_current = _iterators.at(0);
136+
_current = _iterators[0];
143137
}
144138
}
145139

arangod/MMFiles/MMFilesEdgeIndex.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ MMFilesEdgeIndexIterator::MMFilesEdgeIndexIterator(
5858
ManagedDocumentResult* mmdr, arangodb::MMFilesEdgeIndex const* index,
5959
TRI_MMFilesEdgeIndexHash_t const* indexImpl,
6060
std::unique_ptr<VPackBuilder>& keys)
61-
: IndexIterator(collection, trx, mmdr, index),
61+
: IndexIterator(collection, trx, index),
6262
_index(indexImpl),
63+
_mmdr(mmdr),
64+
_context(trx, collection, _mmdr, index->fields().size()),
6365
_keys(keys.get()),
6466
_iterator(_keys->slice()),
6567
_posInBuffer(0),

arangod/MMFiles/MMFilesEdgeIndex.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Basics/fasthash.h"
3030
#include "Indexes/Index.h"
3131
#include "Indexes/IndexIterator.h"
32+
#include "Indexes/IndexLookupContext.h"
3233
#include "MMFiles/MMFilesIndex.h"
3334
#include "MMFiles/MMFilesIndexElement.h"
3435
#include "VocBase/voc-types.h"
@@ -42,6 +43,7 @@ namespace basics {
4243
class LocalTaskQueue;
4344
}
4445

46+
class ManagedDocumentResult;
4547
class MMFilesEdgeIndex;
4648

4749
struct MMFilesEdgeIndexHelper {
@@ -128,6 +130,8 @@ class MMFilesEdgeIndexIterator final : public IndexIterator {
128130

129131
private:
130132
TRI_MMFilesEdgeIndexHash_t const* _index;
133+
ManagedDocumentResult* _mmdr;
134+
IndexLookupContext _context;
131135
std::unique_ptr<arangodb::velocypack::Builder> _keys;
132136
arangodb::velocypack::ArrayIterator _iterator;
133137
std::vector<MMFilesSimpleIndexElement> _buffer;

arangod/MMFiles/MMFilesFulltextIndex.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void MMFilesFulltextIndex::unload() {
232232
}
233233

234234
IndexIterator* MMFilesFulltextIndex::iteratorForCondition(
235-
transaction::Methods* trx, ManagedDocumentResult* mdr,
235+
transaction::Methods* trx, ManagedDocumentResult*,
236236
aql::AstNode const* condNode, aql::Variable const* var, bool reverse) {
237237
TRI_ASSERT(condNode != nullptr);
238238

@@ -267,8 +267,7 @@ IndexIterator* MMFilesFulltextIndex::iteratorForCondition(
267267
// note: the following call will free "ft"!
268268
std::set<TRI_voc_rid_t> results =
269269
TRI_QueryMMFilesFulltextIndex(_fulltextIndex, ft);
270-
return new MMFilesFulltextIndexIterator(_collection, trx, mdr, this,
271-
std::move(results));
270+
return new MMFilesFulltextIndexIterator(_collection, trx, this, std::move(results));
272271
}
273272

274273
/// @brief callback function called by the fulltext index to determine the

arangod/MMFiles/MMFilesFulltextIndex.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ class MMFilesFulltextIndexIterator : public IndexIterator {
113113
public:
114114
MMFilesFulltextIndexIterator(LogicalCollection* collection,
115115
transaction::Methods* trx,
116-
ManagedDocumentResult* mmdr,
117116
MMFilesFulltextIndex const* index,
118117
std::set<TRI_voc_rid_t>&& docs)
119-
: IndexIterator(collection, trx, mmdr, index),
118+
: IndexIterator(collection, trx, index),
120119
_docs(std::move(docs)),
121120
_pos(_docs.begin()) {}
122121

0 commit comments

Comments
 (0)
0