1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
jsteemann 2018-07-30 19:27:36 +02:00
commit c0773691c6
2 changed files with 33 additions and 8 deletions

View File

@ -154,18 +154,20 @@ uint64_t ShardingStrategyCommunityCompat::hashByAttributes(
if (slice.isObject()) {
for (auto const& attr : attributes) {
VPackSlice sub = slice.get(attr).resolveExternal();
VPackBuilder tempBuilder;
if (sub.isNone()) {
if (attr == StaticStrings::KeyString && !key.empty()) {
VPackBuilder tempBuilder;
tempBuilder.add(VPackValue(key));
sub = tempBuilder.slice();
} else {
if (!docComplete) {
error = TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN;
}
// Null is equal to None/not present
sub = VPackSlice::nullSlice();
hash = sub.normalizedHash(hash);
continue;
}
if (!docComplete) {
error = TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN;
}
// Null is equal to None/not present
sub = VPackSlice::nullSlice();
}
hash = sub.normalizedHash(hash);
}

View File

@ -252,7 +252,12 @@ function ahuacatlShardIdsOptimizationTestSuite() {
FILTER joined.joinValue == doc.joinValue
RETURN [doc, joined]
`;
validatePlan(query, "IndexNode", collectionByKey);
const isEnterprise = require("internal").isEnterprise();
if (isEnterprise) {
// enterprise distributes all numeric keys onto one shard
validatePlan(query, "IndexNode", collectionByKey);
}
let res = db._query(query).toArray();
// we find 4 in first Loop, and 4 joins each
assertEqual(16, res.length);
@ -263,6 +268,24 @@ function ahuacatlShardIdsOptimizationTestSuite() {
}
}
},
testRestrictMultipleShardsStringKeys : function () {
dropIndexes(collectionByKey);
collectionByKey.ensureHashIndex(shardKey);
for (let i = 0; i < 25; ++i) {
const query = `
FOR doc IN ${cnKey}
FILTER doc.${shardKey} == "key${i}"
FOR joined IN ${cnKey}
FILTER joined.${shardKey} == "key${i}"
FILTER joined.joinValue == doc.joinValue
RETURN [doc, joined]
`;
validatePlan(query, "IndexNode", collectionByKey);
}
},
/* Not supported yet
testRestrictOnShardKeyNoIndex : function () {