aboutsummaryrefslogtreecommitdiffstats
path: root/persistence
diff options
context:
space:
mode:
Diffstat (limited to 'persistence')
-rw-r--r--persistence/src/vespa/persistence/spi/id_and_timestamp.cpp20
-rw-r--r--persistence/src/vespa/persistence/spi/id_and_timestamp.h10
2 files changed, 30 insertions, 0 deletions
diff --git a/persistence/src/vespa/persistence/spi/id_and_timestamp.cpp b/persistence/src/vespa/persistence/spi/id_and_timestamp.cpp
index fba45990744..03eaf7c9e6e 100644
--- a/persistence/src/vespa/persistence/spi/id_and_timestamp.cpp
+++ b/persistence/src/vespa/persistence/spi/id_and_timestamp.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "id_and_timestamp.h"
+#include <vespa/vespalib/stllike/asciistream.h>
namespace storage::spi {
@@ -14,4 +15,23 @@ IdAndTimestamp& IdAndTimestamp::operator=(const IdAndTimestamp&) = default;
IdAndTimestamp::IdAndTimestamp(IdAndTimestamp&&) noexcept = default;
IdAndTimestamp& IdAndTimestamp::operator=(IdAndTimestamp&&) noexcept = default;
+void IdAndTimestamp::print(vespalib::asciistream& os) const {
+ os << id.toString() << " at time " << timestamp.getValue();
+}
+
+vespalib::string IdAndTimestamp::to_string() const {
+ vespalib::asciistream os;
+ print(os);
+ return os.str();
+}
+
+vespalib::asciistream& operator<<(vespalib::asciistream& os, const IdAndTimestamp& id_ts) {
+ id_ts.print(os);
+ return os;
+}
+std::ostream& operator<<(std::ostream& os, const IdAndTimestamp& id_ts) {
+ os << id_ts.to_string();
+ return os;
+}
+
}
diff --git a/persistence/src/vespa/persistence/spi/id_and_timestamp.h b/persistence/src/vespa/persistence/spi/id_and_timestamp.h
index d8cdba3d063..a45cbfcf5eb 100644
--- a/persistence/src/vespa/persistence/spi/id_and_timestamp.h
+++ b/persistence/src/vespa/persistence/spi/id_and_timestamp.h
@@ -3,6 +3,10 @@
#include "types.h"
#include <vespa/document/base/documentid.h>
+#include <vespa/vespalib/stllike/string.h>
+#include <iosfwd>
+
+namespace vespalib { class asciistream; }
namespace storage::spi {
@@ -27,6 +31,9 @@ struct IdAndTimestamp {
return ((id == rhs.id) && (timestamp == rhs.timestamp));
}
+ void print(vespalib::asciistream&) const;
+ vespalib::string to_string() const;
+
struct hash {
size_t operator()(const IdAndTimestamp& id_ts) const noexcept {
const size_t h = document::GlobalId::hash()(id_ts.id.getGlobalId());
@@ -35,4 +42,7 @@ struct IdAndTimestamp {
};
};
+vespalib::asciistream& operator<<(vespalib::asciistream&, const IdAndTimestamp&);
+std::ostream& operator<<(std::ostream&, const IdAndTimestamp&);
+
}