8000 fix compile warnings in MSVC · sleepycat/arangodb@b8e1eb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8e1eb8

Browse files
committed
fix compile warnings in MSVC
1 parent c62b952 commit b8e1eb8

File tree

5 files changed

+30
-33
lines changed

5 files changed

+30
-33
lines changed

arangod/Aql/EnumerateCollectionBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int EnumerateCollectionBlock::initialize() {
123123
auto dbName = logicalCollection->dbName();
124124
auto collectionInfoCurrent = ClusterInfo::instance()->getCollectionCurrent(dbName, std::to_string(cid));
125125

126-
double maxWait = _engine->getQuery()->getNumericOption("satelliteSyncWait", 60.0);
126+
double maxWait = _engine->getQuery()->getNumericOption<double>("satelliteSyncWait", 60.0);
127127
bool inSync = false;
128128
unsigned long waitInterval = 10000;
129129
double startTime = TRI_microtime();

arangod/Aql/ExecutionBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ExecutionBlock::ExecutionBlock(ExecutionEngine* engine, ExecutionNode const* ep)
3737
_exeNode(ep),
3838
_pos(0),
3939
_done(false),
40-
_tracing(engine->getQuery()->getNumericOption("tracing", 0)) {}
40+
_tracing(engine->getQuery()->getNumericOption<double>("tracing", 0.0)) {}
4141

4242
ExecutionBlock::~ExecutionBlock() {
4343
for (auto& it : _buffer) {

arangod/Aql/ExecutionEngine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
565565
result.add(VPackValue("-all"));
566566
result.close(); // options.optimizer.rules
567567
result.close(); // options.optimizer
568-
double tracing = query->getNumericOption("tracing", 0);
568+
double tracing = query->getNumericOption<double>("tracing", 0.0);
569569
result.add("tracing", VPackValue(tracing));
570-
double satelliteSyncWait = query->getNumericOption("satelliteSyncWait", 60.0);
570+
double satelliteSyncWait = query->getNumericOption<double>("satelliteSyncWait", 60.0);
571571
result.add("satelliteSyncWait", VPackValue(satelliteSyncWait));
572572
result.close(); // options
573573

arangod/Aql/Query.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,25 +1294,6 @@ bool Query::canUseQueryCache() const {
12941294
return false;
12951295
}
12961296

1297-
/// @brief fetch a numeric value from the options
1298-
double Query::getNumericOption(char const* option, double defaultValue) const {
1299-
if (_options == nullptr) {
1300-
return defaultValue;
1301-
}
1302-
1303-
VPackSlice options = _options->slice();
1304-
if (!options.isObject()) {
1305-
return defaultValue;
1306-
}
1307-
1308-
VPackSlice value = options.get(option);
1309-
if (!value.isNumber()) {
1310-
return defaultValue;
1311-
}
1312-
1313-
return value.getNumericValue<double>();
1314-
}
1315-
13161297
/// @brief neatly format transaction error to the user.
13171298
QueryResult Query::transactionError(int errorCode) const {
13181299
std::string err(TRI_errno_string(errorCode));

arangod/Aql/Query.h

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ class Query {
180180

181181
/// @brief maximum number of plans to produce
182182
size_t maxNumberOfPlans() const {
183-
double value = getNumericOption("maxNumberOfPlans", 0.0);
184-
if (value > 0.0) {
185-
return static_cast<size_t>(value);
183+
size_t value = getNumericOption<size_t>("maxNumberOfPlans", 0);
184+
if (value > 0) {
185+
return value;
186186
}
187187
return 0;
188188
}
@@ -206,18 +206,18 @@ class Query {
206206

207207
/// @brief memory limit for query
208208
size_t memoryLimit() const {
209-
double value = getNumericOption("memoryLimit", MemoryLimitValue);
210-
if (value > 0.0) {
209+
uint64_t value = getNumericOption<decltype(MemoryLimitValue)>("memoryLimit", MemoryLimitValue);
210+
if (value > 0) {
211211
return static_cast<size_t>(value);
212212
}
213213
return 0;
214214
}
215215

216216
/// @brief maximum number of plans to produce
217217
int64_t literalSizeThreshold() const {
218-
double value = getNumericOption("literalSizeThreshold", 0.0);
219-
if (value > 0.0) {
220-
return static_cast<int64_t>(value);
218+
int64_t value = getNumericOption<int64_t>("literalSizeThreshold", 0);
219+
if (value > 0) {
220+
return value;
221221
}
222222
return -1;
223223
}
@@ -344,9 +344,25 @@ class Query {
344344
/// @brief whether or not the query cache can be used for the query
345345
bool canUseQueryCache() const;
346346

347-
/// @brief fetch a numeric value from the options
348347
public:
349-
double getNumericOption(char const*, double) const;
348+
/// @brief fetch a numeric value from the options
349+
template<typename T> T getNumericOption(char const* option, T defaultValue) const {
350+
if (_options == nullptr) {
351+
return defaultValue;
352+
}
353+
354+
VPackSlice options = _options->slice();
355+
if (!options.isObject()) {
356+
return defaultValue;
357+
}
358+
359+
VPackSlice value = options.get(option);
360+
if (!value.isNumber()) {
361+
return defaultValue;
362+
}
363+
364+
return value.getNumericValue<T>();
365+
}
350366

351367
private:
352368
/// @brief read the "optimizer.inspectSimplePlans" section from the options

0 commit comments

Comments
 (0)
0