summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 18:22:49 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 18:22:49 +0000
commit00894143c792c8e63ec3c161f8733fef86c501e1 (patch)
tree4a9dd166098dc990affd07a403afdc1b9b499cd9 /searchlib
parentec90577f70dab04c7d20132559ce77adfc80a1c8 (diff)
Add typesafe SteadyTimeStamp.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp2
-rw-r--r--searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp6
-rw-r--r--searchlib/src/tests/sortspec/multilevelsort.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/aggregation/grouping.h35
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h30
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.h8
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.h16
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h6
10 files changed, 56 insertions, 61 deletions
diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
index 46af181c26b..8f22ab87c97 100644
--- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
+++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
@@ -277,7 +277,7 @@ Test::Main()
LOG(info, "sizeof(CountAggregationResult) = %ld", sizeof(CountAggregationResult));
LOG(info, "sizeof(Int64ResultNode) = %ld", sizeof(Int64ResultNode));
- fastos::TimeStamp start(fastos::ClockSteady::now());
+ fastos::SteadyTimeStamp start(fastos::ClockSteady::now());
if (idType == "int") {
if (aggrType == "sum") {
benchmarkIntegerSum(useEngine, numDocs, numQueries, maxGroups);
diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp
index f5ce8a9608b..bf1b5352778 100644
--- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp
+++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp
@@ -170,7 +170,7 @@ public:
};
PhraseSearchTest::PhraseSearchTest(bool expiredDoom)
- : _requestContext(nullptr, expiredDoom ? 0 : std::numeric_limits<int64_t>::max()),
+ : _requestContext(nullptr, expiredDoom ? fastos::SteadyTimeStamp::ZERO : fastos::SteadyTimeStamp::FUTURE),
_index(),
_phrase_fs(field, fieldId, phrase_handle),
_phrase(_phrase_fs, _requestContext, false),
@@ -199,7 +199,7 @@ void Test::requireThatIteratorHonorsFutureDoom() {
test.fetchPostings(false);
vespalib::Clock clock;
- vespalib::Doom futureDoom(clock, std::numeric_limits<int64_t>::max());
+ vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::FUTURE);
unique_ptr<SearchIterator> search(test.createSearch(false));
static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom);
EXPECT_TRUE(!search->seek(1u));
@@ -213,7 +213,7 @@ void Test::requireThatIteratorHonorsDoom() {
test.fetchPostings(false);
vespalib::Clock clock;
- vespalib::Doom futureDoom(clock, 0);
+ vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::ZERO);
unique_ptr<SearchIterator> search(test.createSearch(false));
static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom);
EXPECT_TRUE(!search->seek(1u));
diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp
index 84f67a041b0..65c4cd7da95 100644
--- a/searchlib/src/tests/sortspec/multilevelsort.cpp
+++ b/searchlib/src/tests/sortspec/multilevelsort.cpp
@@ -241,7 +241,7 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num,
}
vespalib::Clock clock;
- vespalib::Doom doom(clock, std::numeric_limits<fastos::TimeStamp::TimeT>::max());
+ vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE);
search::uca::UcaConverterFactory ucaFactory;
FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod);
// init sorter with sort data
@@ -399,7 +399,7 @@ TEST("require that all sort methods behave the same")
TEST("test that [docid] translates to [lid][paritionid]") {
vespalib::Clock clock;
- vespalib::Doom doom(clock, fastos::ClockSystem::now() + fastos::TimeStamp::SEC*10);
+ vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE);
search::uca::UcaConverterFactory ucaFactory;
FastS_SortSpec asc(7, doom, ucaFactory);
RankedHit hits[2] = {RankedHit(91, 0.0), RankedHit(3, 2.0)};
diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.h b/searchlib/src/vespa/searchlib/aggregation/grouping.h
index 1d71eb0c0aa..4230bd777d6 100644
--- a/searchlib/src/vespa/searchlib/aggregation/grouping.h
+++ b/searchlib/src/vespa/searchlib/aggregation/grouping.h
@@ -6,11 +6,11 @@
#include <vespa/vespalib/util/clock.h>
namespace search {
+ class BitVector;
+ struct IDocumentMetaStore;
+}
-class BitVector;
-struct IDocumentMetaStore;
-
-namespace aggregation {
+namespace search::aggregation {
/**
* This class represents a top-level grouping request.
@@ -22,18 +22,18 @@ public:
typedef std::unique_ptr<Grouping> UP;
private:
- uint32_t _id; // client id for this grouping
- bool _valid; // is this grouping object valid?
- bool _all; // if true, group all document, not just hits (streaming only)
- int64_t _topN; // hits to process per search node
- uint32_t _firstLevel; // first processing level this iteration (levels before considered frozen)
- uint32_t _lastLevel; // last processing level this iteration
- GroupingLevelList _levels; // grouping parameters per level
- Group _root; // the grouping tree
- const vespalib::Clock *_clock; // An optional clock to be used for timeout handling.
- fastos::TimeStamp _timeOfDoom; // Used if clock is specified. This is time when request expires.
+ uint32_t _id; // client id for this grouping
+ bool _valid; // is this grouping object valid?
+ bool _all; // if true, group all document, not just hits (streaming only)
+ int64_t _topN; // hits to process per search node
+ uint32_t _firstLevel; // first processing level this iteration (levels before considered frozen)
+ uint32_t _lastLevel; // last processing level this iteration
+ GroupingLevelList _levels; // grouping parameters per level
+ Group _root; // the grouping tree
+ const vespalib::Clock *_clock; // An optional clock to be used for timeout handling.
+ fastos::SteadyTimeStamp _timeOfDoom; // Used if clock is specified. This is time when request expires.
- bool hasExpired() const { return _clock->getTimeNS() >= _timeOfDoom; }
+ bool hasExpired() const { return _clock->getTimeNS() > _timeOfDoom; }
void aggregateWithoutClock(const RankedHit * rankedHit, unsigned int len);
void aggregateWithClock(const RankedHit * rankedHit, unsigned int len);
void postProcess();
@@ -46,7 +46,7 @@ public:
Grouping & operator = (const Grouping &);
Grouping(Grouping &&) = default;
Grouping & operator = (Grouping &&) = default;
- ~Grouping();
+ ~Grouping() override;
Grouping unchain() const { return *this; }
@@ -59,7 +59,7 @@ public:
Grouping &addLevel(GroupingLevel && level) { _levels.push_back(std::move(level)); return *this; }
Grouping &setRoot(const Group &root_) { _root = root_; return *this; }
Grouping &setClock(const vespalib::Clock * clock) { _clock = clock; return *this; }
- Grouping &setTimeOfDoom(fastos::TimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; }
+ Grouping &setTimeOfDoom(fastos::SteadyTimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; }
unsigned int getId() const { return _id; }
bool valid() const { return _valid; }
@@ -97,4 +97,3 @@ public:
};
}
-}
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index 286f4cfc36c..99fd5a88e48 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -572,22 +572,22 @@ private:
LoadedBufferUP loadFile(const char *suffix);
- BaseName _baseFileName;
- Config _config;
+ BaseName _baseFileName;
+ Config _config;
std::shared_ptr<attribute::Interlock> _interlock;
- mutable std::shared_timed_mutex _enumLock;
- GenerationHandler _genHandler;
- GenerationHolder _genHolder;
- Status _status;
- int _highestValueCount;
- uint32_t _enumMax;
- uint32_t _committedDocIdLimit; // docid limit for search
- uint32_t _uncommittedDocIdLimit; // based on queued changes
- uint64_t _createSerialNum;
- uint64_t _compactLidSpaceGeneration;
- bool _hasEnum;
- bool _loaded;
- fastos::TimeStamp _nextStatUpdateTime;
+ mutable std::shared_timed_mutex _enumLock;
+ GenerationHandler _genHandler;
+ GenerationHolder _genHolder;
+ Status _status;
+ int _highestValueCount;
+ uint32_t _enumMax;
+ uint32_t _committedDocIdLimit; // docid limit for search
+ uint32_t _uncommittedDocIdLimit; // based on queued changes
+ uint64_t _createSerialNum;
+ uint64_t _compactLidSpaceGeneration;
+ bool _hasEnum;
+ bool _loaded;
+ fastos::SteadyTimeStamp _nextStatUpdateTime;
////// Locking strategy interface. only available from the Guards.
/**
diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h
index a021ec6bfaa..4f4bf526920 100644
--- a/searchlib/src/vespa/searchlib/engine/request.h
+++ b/searchlib/src/vespa/searchlib/engine/request.h
@@ -16,8 +16,8 @@ public:
Request & operator =(const Request &) = delete;
virtual ~Request();
void setTimeout(const fastos::TimeStamp & timeout);
- fastos::TimeStamp getStartTime() const { return _relativeTime.timeOfDawn(); }
- fastos::TimeStamp getTimeOfDoom() const { return _timeOfDoom; }
+ fastos::SteadyTimeStamp getStartTime() const { return _relativeTime.timeOfDawn(); }
+ fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; }
fastos::TimeStamp getTimeout() const { return _timeOfDoom - getStartTime(); }
fastos::TimeStamp getTimeUsed() const;
fastos::TimeStamp getTimeLeft() const;
@@ -37,8 +37,8 @@ public:
Trace & trace() const { return _trace; }
private:
- RelativeTime _relativeTime;
- fastos::TimeStamp _timeOfDoom;
+ RelativeTime _relativeTime;
+ fastos::SteadyTimeStamp _timeOfDoom;
public:
/// Everything here should move up to private section and have accessors
bool dumpFeatures;
diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp
index 576b8dc92a5..ae0c6810ca1 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.cpp
+++ b/searchlib/src/vespa/searchlib/engine/trace.cpp
@@ -5,7 +5,7 @@
namespace search::engine {
-fastos::TimeStamp
+fastos::SteadyTimeStamp
SteadyClock::now() const {
return fastos::ClockSteady::now();
}
@@ -38,7 +38,7 @@ Trace::Trace(const RelativeTime & relativeTime, uint32_t level)
void
Trace::start(int level) {
if (shouldTrace(level) && !hasTrace()) {
- root().setString("start_time_utc", _relativeTime.timeOfDawn().toString());
+ root().setString("start_time_relative", _relativeTime.timeOfDawn().toString());
}
}
diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h
index f2b67d02df8..0d7dc2982f1 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.h
+++ b/searchlib/src/vespa/searchlib/engine/trace.h
@@ -13,21 +13,21 @@ namespace search::engine {
class Clock {
public:
virtual ~Clock() = default;
- virtual fastos::TimeStamp now() const = 0;
+ virtual fastos::SteadyTimeStamp now() const = 0;
};
class SteadyClock : public Clock {
public:
- fastos::TimeStamp now() const override;
+ fastos::SteadyTimeStamp now() const override;
};
class CountingClock : public Clock {
public:
CountingClock(int64_t start, int64_t increment) : _increment(increment), _nextTime(start) { }
- fastos::TimeStamp now() const override {
+ fastos::SteadyTimeStamp now() const override {
int64_t prev = _nextTime;
_nextTime += _increment;
- return prev;
+ return fastos::SteadyTimeStamp(prev);
}
private:
const int64_t _increment;
@@ -37,12 +37,12 @@ private:
class RelativeTime {
public:
RelativeTime(std::unique_ptr<Clock> clock);
- fastos::TimeStamp timeOfDawn() const { return _start; }
+ fastos::SteadyTimeStamp timeOfDawn() const { return _start; }
fastos::TimeStamp timeSinceDawn() const { return _clock->now() - _start; }
- fastos::TimeStamp now() const { return _clock->now(); }
+ fastos::SteadyTimeStamp now() const { return _clock->now(); }
private:
- fastos::TimeStamp _start;
- std::unique_ptr<Clock> _clock;
+ fastos::SteadyTimeStamp _start;
+ std::unique_ptr<Clock> _clock;
};
/**
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
index 456d1919430..7d82fa706ca 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
@@ -2,14 +2,12 @@
#include <vespa/searchlib/queryeval/fake_requestcontext.h>
-namespace search {
-namespace queryeval {
+namespace search::queryeval {
-FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::TimeStamp doom_in) :
+FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::SteadyTimeStamp doom_in) :
_clock(),
_doom(_clock, doom_in),
_attributeContext(context)
{ }
}
-}
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
index d31cc9a7f9d..fefa7f5b6ff 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
@@ -7,13 +7,12 @@
#include <vespa/searchlib/attribute/attributevector.h>
#include <limits>
-namespace search {
-namespace queryeval {
+namespace search::queryeval {
class FakeRequestContext : public IRequestContext
{
public:
- FakeRequestContext(attribute::IAttributeContext * context = nullptr, fastos::TimeStamp doom=std::numeric_limits<int64_t>::max());
+ FakeRequestContext(attribute::IAttributeContext * context = nullptr, fastos::SteadyTimeStamp doom=fastos::SteadyTimeStamp(fastos::TimeStamp::FUTURE));
const vespalib::Doom & getSoftDoom() const override { return _doom; }
const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override {
return _attributeContext
@@ -32,4 +31,3 @@ private:
};
}
-}