1
0
Fork 0

Merge branch 'spdvpk' of github.com:arangodb/arangodb into spdvpk

This commit is contained in:
Michael Hackstein 2016-02-16 17:29:22 +01:00
commit 35c77083c0
6 changed files with 205 additions and 12 deletions

View File

@ -16,6 +16,20 @@ macro(import_target tname tdep tinclude tpath)
)
endmacro()
# ETCD
if (MSVC)
set (ETCD_BUILD_COMMAND build.bat)
else()
set (ETCD_BUILD_COMMAND ./build)
endif()
ExternalProject_Add(etcd_build
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/etcd
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE TRUE
BUILD_COMMAND "${ETCD_BUILD_COMMAND}"
INSTALL_COMMAND "")
# ZLIB
if (UNIX)
ExternalProject_Add(zlib_build

View File

@ -192,6 +192,13 @@ if (USE_MAINTAINER_MODE)
add_definitions("-DTRI_ENABLE_MAINTAINER_MODE=1")
endif()
# Maintainer mode (Failure Tests) ----------------------------------------------
option(USE_FAILURE_TESTS
"whether we want to have failure tests compiled in" OFF)
if (USE_FAILURE_TESTS)
add_definitions("-DTRI_ENABLE_FAILURE_TESTS=1")
endif()
# Enable relative paths to binaries --------------------------------------------
option(USE_RELATIVE "Do you want to have all path are relative to the binary" OFF)

View File

@ -0,0 +1,50 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_UTILS_OPERATION_OPTIONS_H
#define ARANGOD_UTILS_OPERATION_OPTIONS_H 1
#include "Basics/Common.h"
namespace arangodb {
// a struct for keeping document modification operations in transactions
struct OperationOptions {
OperationOptions() : waitForSync(false), keepNull(false), mergeObjects(false), silent(false) {}
// wait until the operation has been synced
bool waitForSync;
// keep null values on update (=true) or remove them (=false). only used for update operations
bool keepNull;
// merge objects. only used for update operations
bool mergeObjects;
// be silent. this will build smaller results and thus may speed up operations
bool silent;
};
}
#endif

View File

@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_UTILS_OPERATION_RESULT_H
#define ARANGOD_UTILS_OPERATION_RESULT_H 1
#include "Basics/Common.h"
#include <velocypack/Builder.h>
#include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h>
namespace arangodb {
struct OperationResult {
OperationResult() : builder(), code(TRI_ERROR_NO_ERROR), wasSynchronous(false) {}
bool successful() const {
return code == TRI_ERROR_NO_ERROR;
}
bool failed() const {
return !successful();
}
VPackSlice slice() const {
return builder->slice();
}
std::shared_ptr<VPackBuilder> builder;
int code;
bool wasSynchronous;
};
}
#endif

View File

@ -32,6 +32,8 @@
#include "Cluster/ServerState.h"
#include "Utils/CollectionNameResolver.h"
#include "Utils/DocumentHelper.h"
#include "Utils/OperationOptions.h"
#include "Utils/OperationResult.h"
#include "Utils/TransactionContext.h"
#include "VocBase/collection.h"
#include "VocBase/Ditch.h"
@ -48,18 +50,6 @@
namespace arangodb {
struct OperationOptions {
OperationOptions() : waitForSync(false), keepNull(false), mergeObjects(false), silent(false) {}
bool waitForSync;
bool keepNull;
bool mergeObjects;
bool silent;
};
struct OperationResult {
int code;
};
class Transaction {
using VPackOptions = arangodb::velocypack::Options;
@ -422,14 +412,75 @@ class Transaction {
}
}
//////////////////////////////////////////////////////////////////////////////
/// @brief return one or multiple documents from a collection
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult document(std::string const& collectionName,
VPackSlice const& value,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief create one or multiple documents in a collection
/// the single-document variant of this operation will either succeed or,
/// if it fails, clean up after itself
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult insert(std::string const& collectionName,
VPackSlice const& value,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief update/patch one or multiple documents in a collection
/// the single-document variant of this operation will either succeed or,
/// if it fails, clean up after itself
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult update(std::string const& collectionName,
VPackSlice const& oldValue,
VPackSlice const& updateValue,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief replace one or multiple documents in a collection
/// the single-document variant of this operation will either succeed or,
/// if it fails, clean up after itself
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult replace(std::string const& collectionName,
VPackSlice const& oldValue,
VPackSlice const& updateValue,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief remove one or multiple documents in a collection
/// the single-document variant of this operation will either succeed or,
/// if it fails, clean up after itself
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult remove(std::string const& collectionName,
VPackSlice const& value,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief truncate all documents in a collection
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
OperationResult truncate(std::string const& collectionName,
OperationOptions const& options);
//////////////////////////////////////////////////////////////////////////////
/// @brief count the number of documents in a collection
/// TODO: implement this
//////////////////////////////////////////////////////////////////////////////
uint64_t count(std::string const& collectionName);
//////////////////////////////////////////////////////////////////////////////
/// @brief create a single document, using shaped json

View File

@ -512,6 +512,20 @@ class LoggerStream {
return *this;
}
template <typename T>
LoggerStream& operator<<(std::vector<T> const& v) {
for (auto const& i : v)
_out << i << " ";
return *this;
}
template <typename T>
LoggerStream& operator<<(std::unordered_set<T> const& us) {
for (auto const& i : us)
_out << i;
return *this;
}
private:
std::stringstream _out;
size_t _topicId;