From 72231250ed81e10d66bfe70701e64fa5fe50f712 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Wed, 15 Jun 2016 23:09:44 +0200 Subject: Publish --- persistencetypes/src/.gitignore | 4 + persistencetypes/src/persistence/.gitignore | 3 + persistencetypes/src/persistence/CMakeLists.txt | 7 ++ persistencetypes/src/persistence/spi/.gitignore | 2 + .../src/persistence/spi/CMakeLists.txt | 6 ++ persistencetypes/src/persistence/spi/types.cpp | 20 ++++ persistencetypes/src/persistence/spi/types.h | 108 +++++++++++++++++++++ 7 files changed, 150 insertions(+) create mode 100644 persistencetypes/src/.gitignore create mode 100644 persistencetypes/src/persistence/.gitignore create mode 100644 persistencetypes/src/persistence/CMakeLists.txt create mode 100644 persistencetypes/src/persistence/spi/.gitignore create mode 100644 persistencetypes/src/persistence/spi/CMakeLists.txt create mode 100644 persistencetypes/src/persistence/spi/types.cpp create mode 100644 persistencetypes/src/persistence/spi/types.h (limited to 'persistencetypes/src') diff --git a/persistencetypes/src/.gitignore b/persistencetypes/src/.gitignore new file mode 100644 index 00000000000..b17e583dfac --- /dev/null +++ b/persistencetypes/src/.gitignore @@ -0,0 +1,4 @@ +/Makefile.ini +/config_command.sh +/persistencetypes.mak +/project.dsw diff --git a/persistencetypes/src/persistence/.gitignore b/persistencetypes/src/persistence/.gitignore new file mode 100644 index 00000000000..444f5c50077 --- /dev/null +++ b/persistencetypes/src/persistence/.gitignore @@ -0,0 +1,3 @@ +/.depend +/Makefile +/libpersistencetypes.so.5.1 diff --git a/persistencetypes/src/persistence/CMakeLists.txt b/persistencetypes/src/persistence/CMakeLists.txt new file mode 100644 index 00000000000..ba8d1ec3892 --- /dev/null +++ b/persistencetypes/src/persistence/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_library(persistencetypes + SOURCES + $ + INSTALL lib64 + DEPENDS +) diff --git a/persistencetypes/src/persistence/spi/.gitignore b/persistencetypes/src/persistence/spi/.gitignore new file mode 100644 index 00000000000..7e7c0fe7fae --- /dev/null +++ b/persistencetypes/src/persistence/spi/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Makefile diff --git a/persistencetypes/src/persistence/spi/CMakeLists.txt b/persistencetypes/src/persistence/spi/CMakeLists.txt new file mode 100644 index 00000000000..8b922cdce99 --- /dev/null +++ b/persistencetypes/src/persistence/spi/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_library(persistencetypes_spi OBJECT + SOURCES + types.cpp + DEPENDS +) diff --git a/persistencetypes/src/persistence/spi/types.cpp b/persistencetypes/src/persistence/spi/types.cpp new file mode 100644 index 00000000000..2219175a395 --- /dev/null +++ b/persistencetypes/src/persistence/spi/types.cpp @@ -0,0 +1,20 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include +#include "types.h" +#include + +namespace storage +{ + +namespace spi +{ + +DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(NodeIndex); +DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(PartitionId); +DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(IteratorId); +DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(Timestamp); +DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(BucketChecksum); + +} + +} diff --git a/persistencetypes/src/persistence/spi/types.h b/persistencetypes/src/persistence/spi/types.h new file mode 100644 index 00000000000..89b59782ba9 --- /dev/null +++ b/persistencetypes/src/persistence/spi/types.h @@ -0,0 +1,108 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include +#include + +namespace vespalib +{ + +class nbostream; + +} + +/** + * We create small wrapper classes for number values for the following reasons: + * - Being able to create functions taking in several of them, without risking + * caller using numbers in wrong order. + * - We can identify type by typename instead of variable name. + */ +#define DEFINE_PRIMITIVE_WRAPPER(type, name) \ + class name { \ + type _value; \ + public: \ + typedef type Type; \ + name() : _value() {} \ + explicit name(type v) : _value(v) {} \ + operator type() const { return _value; } \ + operator type&() { return _value; } \ + type getValue() const { return _value; } \ + name& operator=(type val) { _value = val; return *this; } \ + friend vespalib::nbostream & \ + operator<<(vespalib::nbostream &os, const name &wrapped); \ + friend vespalib::nbostream & \ + operator>>(vespalib::nbostream &is, name &wrapped); \ + }; \ + +#define DEFINE_PRIMITIVE_WRAPPER_NBOSTREAM(name) \ + vespalib::nbostream & \ + operator<<(vespalib::nbostream &os, const name &wrapped) \ + { \ + os << wrapped._value; \ + return os; \ + } \ + \ + vespalib::nbostream & \ + operator>>(vespalib::nbostream &is, name &wrapped) \ + { \ + is >> wrapped._value; \ + return is; \ + } \ + +namespace storage { +namespace spi { + +/** + * \class storage::spi::NodeIndex + * \ingroup spi + */ +DEFINE_PRIMITIVE_WRAPPER(uint16_t, NodeIndex); + +/** + * \class storage::spi::PartitionId + * \ingroup spi + */ +DEFINE_PRIMITIVE_WRAPPER(uint16_t, PartitionId); + +/** + * \class storage::spi::IteratorId + * \ingroup spi + */ +DEFINE_PRIMITIVE_WRAPPER(uint64_t, IteratorId); + +/** + * \class storage::spi::Timestamp + * \ingroup spi + */ +DEFINE_PRIMITIVE_WRAPPER(uint64_t, Timestamp); + +/** + * \class storage::spi::BucketChecksum + * \ingroup spi + */ +DEFINE_PRIMITIVE_WRAPPER(uint32_t, BucketChecksum); + +// Import critical dependencies into SPI namespace. This makes interface look +// cleaner, and makes it easy to exchange actual implementation. +typedef document::Document Document; +typedef document::DocumentUpdate DocumentUpdate; +typedef document::DocumentId DocumentId; +typedef document::GlobalId GlobalId; +typedef std::vector TimestampList; +typedef vespalib::string string; + +enum IncludedVersions { + NEWEST_DOCUMENT_ONLY, + NEWEST_DOCUMENT_OR_REMOVE, + ALL_VERSIONS +}; + +enum MaintenanceLevel { + LOW, + HIGH +}; + +} // spi +} // storage + -- cgit v1.2.3