aboutsummaryrefslogtreecommitdiffstats
path: root/persistencetypes
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /persistencetypes
Publish
Diffstat (limited to 'persistencetypes')
-rw-r--r--persistencetypes/.gitignore2
-rw-r--r--persistencetypes/CMakeLists.txt15
-rw-r--r--persistencetypes/OWNERS2
-rw-r--r--persistencetypes/src/.gitignore4
-rw-r--r--persistencetypes/src/persistence/.gitignore3
-rw-r--r--persistencetypes/src/persistence/CMakeLists.txt7
-rw-r--r--persistencetypes/src/persistence/spi/.gitignore2
-rw-r--r--persistencetypes/src/persistence/spi/CMakeLists.txt6
-rw-r--r--persistencetypes/src/persistence/spi/types.cpp20
-rw-r--r--persistencetypes/src/persistence/spi/types.h108
10 files changed, 169 insertions, 0 deletions
diff --git a/persistencetypes/.gitignore b/persistencetypes/.gitignore
new file mode 100644
index 00000000000..a9b20e8992d
--- /dev/null
+++ b/persistencetypes/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+Testing
diff --git a/persistencetypes/CMakeLists.txt b/persistencetypes/CMakeLists.txt
new file mode 100644
index 00000000000..25a96fad5a7
--- /dev/null
+++ b/persistencetypes/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_define_module(
+ DEPENDS
+ fastos
+ vespalog
+ vespalib
+ staging_vespalib
+ fnet
+ config_cloudconfig
+ document
+
+ LIBS
+ src/persistence
+ src/persistence/spi
+)
diff --git a/persistencetypes/OWNERS b/persistencetypes/OWNERS
new file mode 100644
index 00000000000..97c35339850
--- /dev/null
+++ b/persistencetypes/OWNERS
@@ -0,0 +1,2 @@
+vekterli
+dybdahl
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
+ $<TARGET_OBJECTS:persistencetypes_spi>
+ 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 <vespa/fastos/fastos.h>
+#include "types.h"
+#include <vespa/vespalib/objects/nbostream.h>
+
+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 <vespa/document/document.h>
+#include <vespa/document/base/globalid.h>
+
+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<Timestamp> TimestampList;
+typedef vespalib::string string;
+
+enum IncludedVersions {
+ NEWEST_DOCUMENT_ONLY,
+ NEWEST_DOCUMENT_OR_REMOVE,
+ ALL_VERSIONS
+};
+
+enum MaintenanceLevel {
+ LOW,
+ HIGH
+};
+
+} // spi
+} // storage
+