diff options
Diffstat (limited to 'document')
4 files changed, 26 insertions, 79 deletions
diff --git a/document/src/main/java/com/yahoo/document/json/SingleDocumentParser.java b/document/src/main/java/com/yahoo/document/json/SingleDocumentParser.java deleted file mode 100644 index 67508c61b23..00000000000 --- a/document/src/main/java/com/yahoo/document/json/SingleDocumentParser.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.document.json; - -import com.fasterxml.jackson.core.JsonFactory; -import com.yahoo.document.DocumentOperation; -import com.yahoo.document.DocumentPut; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.DocumentUpdate; -import com.yahoo.vespaxmlparser.DocumentFeedOperation; -import com.yahoo.vespaxmlparser.DocumentUpdateFeedOperation; -import com.yahoo.vespaxmlparser.FeedOperation; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Parser that supports parsing PUT operation and UPDATE operation. - * - * @author dybis - */ -public class SingleDocumentParser { - - private static final JsonFactory jsonFactory = new JsonFactory().disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES); - private DocumentTypeManager docMan; - - public SingleDocumentParser(DocumentTypeManager docMan) { - this.docMan = docMan; - } - - public FeedOperation parsePut(InputStream inputStream, String docId) { - return parse(inputStream, docId, DocumentOperationType.PUT); - } - - public FeedOperation parseUpdate(InputStream inputStream, String docId) { - return parse(inputStream, docId, DocumentOperationType.UPDATE); - } - - private FeedOperation parse(InputStream inputStream, String docId, DocumentOperationType documentOperationType) { - JsonReader reader = new JsonReader(docMan, inputStream, jsonFactory); - DocumentOperation documentOperation = reader.readSingleDocument(documentOperationType, docId); - try { - inputStream.close(); - } catch (IOException e) { - throw new IllegalStateException(e); - } - if (documentOperationType == DocumentOperationType.PUT) { - return new DocumentFeedOperation(((DocumentPut) documentOperation).getDocument(), documentOperation.getCondition()); - } else { - return new DocumentUpdateFeedOperation((DocumentUpdate) documentOperation, documentOperation.getCondition()); - } - } - -} diff --git a/document/src/vespa/document/bucket/bucket.h b/document/src/vespa/document/bucket/bucket.h index 44068e1c443..f189c2951c9 100644 --- a/document/src/vespa/document/bucket/bucket.h +++ b/document/src/vespa/document/bucket/bucket.h @@ -32,7 +32,7 @@ public: vespalib::string toString() const; struct hash { - size_t operator () (const Bucket& b) const { + size_t operator () (const Bucket& b) const noexcept { size_t hash1 = BucketId::hash()(b.getBucketId()); size_t hash2 = BucketSpace::hash()(b.getBucketSpace()); // Formula taken from std::hash_combine proposal diff --git a/document/src/vespa/document/bucket/bucketid.cpp b/document/src/vespa/document/bucket/bucketid.cpp index 668798d6c39..1b9cf1e5304 100644 --- a/document/src/vespa/document/bucket/bucketid.cpp +++ b/document/src/vespa/document/bucket/bucketid.cpp @@ -71,7 +71,7 @@ Initialize _initializeUsedMasks; } -void BucketId::initialize() { +void BucketId::initialize() noexcept { fillUsedMasks(BucketId::_usedMasks, BucketId::maxNumBits); fillStripMasks(BucketId::_stripMasks, BucketId::maxNumBits); } @@ -91,7 +91,7 @@ void BucketId::throwFailedSetUsedBits(uint32_t used, uint32_t availBits) { } BucketId::Type -BucketId::reverse(Type id) +BucketId::reverse(Type id) noexcept { id = ((id & 0x5555555555555555l) << 1) | ((id & 0xaaaaaaaaaaaaaaaal) >> 1); id = ((id & 0x3333333333333333l) << 2) | ((id & 0xccccccccccccccccl) >> 2); @@ -100,7 +100,7 @@ BucketId::reverse(Type id) } BucketId::Type -BucketId::keyToBucketId(Type key) +BucketId::keyToBucketId(Type key) noexcept { Type retVal = reverse(key); @@ -113,7 +113,7 @@ BucketId::keyToBucketId(Type key) } bool -BucketId::contains(const BucketId& id) const +BucketId::contains(const BucketId& id) const noexcept { if (id.getUsedBits() < getUsedBits()) { return false; diff --git a/document/src/vespa/document/bucket/bucketid.h b/document/src/vespa/document/bucket/bucketid.h index b31f9080acc..675a0d23ebd 100644 --- a/document/src/vespa/document/bucket/bucketid.h +++ b/document/src/vespa/document/bucket/bucketid.h @@ -37,7 +37,7 @@ class BucketId { public: struct hash { - size_t operator () (const BucketId& g) const { + size_t operator () (const BucketId& g) const noexcept { return g.getId(); } }; @@ -55,23 +55,23 @@ public: /** Create a bucket id using a set of bits from a raw unchecked value. */ BucketId(uint32_t useBits, Type id) noexcept : _id(createUsedBits(useBits, id)) { } - bool operator<(const BucketId& id) const { + bool operator<(const BucketId& id) const noexcept { return getId() < id.getId(); } - bool operator==(const BucketId& id) const { return getId() == id.getId(); } - bool operator!=(const BucketId& id) const { return getId() != id.getId(); } + bool operator==(const BucketId& id) const noexcept { return getId() == id.getId(); } + bool operator!=(const BucketId& id) const noexcept { return getId() != id.getId(); } vespalib::string toString() const; - bool valid() const { + bool valid() const noexcept { return validUsedBits(getUsedBits()); } - static bool validUsedBits(uint32_t usedBits) { + static bool validUsedBits(uint32_t usedBits) noexcept { return (usedBits >= minNumBits) && (usedBits <= maxNumBits); } - bool isSet() const { + bool isSet() const noexcept { return _id != 0u; } /** @@ -79,14 +79,14 @@ public: * verify that two different documents belong to the same bucket given some * level of bucket splitting, use this to ignore the unused bits. */ - BucketId stripUnused() const { return BucketId(getUsedBits(), getId()); } + BucketId stripUnused() const noexcept { return BucketId(getUsedBits(), getId()); } /** * Checks whether the given bucket is contained within this bucket. That is, * if it is the same bucket, or if it is a bucket using more bits, which is * identical to this one if set to use as many bits as this one. */ - bool contains(const BucketId& id) const; + bool contains(const BucketId& id) const noexcept; // Functions exposing internals we want to make users independent of @@ -97,7 +97,7 @@ public: static constexpr uint32_t maxNumBits = (8 * sizeof(Type) - CountBits); static constexpr uint32_t minNumBits = 1u; // See comment above. - uint32_t getUsedBits() const { return _id >> maxNumBits; } + uint32_t getUsedBits() const noexcept { return _id >> maxNumBits; } void setUsedBits(uint32_t used) { uint32_t availBits = maxNumBits; @@ -113,22 +113,22 @@ public: } /** Get the bucket id value stripped of the bits that are not in use. */ - Type getId() const { return (_id & getStripMask()); } + Type getId() const noexcept { return (_id & getStripMask()); } /** * Get the bucket id value stripped of the count bits plus the bits that * are not in use. */ - Type withoutCountBits() const { return (_id & getUsedMask()); } + Type withoutCountBits() const noexcept { return (_id & getUsedMask()); } - Type getRawId() const { return _id; } + Type getRawId() const noexcept { return _id; } /** * Reverses the bits in the given number, except the countbits part. * Used for sorting in the bucket database as we want related buckets * to be sorted next to each other. */ - static Type bucketIdToKey(Type id) { + static Type bucketIdToKey(Type id) noexcept { Type retVal = reverse(id); Type usedCountLSB = id >> maxNumBits; @@ -139,39 +139,39 @@ public: return retVal; } - static Type keyToBucketId(Type key); + static Type keyToBucketId(Type key) noexcept ; /** * Reverses the bucket id bitwise, except the countbits part, * and returns the value, */ - Type toKey() const { return bucketIdToKey(getId()); }; + Type toKey() const noexcept { return bucketIdToKey(getId()); }; /** * Reverses the order of the bits in the bucket id. */ - static Type reverse(Type id); + static Type reverse(Type id) noexcept; /** * Returns the value of the Nth bit, counted in the reverse order of the * bucket id. */ - uint8_t getBit(uint32_t n) const { + uint8_t getBit(uint32_t n) const noexcept { return (_id & ((Type)1 << n)) == 0 ? 0 : 1; } - static void initialize(); + static void initialize() noexcept; private: static Type _usedMasks[maxNumBits+1]; static Type _stripMasks[maxNumBits+1]; Type _id; - Type getUsedMask() const { + Type getUsedMask() const noexcept { return _usedMasks[getUsedBits()]; } - Type getStripMask() const { + Type getStripMask() const noexcept { return _stripMasks[getUsedBits()]; } |