diff options
27 files changed, 136 insertions, 121 deletions
diff --git a/document/src/vespa/document/annotation/annotation.cpp b/document/src/vespa/document/annotation/annotation.cpp index f978732f366..86628741816 100644 --- a/document/src/vespa/document/annotation/annotation.cpp +++ b/document/src/vespa/document/annotation/annotation.cpp @@ -30,4 +30,12 @@ Annotation::toString() const { return os.str(); } +bool +Annotation::operator==(const Annotation &a2) const { + return (getType() == a2.getType() && + !(!!getFieldValue() ^ !!a2.getFieldValue()) && + (!getFieldValue() || (*getFieldValue() == *a2.getFieldValue())) + ); +} + } // namespace document diff --git a/document/src/vespa/document/annotation/annotation.h b/document/src/vespa/document/annotation/annotation.h index 6f64df1227e..8f1c6962d01 100644 --- a/document/src/vespa/document/annotation/annotation.h +++ b/document/src/vespa/document/annotation/annotation.h @@ -29,6 +29,8 @@ public: void setSpanNode(const SpanNode &node) { _node = &node; } template <typename T> void setFieldValue(std::unique_ptr<T> value) { _value.reset(value.release()); } + bool operator==(const Annotation &a2) const; + const SpanNode *getSpanNode() const { return _node; } const AnnotationType &getType() const { return *_type; } @@ -38,14 +40,6 @@ public: vespalib::string toString() const; }; -inline bool operator==(const Annotation &a1, const Annotation &a2) { - return (a1.getType() == a2.getType() && - !(!!a1.getFieldValue() ^ !!a2.getFieldValue()) && - (!a1.getFieldValue() || - (*a1.getFieldValue() == *a2.getFieldValue())) - ); -} - std::ostream & operator << (std::ostream & os, const Annotation & span); } // namespace document diff --git a/document/src/vespa/document/datatype/annotationtype.h b/document/src/vespa/document/datatype/annotationtype.h index ba0c3519ba2..860c132196d 100644 --- a/document/src/vespa/document/datatype/annotationtype.h +++ b/document/src/vespa/document/datatype/annotationtype.h @@ -39,11 +39,5 @@ public: static std::vector<const AnnotationType *> getDefaultAnnotationTypes(); }; -#if 0 -inline std::ostream &operator<<(std::ostream &out, const AnnotationType &a) { - return out << "AnnotationType(" << a.getId() << ", " << a.getName() << ")"; -} -#endif - } // namespace document diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.cpp b/document/src/vespa/document/fieldvalue/fieldvalue.cpp index f0738f9eb72..dc343ee0128 100644 --- a/document/src/vespa/document/fieldvalue/fieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/fieldvalue.cpp @@ -269,7 +269,17 @@ FieldValue::createArray(const DataType & baseType) } } +bool operator != (const FieldValue::LP & a, const FieldValue::LP & b) { return *a != *b; } +bool operator < (const FieldValue::LP & a, const FieldValue::LP & b) { return *a < *b; } +std::ostream& operator<<(std::ostream& out, const FieldValue & p) { + p.print(out); + return out; +} +XmlOutputStream & operator<<(XmlOutputStream & out, const FieldValue & p) { + p.printXml(out); + return out; +} } // document diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.h b/document/src/vespa/document/fieldvalue/fieldvalue.h index dc79743d7e7..34d77364d85 100644 --- a/document/src/vespa/document/fieldvalue/fieldvalue.h +++ b/document/src/vespa/document/fieldvalue/fieldvalue.h @@ -318,19 +318,12 @@ private: IteratorHandler & handler) const; }; -inline bool operator != (const FieldValue::LP & a, const FieldValue::LP & b) { return *a != *b; } -inline bool operator < (const FieldValue::LP & a, const FieldValue::LP & b) { return *a < *b; } +bool operator != (const FieldValue::LP & a, const FieldValue::LP & b); +bool operator < (const FieldValue::LP & a, const FieldValue::LP & b); -inline std::ostream& operator<<(std::ostream& out, const FieldValue & p) { - p.print(out); - return out; -} - -inline XmlOutputStream & operator<<(XmlOutputStream & out, const FieldValue & p) { - p.printXml(out); - return out; -} +std::ostream& operator<<(std::ostream& out, const FieldValue & p); +XmlOutputStream & operator<<(XmlOutputStream & out, const FieldValue & p); } // document diff --git a/document/src/vespa/document/select/orderingspecification.cpp b/document/src/vespa/document/select/orderingspecification.cpp index f42c057de25..7188c339beb 100644 --- a/document/src/vespa/document/select/orderingspecification.cpp +++ b/document/src/vespa/document/select/orderingspecification.cpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include "orderingspecification.h" -#include <sstream> +#include <vespa/vespalib/stllike/asciistream.h> namespace document { @@ -10,11 +10,18 @@ OrderingSpecification::operator==(const OrderingSpecification& other) const { return _order == other._order && _orderingStart == other._orderingStart && _widthBits == other._widthBits && _divisionBits == other._divisionBits; } -std::string +vespalib::string OrderingSpecification::toString() const { - std::ostringstream ost; + vespalib::asciistream ost; ost << (_order == ASCENDING ? "+" : "-") << "," << _widthBits << "," << _divisionBits << "," << _orderingStart; return ost.str(); } +std::ostream& +operator<<(std::ostream& out, const OrderingSpecification& o) +{ + out << o.toString(); + return out; +} + } diff --git a/document/src/vespa/document/select/orderingspecification.h b/document/src/vespa/document/select/orderingspecification.h index 0fa64862fa0..1d7ea84f86e 100644 --- a/document/src/vespa/document/select/orderingspecification.h +++ b/document/src/vespa/document/select/orderingspecification.h @@ -2,7 +2,7 @@ #pragma once #include <vespa/fastos/types.h> -#include <string> +#include <vespa/vespalib/stllike/string.h> namespace document { @@ -28,7 +28,7 @@ public: bool operator==(const OrderingSpecification& other) const; - std::string toString() const; + vespalib::string toString() const; private: Order _order; @@ -37,11 +37,7 @@ private: uint16_t _divisionBits; }; -inline std::ostream& -operator<<(std::ostream& out, const OrderingSpecification& o) -{ - out << o.toString(); - return out; -} -} +std::ostream& +operator<<(std::ostream& out, const OrderingSpecification& o); +} diff --git a/persistence/src/vespa/persistence/spi/bucket.cpp b/persistence/src/vespa/persistence/spi/bucket.cpp index 423ffdd496c..d055f0eef59 100644 --- a/persistence/src/vespa/persistence/spi/bucket.cpp +++ b/persistence/src/vespa/persistence/spi/bucket.cpp @@ -7,21 +7,27 @@ namespace storage { namespace spi { -std::string Bucket::toString() const { - std::ostringstream ost; - print(ost); +vespalib::string +Bucket::toString() const { + vespalib::asciistream ost; + ost << *this; return ost.str(); } -void -Bucket::print(std::ostream& out) const +vespalib::asciistream& +operator<<(vespalib::asciistream& os, const Bucket& bucket) { - out << "Bucket(0x" - << std::hex << std::setw(sizeof(document::BucketId::Type) * 2) - << std::setfill('0') << _bucket.getId() - << std::dec - << ", partition " << _partition - << ")"; + return os << "BucketId(0x" + << vespalib::hex << vespalib::setw(sizeof(document::BucketId::Type)*2) << vespalib::setfill('0') + << bucket.getBucketId() + << std::dec + << ", partition " << bucket.getPartition() + << ")"; +} + +std::ostream& +operator<<(std::ostream& os, const Bucket& bucket) { + return os << bucket.toString(); } } // spi diff --git a/persistence/src/vespa/persistence/spi/bucket.h b/persistence/src/vespa/persistence/spi/bucket.h index dc9419bbdae..b969f6363bf 100644 --- a/persistence/src/vespa/persistence/spi/bucket.h +++ b/persistence/src/vespa/persistence/spi/bucket.h @@ -38,15 +38,11 @@ public: return (_bucket == o._bucket && _partition == o._partition); } - void print(std::ostream& out) const; - - std::string toString() const; + vespalib::string toString() const; }; -inline std::ostream& operator<<(std::ostream& out, const Bucket& bucket) { - bucket.print(out); - return out; -} +vespalib::asciistream& operator<<(vespalib::asciistream& out, const Bucket& bucket); +std::ostream& operator<<(std::ostream& out, const Bucket& bucket); } // spi } // storage diff --git a/persistence/src/vespa/persistence/spi/bucketinfo.cpp b/persistence/src/vespa/persistence/spi/bucketinfo.cpp index 4637b5b598b..3b298cfc2b2 100644 --- a/persistence/src/vespa/persistence/spi/bucketinfo.cpp +++ b/persistence/src/vespa/persistence/spi/bucketinfo.cpp @@ -46,9 +46,9 @@ BucketInfo::operator==(const BucketInfo& o) const && _active == o._active); } -void -BucketInfo::print(std::ostream& out) const -{ +vespalib::string +BucketInfo::toString() const { + vespalib::asciistream out; out << "BucketInfo("; out << "crc 0x" << std::hex << _checksum << std::dec << ", documentCount " << _documentCount; @@ -62,13 +62,15 @@ BucketInfo::print(std::ostream& out) const out << ", ready " << (_ready ? "true" : "false") << ", active " << (_active ? "true" : "false"); out << ")"; + return out.str(); } -std::string -BucketInfo::toString() const { - std::ostringstream ost; - print(ost); - return ost.str(); +vespalib::asciistream& operator<<(vespalib::asciistream& out, const BucketInfo& info) { + return out << info.toString(); +} + +std::ostream& operator<<(std::ostream& out, const BucketInfo& info) { + return out << info.toString(); } } // spi diff --git a/persistence/src/vespa/persistence/spi/bucketinfo.h b/persistence/src/vespa/persistence/spi/bucketinfo.h index fe6a95661fc..b4019c3c6cf 100644 --- a/persistence/src/vespa/persistence/spi/bucketinfo.h +++ b/persistence/src/vespa/persistence/spi/bucketinfo.h @@ -37,7 +37,7 @@ public: bool operator==(const BucketInfo& o) const; void print(std::ostream& out) const; - std::string toString() const; + vespalib::string toString() const; /** * Get the checksum of the bucket. An empty bucket should have checksum of @@ -99,10 +99,8 @@ private: ActiveState _active; }; -inline std::ostream& operator<<(std::ostream& out, const BucketInfo& info) { - info.print(out); - return out; -} +vespalib::asciistream& operator<<(vespalib::asciistream& out, const BucketInfo& info); +std::ostream& operator<<(std::ostream& out, const BucketInfo& info); } // spi } // storage diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp index a9f6a85892b..45e5a860d14 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp @@ -309,4 +309,10 @@ BucketInfo::operator==(const BucketInfo& other) const return true; }; +std::ostream& +operator<<(std::ostream& out, const BucketInfo& info) { + info.print(out, false, ""); + return out; +} + } diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.h b/storage/src/vespa/storage/bucketdb/bucketinfo.h index 1b220282cf0..f7b52640de9 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.h +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.h @@ -169,8 +169,7 @@ private: void addNodeManual(const BucketCopy& newCopy) { _nodes.push_back(newCopy); } }; -inline std::ostream& operator<<(std::ostream& out, const BucketInfo& info) - { info.print(out, false, ""); return out; } +std::ostream& operator<<(std::ostream& out, const BucketInfo& info); } diff --git a/storage/src/vespa/storage/bucketdb/storbucketdb.cpp b/storage/src/vespa/storage/bucketdb/storbucketdb.cpp index 15700ae4ce2..4cc535be9de 100644 --- a/storage/src/vespa/storage/bucketdb/storbucketdb.cpp +++ b/storage/src/vespa/storage/bucketdb/storbucketdb.cpp @@ -26,6 +26,12 @@ bool StorageBucketInfo::operator < (const StorageBucketInfo & b) const { return disk < b.disk; } +std::ostream& +operator<<(std::ostream& out, const StorageBucketInfo& info) { + info.print(out, false, ""); + return out; +} + } // bucketdb void diff --git a/storage/src/vespa/storage/bucketdb/storbucketdb.h b/storage/src/vespa/storage/bucketdb/storbucketdb.h index 759528c6d67..e6f2b3aded2 100644 --- a/storage/src/vespa/storage/bucketdb/storbucketdb.h +++ b/storage/src/vespa/storage/bucketdb/storbucketdb.h @@ -48,9 +48,7 @@ struct StorageBucketInfo { bool operator < (const StorageBucketInfo & b) const; }; -inline std::ostream& operator<<(std::ostream& out, - const StorageBucketInfo& info) - { info.print(out, false, ""); return out; } +std::ostream& operator<<(std::ostream& out, const StorageBucketInfo& info); } // bucketdb diff --git a/storage/src/vespa/storage/common/storagelink.cpp b/storage/src/vespa/storage/common/storagelink.cpp index 23fbf477fd2..ddeecd1e0ed 100644 --- a/storage/src/vespa/storage/common/storagelink.cpp +++ b/storage/src/vespa/storage/common/storagelink.cpp @@ -304,3 +304,9 @@ StorageLink::stateToString(State state) return 0; } } + +std::ostream& operator<<(std::ostream& out, StorageLink& link) { + link.printChain(out); + return out; +} + diff --git a/storage/src/vespa/storage/common/storagelink.h b/storage/src/vespa/storage/common/storagelink.h index 5a683d55b03..d4cdb95a327 100644 --- a/storage/src/vespa/storage/common/storagelink.h +++ b/storage/src/vespa/storage/common/storagelink.h @@ -186,10 +186,7 @@ private: friend class StorageLinkTest; }; -inline std::ostream& operator<<(std::ostream& out, StorageLink& link) { - link.printChain(out); - return out; -} +std::ostream& operator<<(std::ostream& out, StorageLink& link); } diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp index 08057039cb1..faeae1c79fb 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.cpp +++ b/storageapi/src/vespa/storageapi/message/bucket.cpp @@ -134,6 +134,11 @@ MergeBucketCommand::print(std::ostream& out, bool verbose, } } +std::ostream& +operator<<(std::ostream& out, const MergeBucketCommand::Node& n) { + return out << n.index << (n.sourceOnly ? " (source only)" : ""); +} + MergeBucketReply::MergeBucketReply(const MergeBucketCommand& cmd) : BucketReply(cmd), _nodes(cmd.getNodes()), diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h index b47aa01c63e..7f5ba157d3d 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.h +++ b/storageapi/src/vespa/storageapi/message/bucket.h @@ -152,10 +152,8 @@ public: DECLARE_STORAGECOMMAND(MergeBucketCommand, onMergeBucket) }; -inline std::ostream& -operator<<(std::ostream& out, const MergeBucketCommand::Node& n) { - return out << n.index << (n.sourceOnly ? " (source only)" : ""); -} +std::ostream& +operator<<(std::ostream& out, const MergeBucketCommand::Node& n); /** * @class MergeBucketReply diff --git a/storageapi/src/vespa/storageapi/message/datagram.cpp b/storageapi/src/vespa/storageapi/message/datagram.cpp index bc0dadc3fb3..8d93bc68944 100644 --- a/storageapi/src/vespa/storageapi/message/datagram.cpp +++ b/storageapi/src/vespa/storageapi/message/datagram.cpp @@ -185,5 +185,13 @@ EmptyBucketsReply::print(std::ostream& out, bool verbose, } } +std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e) +{ + out << e._doc->getId(); + if (e._removeEntry) out << " - removed"; + out << ", last modified at " << e._lastModified; + return out; +} + } // api } // storage diff --git a/storageapi/src/vespa/storageapi/message/datagram.h b/storageapi/src/vespa/storageapi/message/datagram.h index 69563bb32f8..0af2cbd3724 100644 --- a/storageapi/src/vespa/storageapi/message/datagram.h +++ b/storageapi/src/vespa/storageapi/message/datagram.h @@ -152,14 +152,7 @@ public: }; -inline std::ostream& operator<<(std::ostream& out, - const DocumentListCommand::Entry& e) -{ - out << e._doc->getId(); - if (e._removeEntry) out << " - removed"; - out << ", last modified at " << e._lastModified; - return out; -} +std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e); /** * @class DocumentListReply diff --git a/storageapi/src/vespa/storageapi/message/stat.cpp b/storageapi/src/vespa/storageapi/message/stat.cpp index e006b95ed16..483060318b9 100644 --- a/storageapi/src/vespa/storageapi/message/stat.cpp +++ b/storageapi/src/vespa/storageapi/message/stat.cpp @@ -98,5 +98,13 @@ GetBucketListReply::print(std::ostream& out, bool verbose, } } +std::ostream& +operator<<(std::ostream& out, const GetBucketListReply::BucketInfo& instance) +{ + out << "BucketInfo(" << instance._bucket << ": " + << instance._bucketInformation << ")"; + return out; +} + } // api } // storage diff --git a/storageapi/src/vespa/storageapi/message/stat.h b/storageapi/src/vespa/storageapi/message/stat.h index dbad3e9cd7b..063aa579057 100644 --- a/storageapi/src/vespa/storageapi/message/stat.h +++ b/storageapi/src/vespa/storageapi/message/stat.h @@ -105,13 +105,7 @@ public: }; -inline std::ostream& operator<<(std::ostream& out, - const GetBucketListReply::BucketInfo& instance) -{ - out << "BucketInfo(" << instance._bucket << ": " - << instance._bucketInformation << ")"; - return out; -} +std::ostream& operator<<(std::ostream& out, const GetBucketListReply::BucketInfo& instance); } // api } // storage diff --git a/storageapi/src/vespa/storageapi/message/visitor.cpp b/storageapi/src/vespa/storageapi/message/visitor.cpp index f2ffab76326..3dee0e2e4fb 100644 --- a/storageapi/src/vespa/storageapi/message/visitor.cpp +++ b/storageapi/src/vespa/storageapi/message/visitor.cpp @@ -223,5 +223,10 @@ VisitorInfoReply::print(std::ostream& out, bool verbose, } } +std::ostream& +operator<<(std::ostream& out, const VisitorInfoCommand::BucketTimestampPair& pair) { + return out << pair.bucketId << " - " << pair.timestamp; +} + } // api } // storage diff --git a/storageapi/src/vespa/storageapi/message/visitor.h b/storageapi/src/vespa/storageapi/message/visitor.h index 10e7aa65e40..91e1278ecc4 100644 --- a/storageapi/src/vespa/storageapi/message/visitor.h +++ b/storageapi/src/vespa/storageapi/message/visitor.h @@ -113,8 +113,7 @@ public: uint32_t getMaxBucketsPerVisitor() const { return _maxBucketsPerVisitor; } - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; virtual StorageCommand::UP createCopyToForward( const document::BucketId&, uint64_t timestamp) const; @@ -136,8 +135,7 @@ private: public: explicit CreateVisitorReply(const CreateVisitorCommand& cmd); - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; void setLastBucket(const document::BucketId& lastBucket) { _lastBucket = lastBucket; } @@ -165,8 +163,7 @@ public: const vespalib::string & getInstanceId() const { return _instanceId; } - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(DestroyVisitorCommand, onDestroyVisitor) }; @@ -181,8 +178,7 @@ class DestroyVisitorReply : public StorageReply { public: explicit DestroyVisitorReply(const DestroyVisitorCommand& cmd); - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(DestroyVisitorReply, onDestroyVisitorReply) }; @@ -237,29 +233,20 @@ public: { return _bucketsCompleted; } bool visitorCompleted() const { return _completed; } - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(VisitorInfoCommand, onVisitorInfo) }; -inline std::ostream& -operator<<(std::ostream& out, - const VisitorInfoCommand::BucketTimestampPair& pair) -{ - return out << pair.bucketId << " - " << pair.timestamp; -} +std::ostream& operator<<(std::ostream& out, const VisitorInfoCommand::BucketTimestampPair& pair); class VisitorInfoReply : public StorageReply { bool _completed; public: VisitorInfoReply(const VisitorInfoCommand& cmd); - bool visitorCompleted() const { return _completed; } - - void print(std::ostream& out, bool verbose, - const std::string& indent) const; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(VisitorInfoReply, onVisitorInfoReply) }; diff --git a/vdslib/src/vespa/vdslib/container/documentlist.cpp b/vdslib/src/vespa/vdslib/container/documentlist.cpp index e17c738ea0d..10c942f3002 100644 --- a/vdslib/src/vespa/vdslib/container/documentlist.cpp +++ b/vdslib/src/vespa/vdslib/container/documentlist.cpp @@ -495,4 +495,9 @@ DocumentList::print(std::ostream& out, bool verbose, out << ")"; } +std::ostream& operator<<(std::ostream& out, const DocumentList::MetaEntry& e) { + e.print(out); + return out; +} + } // namespace vdslib diff --git a/vdslib/src/vespa/vdslib/container/documentlist.h b/vdslib/src/vespa/vdslib/container/documentlist.h index 894195bcfee..00482cf7e58 100644 --- a/vdslib/src/vespa/vdslib/container/documentlist.h +++ b/vdslib/src/vespa/vdslib/container/documentlist.h @@ -240,11 +240,7 @@ private: document::DocumentTypeRepo::SP _repo; }; -inline std::ostream& operator<<(std::ostream& out, const DocumentList::MetaEntry& e) -{ - e.print(out); - return out; -} +std::ostream& operator<<(std::ostream& out, const DocumentList::MetaEntry& e); } |