mirror of https://gitee.com/bigwinds/arangodb
use StaticStrings
This commit is contained in:
parent
55a20df204
commit
30525fccee
|
@ -34,6 +34,7 @@
|
|||
#include <thread>
|
||||
|
||||
#include "Aql/Query.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "RestServer/QueryRegistryFeature.h"
|
||||
#include "Utils/OperationOptions.h"
|
||||
|
@ -295,7 +296,7 @@ bool State::loadCollection(std::string const& name) {
|
|||
VPackSlice req = i.get("request");
|
||||
tmp->append(req.startAs<char const>(), req.byteSize());
|
||||
_log.push_back(
|
||||
log_t(std::stoi(i.get(TRI_VOC_ATTRIBUTE_KEY).copyString()),
|
||||
log_t(std::stoi(i.get(StaticStrings::KeyString).copyString()),
|
||||
static_cast<term_t>(i.get("term").getUInt()),
|
||||
static_cast<arangodb::consensus::id_t>(
|
||||
i.get("leader").getUInt()), tmp));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "Aql/AqlValue.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/StringBuffer.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
|
@ -981,7 +982,7 @@ size_t DistributeBlock::sendToClient(AqlItemBlock* cur) {
|
|||
static_cast<DistributeNode const*>(_exeNode)
|
||||
->_allowKeyConversionToObject) {
|
||||
builder.openObject();
|
||||
builder.add(TRI_VOC_ATTRIBUTE_KEY, input);
|
||||
builder.add(StaticStrings::KeyString, input);
|
||||
builder.close();
|
||||
|
||||
// clear the previous value
|
||||
|
@ -1004,12 +1005,12 @@ size_t DistributeBlock::sendToClient(AqlItemBlock* cur) {
|
|||
if (_usesDefaultSharding) {
|
||||
// the collection is sharded by _key...
|
||||
|
||||
if (!hasCreatedKeyAttribute && !value.hasKey(TRI_VOC_ATTRIBUTE_KEY)) {
|
||||
if (!hasCreatedKeyAttribute && !value.hasKey(StaticStrings::KeyString)) {
|
||||
// there is no _key attribute present, so we are responsible for
|
||||
// creating one
|
||||
VPackBuilder temp;
|
||||
temp.openObject();
|
||||
temp.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(createKey()));
|
||||
temp.add(StaticStrings::KeyString, VPackValue(createKey()));
|
||||
temp.close();
|
||||
|
||||
builder2 = VPackCollection::merge(input, temp.slice(), true);
|
||||
|
@ -1024,14 +1025,14 @@ size_t DistributeBlock::sendToClient(AqlItemBlock* cur) {
|
|||
} else {
|
||||
// the collection is not sharded by _key
|
||||
|
||||
if (hasCreatedKeyAttribute || value.hasKey(TRI_VOC_ATTRIBUTE_KEY)) {
|
||||
if (hasCreatedKeyAttribute || value.hasKey(StaticStrings::KeyString)) {
|
||||
// a _key was given, but user is not allowed to specify _key
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY);
|
||||
}
|
||||
|
||||
VPackBuilder temp;
|
||||
temp.openObject();
|
||||
temp.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(createKey()));
|
||||
temp.add(StaticStrings::KeyString, VPackValue(createKey()));
|
||||
temp.close();
|
||||
|
||||
builder2 = VPackCollection::merge(input, temp.slice(), true);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Collection.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Cluster/ClusterInfo.h"
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::aql;
|
||||
|
||||
/// @brief create a collection wrapper
|
||||
|
@ -137,7 +139,7 @@ bool Collection::usesDefaultSharding() const {
|
|||
// check if collection shard keys are only _key
|
||||
std::vector<std::string> sk(shardKeys());
|
||||
|
||||
if (sk.size() != 1 || sk[0] != TRI_VOC_ATTRIBUTE_KEY) {
|
||||
if (sk.size() != 1 || sk[0] != StaticStrings::KeyString) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1970,12 +1970,12 @@ AqlValue Functions::Neighbors(arangodb::aql::Query* query,
|
|||
splitCollection = true;
|
||||
}
|
||||
} else if (vertexInfo.isObject()) {
|
||||
if (!vertexInfo.hasKey(trx, TRI_VOC_ATTRIBUTE_ID)) {
|
||||
if (!vertexInfo.hasKey(trx, StaticStrings::IdString)) {
|
||||
THROW_ARANGO_EXCEPTION_PARAMS(
|
||||
TRI_ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH, "NEIGHBORS");
|
||||
}
|
||||
bool localMustDestroy;
|
||||
AqlValue id = vertexInfo.get(trx, TRI_VOC_ATTRIBUTE_ID, localMustDestroy, false);
|
||||
AqlValue id = vertexInfo.get(trx, StaticStrings::IdString, localMustDestroy, false);
|
||||
AqlValueGuard guard(id, localMustDestroy);
|
||||
|
||||
if (!id.isString()) {
|
||||
|
@ -2310,9 +2310,9 @@ AqlValue Functions::ParseIdentifier(
|
|||
|
||||
AqlValue value = ExtractFunctionParameterValue(trx, parameters, 0);
|
||||
std::string identifier;
|
||||
if (value.isObject() && value.hasKey(trx, TRI_VOC_ATTRIBUTE_ID)) {
|
||||
if (value.isObject() && value.hasKey(trx, StaticStrings::IdString)) {
|
||||
bool localMustDestroy;
|
||||
AqlValue s = value.get(trx, TRI_VOC_ATTRIBUTE_ID, localMustDestroy, false);
|
||||
AqlValue s = value.get(trx, StaticStrings::IdString, localMustDestroy, false);
|
||||
AqlValueGuard guard(s, localMustDestroy);
|
||||
|
||||
if (s.isString()) {
|
||||
|
@ -3666,9 +3666,9 @@ AqlValue Functions::IsSameCollection(
|
|||
AqlValue value = ExtractFunctionParameterValue(trx, parameters, 1);
|
||||
std::string identifier;
|
||||
|
||||
if (value.isObject() && value.hasKey(trx, TRI_VOC_ATTRIBUTE_ID)) {
|
||||
if (value.isObject() && value.hasKey(trx, StaticStrings::IdString)) {
|
||||
bool localMustDestroy;
|
||||
value = value.get(trx, TRI_VOC_ATTRIBUTE_ID, localMustDestroy, false);
|
||||
value = value.get(trx, StaticStrings::IdString, localMustDestroy, false);
|
||||
AqlValueGuard guard(value, localMustDestroy);
|
||||
|
||||
if (value.isString()) {
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
#include "Aql/Variable.h"
|
||||
#include "Aql/types.h"
|
||||
#include "Basics/AttributeNameParser.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Utils/Transaction.h"
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::aql;
|
||||
using Json = arangodb::basics::Json;
|
||||
using EN = arangodb::aql::ExecutionNode;
|
||||
|
||||
/// @brief adds a SORT operation for IN right-hand side operands
|
||||
|
@ -2794,7 +2794,7 @@ class RemoveToEnumCollFinder final : public WalkerWorker<ExecutionNode> {
|
|||
}
|
||||
// check the remove node's collection is sharded over _key
|
||||
std::vector<std::string> shardKeys = rn->collection()->shardKeys();
|
||||
if (shardKeys.size() != 1 || shardKeys[0] != TRI_VOC_ATTRIBUTE_KEY) {
|
||||
if (shardKeys.size() != 1 || shardKeys[0] != StaticStrings::KeyString) {
|
||||
break; // abort . . .
|
||||
}
|
||||
|
||||
|
|
|
@ -2316,7 +2316,7 @@ int ClusterInfo::getResponsibleShard(CollectionID const& collectionID,
|
|||
shardKeysPtr = it2->second;
|
||||
usesDefaultShardingAttributes =
|
||||
shardKeysPtr->size() == 1 &&
|
||||
shardKeysPtr->at(0) == TRI_VOC_ATTRIBUTE_KEY;
|
||||
shardKeysPtr->at(0) == StaticStrings::KeyString;
|
||||
found = true;
|
||||
break; // all OK
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define ARANGOD_CLUSTER_CLUSTER_INFO_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/Mutex.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
|
@ -297,7 +297,7 @@ class CollectionInfo {
|
|||
TRI_ASSERT(firstElement.isString());
|
||||
std::string shardKey =
|
||||
arangodb::basics::VelocyPackHelper::getStringValue(firstElement, "");
|
||||
return shardKey == TRI_VOC_ATTRIBUTE_KEY;
|
||||
return shardKey == StaticStrings::KeyString;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -277,7 +277,7 @@ static int distributeBabyOnShards(
|
|||
// attributes a bit further down the line when we have determined
|
||||
// the responsible shard.
|
||||
|
||||
VPackSlice keySlice = node.get(TRI_VOC_ATTRIBUTE_KEY);
|
||||
VPackSlice keySlice = node.get(StaticStrings::KeyString);
|
||||
if (keySlice.isNone()) {
|
||||
// The user did not specify a key, let's create one:
|
||||
uint64_t uid = ci->uniqid();
|
||||
|
@ -410,7 +410,7 @@ bool shardKeysChanged(std::string const& dbname, std::string const& collname,
|
|||
std::vector<std::string> const& shardKeys = c->shardKeys();
|
||||
|
||||
for (size_t i = 0; i < shardKeys.size(); ++i) {
|
||||
if (shardKeys[i] == TRI_VOC_ATTRIBUTE_KEY) {
|
||||
if (shardKeys[i] == StaticStrings::KeyString) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1262,8 +1262,8 @@ int getDocumentOnCoordinator(
|
|||
for (auto const& it : shardMap) {
|
||||
if (!useMultiple) {
|
||||
TRI_ASSERT(it.second.size() == 1);
|
||||
if (!options.ignoreRevs && slice.hasKey(TRI_VOC_ATTRIBUTE_REV)) {
|
||||
headers->emplace("if-match", slice.get(TRI_VOC_ATTRIBUTE_REV).copyString());
|
||||
if (!options.ignoreRevs && slice.hasKey(StaticStrings::RevString)) {
|
||||
headers->emplace("if-match", slice.get(StaticStrings::RevString).copyString());
|
||||
}
|
||||
|
||||
// We send to single endpoint
|
||||
|
@ -1271,7 +1271,7 @@ int getDocumentOnCoordinator(
|
|||
"shard:" + it.first, reqType,
|
||||
baseUrl + StringUtils::urlEncode(it.first) + "/" +
|
||||
StringUtils::urlEncode(
|
||||
slice.get(TRI_VOC_ATTRIBUTE_KEY).copyString()) +
|
||||
slice.get(StaticStrings::KeyString).copyString()) +
|
||||
optsUrlPart,
|
||||
body);
|
||||
requests[0].setHeaders(headers);
|
||||
|
@ -1330,15 +1330,15 @@ int getDocumentOnCoordinator(
|
|||
auto shardList = ci->getShardList(collid);
|
||||
if (!useMultiple) {
|
||||
|
||||
if (!options.ignoreRevs && slice.hasKey(TRI_VOC_ATTRIBUTE_REV)) {
|
||||
headers->emplace("if-match", slice.get(TRI_VOC_ATTRIBUTE_REV).copyString());
|
||||
if (!options.ignoreRevs && slice.hasKey(StaticStrings::RevString)) {
|
||||
headers->emplace("if-match", slice.get(StaticStrings::RevString).copyString());
|
||||
}
|
||||
for (auto const& shard : *shardList) {
|
||||
ClusterCommRequest req(
|
||||
"shard:" + shard, reqType,
|
||||
baseUrl + StringUtils::urlEncode(shard) + "/" +
|
||||
StringUtils::urlEncode(
|
||||
slice.get(TRI_VOC_ATTRIBUTE_KEY).copyString()) +
|
||||
slice.get(StaticStrings::KeyString).copyString()) +
|
||||
optsUrlPart,
|
||||
nullptr);
|
||||
auto headersCopy =
|
||||
|
@ -1435,7 +1435,7 @@ static void insertIntoShardMap(
|
|||
// We only need add one resp. shard
|
||||
VPackBuilder partial;
|
||||
partial.openObject();
|
||||
partial.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(splitId[1]));
|
||||
partial.add(StaticStrings::KeyString, VPackValue(splitId[1]));
|
||||
partial.close();
|
||||
bool usesDefaultShardingAttributes;
|
||||
ShardID shardID;
|
||||
|
@ -1554,7 +1554,7 @@ int getFilteredDocumentsOnCoordinator(
|
|||
}
|
||||
for (auto const& element : VPackArrayIterator(documents)) {
|
||||
std::string id = arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
element, TRI_VOC_ATTRIBUTE_ID, "");
|
||||
element, StaticStrings::IdString, "");
|
||||
VPackBuilder tmp;
|
||||
tmp.add(element);
|
||||
result.emplace(id, tmp.steal());
|
||||
|
@ -1815,7 +1815,7 @@ int modifyDocumentOnCoordinator(
|
|||
requests.emplace_back(
|
||||
"shard:" + it.first, reqType,
|
||||
baseUrl + StringUtils::urlEncode(it.first) + "/" +
|
||||
slice.get(TRI_VOC_ATTRIBUTE_KEY).copyString() + optsUrlPart,
|
||||
slice.get(StaticStrings::KeyString).copyString() + optsUrlPart,
|
||||
body);
|
||||
} else {
|
||||
reqBuilder.clear();
|
||||
|
@ -1871,7 +1871,7 @@ int modifyDocumentOnCoordinator(
|
|||
auto body = std::make_shared<std::string>(slice.toJson());
|
||||
auto shardList = ci->getShardList(collid);
|
||||
if (!useMultiple) {
|
||||
std::string key = slice.get(TRI_VOC_ATTRIBUTE_KEY).copyString();
|
||||
std::string key = slice.get(StaticStrings::KeyString).copyString();
|
||||
for (auto const& shard : *shardList) {
|
||||
requests.emplace_back(
|
||||
"shard:" + shard, reqType,
|
||||
|
|
|
@ -76,11 +76,11 @@ bool ClusterTraverser::VertexGetter::operator()(std::string const& edgeId,
|
|||
auto it = _traverser->_edges.find(edgeId);
|
||||
if (it != _traverser->_edges.end()) {
|
||||
VPackSlice slice(it->second->data());
|
||||
std::string from = slice.get(TRI_VOC_ATTRIBUTE_FROM).copyString();
|
||||
std::string from = slice.get(StaticStrings::FromString).copyString();
|
||||
if (from != vertexId) {
|
||||
result = from;
|
||||
} else {
|
||||
std::string to = slice.get(TRI_VOC_ATTRIBUTE_TO).copyString();
|
||||
std::string to = slice.get(StaticStrings::ToString).copyString();
|
||||
result = to;
|
||||
}
|
||||
auto exp = _traverser->_expressions->find(depth);
|
||||
|
@ -155,14 +155,14 @@ void ClusterTraverser::EdgeGetter::operator()(std::string const& startVertex,
|
|||
std::unordered_set<std::string> verticesToFetch;
|
||||
for (auto const& edge : VPackArrayIterator(edgesSlice)) {
|
||||
std::string edgeId = arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
edge, TRI_VOC_ATTRIBUTE_ID, "");
|
||||
edge, StaticStrings::IdString.c_str(), "");
|
||||
std::string fromId = arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
edge, TRI_VOC_ATTRIBUTE_FROM, "");
|
||||
edge, StaticStrings::FromString.c_str(), "");
|
||||
if (_traverser->_vertices.find(fromId) == _traverser->_vertices.end()) {
|
||||
verticesToFetch.emplace(std::move(fromId));
|
||||
}
|
||||
std::string toId = arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
edge, TRI_VOC_ATTRIBUTE_TO, "");
|
||||
edge, StaticStrings::ToString.c_str(), "");
|
||||
if (_traverser->_vertices.find(toId) == _traverser->_vertices.end()) {
|
||||
verticesToFetch.emplace(std::move(toId));
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include "Rest/HttpResponse.h"
|
||||
|
||||
using namespace arangodb::basics;
|
||||
|
||||
static std::string const AllowedChars =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890. +-_=";
|
||||
|
||||
|
||||
namespace arangodb {
|
||||
namespace rest {
|
||||
|
@ -62,9 +66,6 @@ PathHandler::PathHandler(HttpRequest* request, Options const* options)
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
HttpHandler::status_t PathHandler::execute() {
|
||||
static std::string const allowed =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890. +-_=";
|
||||
|
||||
std::vector<std::string> names = _request->suffix();
|
||||
std::string name = path;
|
||||
std::string last = "";
|
||||
|
@ -113,7 +114,7 @@ HttpHandler::status_t PathHandler::execute() {
|
|||
return status_t(HANDLER_DONE);
|
||||
}
|
||||
|
||||
std::string::size_type sc = next.find_first_not_of(allowed);
|
||||
std::string::size_type sc = next.find_first_not_of(AllowedChars);
|
||||
|
||||
if (sc != std::string::npos) {
|
||||
LOG(WARN) << "file '" << name << "' contains illegal character";
|
||||
|
@ -170,8 +171,7 @@ HttpHandler::status_t PathHandler::execute() {
|
|||
if (cacheMaxAge > 0 &&
|
||||
_request->requestType() == GeneralRequest::RequestType::GET) {
|
||||
// yes, then set a pro-caching header
|
||||
static std::string const cacheControl = "cache-control";
|
||||
_response->setHeaderNC(cacheControl, maxAgeHeader);
|
||||
_response->setHeaderNC(StaticStrings::CacheControl, maxAgeHeader);
|
||||
}
|
||||
|
||||
std::string::size_type d = last.find_last_of('.');
|
||||
|
|
|
@ -511,7 +511,7 @@ int ContinuousSyncer::processDocument(TRI_replication_operation_e type,
|
|||
}
|
||||
|
||||
// extract "key"
|
||||
VPackSlice const key = doc.get(TRI_VOC_ATTRIBUTE_KEY);
|
||||
VPackSlice const key = doc.get(StaticStrings::KeyString);
|
||||
|
||||
if (!key.isString()) {
|
||||
errorMsg = "invalid document key format";
|
||||
|
@ -519,7 +519,7 @@ int ContinuousSyncer::processDocument(TRI_replication_operation_e type,
|
|||
}
|
||||
|
||||
// extract "rev"
|
||||
VPackSlice const rev = doc.get(TRI_VOC_ATTRIBUTE_REV);
|
||||
VPackSlice const rev = doc.get(StaticStrings::RevString);
|
||||
|
||||
if (!rev.isString()) {
|
||||
errorMsg = "invalid document revision format";
|
||||
|
@ -528,8 +528,8 @@ int ContinuousSyncer::processDocument(TRI_replication_operation_e type,
|
|||
|
||||
VPackBuilder builder;
|
||||
builder.openObject();
|
||||
builder.add(TRI_VOC_ATTRIBUTE_KEY, key);
|
||||
builder.add(TRI_VOC_ATTRIBUTE_REV, rev);
|
||||
builder.add(StaticStrings::KeyString, key);
|
||||
builder.add(StaticStrings::RevString, rev);
|
||||
builder.close();
|
||||
|
||||
VPackSlice const old = builder.slice();
|
||||
|
|
|
@ -66,7 +66,7 @@ static bool BinarySearch(std::vector<void const*> const& markers,
|
|||
|
||||
TRI_ASSERT(position < markers.size());
|
||||
VPackSlice const otherSlice(reinterpret_cast<char const*>(markers.at(position)));
|
||||
VPackSlice const otherKey = otherSlice.get(TRI_VOC_ATTRIBUTE_KEY);
|
||||
VPackSlice const otherKey = otherSlice.get(StaticStrings::KeyString);
|
||||
|
||||
int res = key.compare(otherKey.copyString());
|
||||
|
||||
|
@ -539,12 +539,12 @@ int InitialSyncer::applyCollectionDump(
|
|||
}
|
||||
|
||||
if (!doc.isNone()) {
|
||||
VPackSlice value = doc.get(TRI_VOC_ATTRIBUTE_KEY);
|
||||
VPackSlice value = doc.get(StaticStrings::KeyString);
|
||||
if (value.isString()) {
|
||||
key = value.copyString();
|
||||
}
|
||||
|
||||
value = doc.get(TRI_VOC_ATTRIBUTE_REV);
|
||||
value = doc.get(StaticStrings::RevString);
|
||||
|
||||
if (value.isString()) {
|
||||
rev = value.copyString();
|
||||
|
@ -562,9 +562,9 @@ int InitialSyncer::applyCollectionDump(
|
|||
|
||||
VPackBuilder oldBuilder;
|
||||
oldBuilder.openObject();
|
||||
oldBuilder.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(key));
|
||||
oldBuilder.add(StaticStrings::KeyString, VPackValue(key));
|
||||
if (!rev.empty()) {
|
||||
oldBuilder.add(TRI_VOC_ATTRIBUTE_REV, VPackValue(rev));
|
||||
oldBuilder.add(StaticStrings::RevString, VPackValue(rev));
|
||||
}
|
||||
oldBuilder.close();
|
||||
|
||||
|
@ -1109,8 +1109,8 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
VPackSlice const r(reinterpret_cast<char const*>(rhs));
|
||||
|
||||
VPackValueLength lLength, rLength;
|
||||
char const* lKey = l.get(TRI_VOC_ATTRIBUTE_KEY).getString(lLength);
|
||||
char const* rKey = r.get(TRI_VOC_ATTRIBUTE_KEY).getString(rLength);
|
||||
char const* lKey = l.get(StaticStrings::KeyString).getString(lLength);
|
||||
char const* rKey = r.get(StaticStrings::KeyString).getString(rLength);
|
||||
|
||||
size_t const length = (lLength < rLength ? lLength : rLength);
|
||||
int res = memcmp(lKey, rKey, length);
|
||||
|
@ -1219,7 +1219,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
for (size_t i = 0; i < markers.size(); ++i) {
|
||||
VPackSlice const k(reinterpret_cast<char const*>(markers[i]));
|
||||
|
||||
std::string const key(k.get(TRI_VOC_ATTRIBUTE_KEY).copyString());
|
||||
std::string const key(k.get(StaticStrings::KeyString).copyString());
|
||||
|
||||
if (key.compare(lowKey) >= 0) {
|
||||
break;
|
||||
|
@ -1227,7 +1227,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
|
||||
keyBuilder.clear();
|
||||
keyBuilder.openObject();
|
||||
keyBuilder.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(key));
|
||||
keyBuilder.add(StaticStrings::KeyString, VPackValue(key));
|
||||
keyBuilder.close();
|
||||
|
||||
trx.remove(collectionName, keyBuilder.slice(), options);
|
||||
|
@ -1245,7 +1245,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
for (size_t i = markers.size(); i >= 1; --i) {
|
||||
VPackSlice const k(reinterpret_cast<char const*>(markers[i - 1]));
|
||||
|
||||
std::string const key(k.get(TRI_VOC_ATTRIBUTE_KEY).copyString());
|
||||
std::string const key(k.get(StaticStrings::KeyString).copyString());
|
||||
|
||||
if (key.compare(highKey) <= 0) {
|
||||
break;
|
||||
|
@ -1253,7 +1253,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
|
||||
keyBuilder.clear();
|
||||
keyBuilder.openObject();
|
||||
keyBuilder.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(key));
|
||||
keyBuilder.add(StaticStrings::KeyString, VPackValue(key));
|
||||
keyBuilder.close();
|
||||
|
||||
trx.remove(collectionName, keyBuilder.slice(), options);
|
||||
|
@ -1329,8 +1329,8 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
for (size_t i = localFrom; i <= localTo; ++i) {
|
||||
TRI_ASSERT(i < markers.size());
|
||||
VPackSlice const current(reinterpret_cast<char const*>(markers.at(i)));
|
||||
hash ^= current.get(TRI_VOC_ATTRIBUTE_KEY).hash();
|
||||
hash ^= current.get(TRI_VOC_ATTRIBUTE_REV).hash();
|
||||
hash ^= current.get(StaticStrings::KeyString).hash();
|
||||
hash ^= current.get(StaticStrings::RevString).hash();
|
||||
}
|
||||
|
||||
if (std::to_string(hash) != hashSlice.copyString()) {
|
||||
|
@ -1397,13 +1397,13 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
// delete all keys at start of the range
|
||||
while (nextStart < markers.size()) {
|
||||
VPackSlice const keySlice(reinterpret_cast<char const*>(markers[nextStart]));
|
||||
std::string const localKey(keySlice.get(TRI_VOC_ATTRIBUTE_KEY).copyString());
|
||||
std::string const localKey(keySlice.get(StaticStrings::KeyString).copyString());
|
||||
|
||||
if (localKey.compare(lowString) < 0) {
|
||||
// we have a local key that is not present remotely
|
||||
keyBuilder.clear();
|
||||
keyBuilder.openObject();
|
||||
keyBuilder.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(localKey));
|
||||
keyBuilder.add(StaticStrings::KeyString, VPackValue(localKey));
|
||||
keyBuilder.close();
|
||||
|
||||
trx.remove(collectionName, keyBuilder.slice(), options);
|
||||
|
@ -1451,7 +1451,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
|
||||
while (nextStart < markers.size()) {
|
||||
VPackSlice const localKeySlice(reinterpret_cast<char const*>(markers[nextStart]));
|
||||
std::string const localKey(localKeySlice.get(TRI_VOC_ATTRIBUTE_KEY).copyString());
|
||||
std::string const localKey(localKeySlice.get(StaticStrings::KeyString).copyString());
|
||||
|
||||
int res = localKey.compare(keyString);
|
||||
|
||||
|
@ -1459,7 +1459,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
// we have a local key that is not present remotely
|
||||
keyBuilder.clear();
|
||||
keyBuilder.openObject();
|
||||
keyBuilder.add(TRI_VOC_ATTRIBUTE_KEY, VPackValue(localKey));
|
||||
keyBuilder.add(StaticStrings::KeyString, VPackValue(localKey));
|
||||
keyBuilder.close();
|
||||
|
||||
trx.remove(collectionName, keyBuilder.slice(), options);
|
||||
|
@ -1491,7 +1491,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
|
||||
while (nextStart < markers.size()) {
|
||||
VPackSlice const localKeySlice(reinterpret_cast<char const*>(markers[nextStart]));
|
||||
std::string const localKey(localKeySlice.get(TRI_VOC_ATTRIBUTE_KEY).copyString());
|
||||
std::string const localKey(localKeySlice.get(StaticStrings::KeyString).copyString());
|
||||
|
||||
int res = localKey.compare(highString);
|
||||
|
||||
|
@ -1573,7 +1573,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
return TRI_ERROR_REPLICATION_INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
VPackSlice const keySlice = it.get(TRI_VOC_ATTRIBUTE_KEY);
|
||||
VPackSlice const keySlice = it.get(StaticStrings::KeyString);
|
||||
|
||||
if (!keySlice.isString()) {
|
||||
errorMsg = "got invalid response from master at " +
|
||||
|
@ -1583,7 +1583,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
return TRI_ERROR_REPLICATION_INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
VPackSlice const revSlice = it.get(TRI_VOC_ATTRIBUTE_REV);
|
||||
VPackSlice const revSlice = it.get(StaticStrings::RevString);
|
||||
|
||||
if (!revSlice.isString()) {
|
||||
errorMsg = "got invalid response from master at " +
|
||||
|
|
|
@ -213,11 +213,8 @@ HttpHandler::status_t RestBatchHandler::execute() {
|
|||
_response->body().appendText(TRI_CHAR_LENGTH_PAIR("\r\n\r\n"));
|
||||
|
||||
// remove some headers we don't need
|
||||
static std::string const server = "server";
|
||||
static std::string const empty = "";
|
||||
|
||||
partResponse->setConnectionType(HttpResponse::CONNECTION_NONE);
|
||||
partResponse->setHeaderNC(server, empty);
|
||||
partResponse->setHeaderNC(StaticStrings::Server, "");
|
||||
|
||||
// append the part response header
|
||||
partResponse->writeHeader(&_response->body());
|
||||
|
|
|
@ -174,10 +174,8 @@ bool VocbaseContext::useClusterAuthentication() const {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string VocbaseContext::realm() const {
|
||||
static std::string EMPTY = "";
|
||||
|
||||
if (_vocbase == nullptr) {
|
||||
return EMPTY;
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
return _vocbase->_name;
|
||||
|
|
|
@ -543,20 +543,16 @@ static HttpResponse* ResponseV8ToCpp(v8::Isolate* isolate,
|
|||
std::string name = TRI_ObjectToString(transformator);
|
||||
|
||||
// check available transformations
|
||||
static std::string const contentEncoding = "content-encoding";
|
||||
|
||||
if (name == "base64encode") {
|
||||
// base64-encode the result
|
||||
out = StringUtils::encodeBase64(out);
|
||||
// set the correct content-encoding header
|
||||
static std::string const base64 = "base64";
|
||||
response->setHeaderNC(contentEncoding, base64);
|
||||
response->setHeaderNC(StaticStrings::ContentEncoding, StaticStrings::Base64);
|
||||
} else if (name == "base64decode") {
|
||||
// base64-decode the result
|
||||
out = StringUtils::decodeBase64(out);
|
||||
// set the correct content-encoding header
|
||||
static std::string const binary = "binary";
|
||||
response->setHeaderNC(contentEncoding, binary);
|
||||
response->setHeaderNC(StaticStrings::ContentEncoding, StaticStrings::Binary);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ bool ExtractDocumentHandle(v8::Isolate* isolate,
|
|||
if (key.get() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
builder.add(TRI_VOC_ATTRIBUTE_KEY,
|
||||
builder.add(StaticStrings::KeyString,
|
||||
VPackValue(reinterpret_cast<char*>(key.get())));
|
||||
}
|
||||
return res;
|
||||
|
@ -223,7 +223,7 @@ bool ExtractDocumentHandle(v8::Isolate* isolate,
|
|||
return false;
|
||||
}
|
||||
// If we get here we have a valid key
|
||||
builder.add(TRI_VOC_ATTRIBUTE_KEY,
|
||||
builder.add(StaticStrings::KeyString,
|
||||
VPackValue(reinterpret_cast<char*>(key.get())));
|
||||
|
||||
if (!includeRev) {
|
||||
|
@ -241,7 +241,7 @@ bool ExtractDocumentHandle(v8::Isolate* isolate,
|
|||
if (rid == 0) {
|
||||
return false;
|
||||
}
|
||||
builder.add(TRI_VOC_ATTRIBUTE_REV, VPackValue(std::to_string(rid)));
|
||||
builder.add(StaticStrings::RevString, VPackValue(std::to_string(rid)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ static int ProcessIndexFields(v8::Isolate* isolate,
|
|||
|
||||
std::string const f = TRI_ObjectToString(fieldList->Get(i));
|
||||
|
||||
if (f.empty() || (create && f == TRI_VOC_ATTRIBUTE_ID)) {
|
||||
if (f.empty() || (create && f == StaticStrings::IdString)) {
|
||||
// accessing internal attributes is disallowed
|
||||
return TRI_ERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
|
|
@ -173,16 +173,15 @@ class BenchmarkThread : public arangodb::Thread {
|
|||
|
||||
TRI_ASSERT(t != nullptr);
|
||||
|
||||
if (location.substr(0, 5) == "/_db/") {
|
||||
if (location.compare(0, 5, "/_db/") == 0) {
|
||||
// location already contains /_db/
|
||||
return location;
|
||||
}
|
||||
|
||||
if (location[0] == '/') {
|
||||
return std::string("/_db/" + t->_databaseName + location);
|
||||
} else {
|
||||
return std::string("/_db/" + t->_databaseName + "/" + location);
|
||||
}
|
||||
}
|
||||
return std::string("/_db/" + t->_databaseName + "/" + location);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -248,7 +247,6 @@ class BenchmarkThread : public arangodb::Thread {
|
|||
batchPayload.appendText(boundary, blen);
|
||||
batchPayload.appendText(TRI_CHAR_LENGTH_PAIR("--\r\n"));
|
||||
|
||||
_headers.erase("Content-Type");
|
||||
_headers["Content-Type"] =
|
||||
HttpRequest::MULTI_PART_CONTENT_TYPE + "; boundary=" + boundary;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ ArangoClientHelper::ArangoClientHelper() : _httpClient(nullptr) {}
|
|||
// helper to rewrite HTTP location
|
||||
std::string ArangoClientHelper::rewriteLocation(void* data,
|
||||
std::string const& location) {
|
||||
if (location.substr(0, 5) == "/_db/") {
|
||||
if (location.compare(0, 5, "/_db/") == 0) {
|
||||
return location;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
using namespace arangodb;
|
||||
|
||||
// constants
|
||||
std::string const StaticStrings::Base64("base64");
|
||||
std::string const StaticStrings::Binary("binary");
|
||||
std::string const StaticStrings::N1800("1800");
|
||||
|
||||
// system attribute names
|
||||
|
@ -51,8 +53,10 @@ std::string const StaticStrings::Allow("allow");
|
|||
std::string const StaticStrings::Async("x-arango-async");
|
||||
std::string const StaticStrings::AsyncId("x-arango-async-id");
|
||||
std::string const StaticStrings::Authorization("authorization");
|
||||
std::string const StaticStrings::CacheControl("cache-control");
|
||||
std::string const StaticStrings::Close("Close");
|
||||
std::string const StaticStrings::Connection("connection");
|
||||
std::string const StaticStrings::ContentEncoding("content-encoding");
|
||||
std::string const StaticStrings::ContentTypeHeader("content-type");
|
||||
std::string const StaticStrings::Coordinator("x-arango-coordinator");
|
||||
std::string const StaticStrings::CorsMethods("DELETE, GET, HEAD, PATCH, POST, PUT");
|
||||
|
|
|
@ -31,6 +31,8 @@ class StaticStrings {
|
|||
|
||||
public:
|
||||
// constants
|
||||
static std::string const Base64;
|
||||
static std::string const Binary;
|
||||
static std::string const N1800;
|
||||
|
||||
// system attribute names
|
||||
|
@ -57,8 +59,10 @@ class StaticStrings {
|
|||
static std::string const Async;
|
||||
static std::string const AsyncId;
|
||||
static std::string const Authorization;
|
||||
static std::string const CacheControl;
|
||||
static std::string const Close;
|
||||
static std::string const Connection;
|
||||
static std::string const ContentEncoding;
|
||||
static std::string const ContentTypeHeader;
|
||||
static std::string const Coordinator;
|
||||
static std::string const CorsMethods;
|
||||
|
|
Loading…
Reference in New Issue