8000 Feature/out of search in range by Dronplane · Pull Request #11324 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/out of search in range #11324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
Dronplane committed Mar 23, 2020
commit 8f1eb2c6717a77c475c837caf27f3d90dbb77e62
2 changes: 1 addition & 1 deletion arangod/Aql/AqlFunctionFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void AqlFunctionFeature::addStringFunctions() {
add({"NGRAM_MATCH", ".,.|.,.", flags, &Functions::NgramMatch}); // (attribute, target, [threshold, analyzer]) OR (attribute, target, [analyzer])
add({"NGRAM_SIMILARITY", ".,.,.", flags, &Functions::NgramSimilarity}); // (attribute, target, ngram size)
add({"NGRAM_POSITIONAL_SIMILARITY", ".,.,.", flags, &Functions::NgramPositionalSimilarity}); // (attribute, target, ngram size)
add({"IN_RANGE", & 10000 quot;.,.,.,.,.", flags, &Functions::InRange });
add({"IN_RANGE", ".,.,.,.,.", flags, &Functions::InRange }); // (attribute, lower, upper, include lower, include upper)
// special flags:
add({"RANDOM_TOKEN", ".", Function::makeFlags(FF::CanRunOnDBServer),
&Functions::RandomToken}); // not deterministic and not cacheable
Expand Down
44 changes: 9 additions & 35 deletions arangod/Aql/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,8 +1841,7 @@ AqlValue Functions::InRange(ExpressionContext* ctx, transaction::Methods* trx,

auto const argc = args.size();

if (argc != 5) { // for const evaluation we need analyzer to be set explicitly (we can`t access filter context)
// but we can`t set analyzer as mandatory in function AQL signature - this will break SEARCH
if (argc != 5) {
registerWarning(
ctx, AFN,
arangodb::Result{ TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH,
Expand All @@ -1856,20 +1855,6 @@ AqlValue Functions::InRange(ExpressionContext* ctx, transaction::Methods* trx,
auto const& includeLowerVal = extractFunctionParameterValue(args, 3);
auto const& includeUpperVal = extractFunctionParameterValue(args, 4);

//bool const isNumber = attributeVal.isNumber() &&
// lowerVal.isNumber() &&
// upperVal.isNumber();

//bool const isString = !isNumber &&
// attributeVal.isString() &&
// lowerVal.isString() &&
// upperVal.isString();

//if (ADB_UNLIKELY(!isNumber && !isString)) {
// arangodb::aql::registerInvalidArgumentWarning(ctx, AFN);
// return arangodb::aql::AqlValue{ arangodb::aql::AqlValueHintNull{} };
//}

if (ADB_UNLIKELY(!includeLowerVal.isBoolean())) {
arangodb::aql::registerInvalidArgumentWarning(ctx, AFN);
return arangodb::aql::AqlValue{ arangodb::aql::AqlValueHintNull{} };
Expand All @@ -1882,30 +1867,19 @@ AqlValue Functions::InRange(ExpressionContext* ctx, transaction::Methods* trx,

auto const includeLower = includeLowerVal.toBoolean();
auto const includeUpper = includeUpperVal.toBoolean();
auto const compareLowerResult = AqlValue::Compare(trx, lowerVal, attributeVal, true);
if ((!includeLower && compareLowerResult >= 0) || (includeLower && compareLowerResult > 0)) {
return AqlValue(AqlValueHintBool(false));

// first check lower bound
{
auto const compareLowerResult = AqlValue::Compare(trx, lowerVal, attributeVal, true);
if ((!includeLower && compareLowerResult >= 0) || (includeLower && compareLowerResult > 0)) {
return AqlValue(AqlValueHintBool(false));
}
}

// lower bound is fine, check upper
auto const compareUpperResult = AqlValue::Compare(trx, attributeVal, upperVal, true);
return AqlValue(AqlValueHintBool((includeUpper && compareUpperResult <= 0) ||
(!includeUpper && compareUpperResult < 0)));
//!!!!!! NULL Bool !!
//if (isNumber) {
// auto const attribute = attributeVal.toDouble();
// auto const lower = lowerVal.toDouble();
// auto const upper = upperVal.toDouble();
// return AqlValue(AqlValueHintBool(
// (includeLower ? attribute >= lower : attribute > lower) &&
// (includeUpper ? attribute <= upper : attribute < upper)
// ));
//} else {
// TRI_ASSERT(isString);
// auto const attribute = iresearch::getStringRef(attributeVal.slice());
// auto const lower = iresearch::getStringRef(lowerVal.slice());
// auto const upper = iresearch::getStringRef(upperVal.slice());
// return arangodb::aql::AqlValue{ arangodb::aql::AqlValueHintNull{} };
//}
}

/// @brief function TO_BOOL
Expand Down
1 change: 0 additions & 1 deletion arangod/IResearch/IResearchFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ void registerFilters(arangodb::aql::AqlFunctionFeature& functions) {
addFunction(functions, { "EXISTS", ".|.,.", flags, &dummyFilterFunc }); // (attribute, [ // "analyzer"|"type"|"string"|"numeric"|"bool"|"null" // ])
addFunction(functions, { "STARTS_WITH", ".,.|.", flags, &startsWithFunc }); // (attribute, prefix, scoring-limit)
addFunction(functions, { "PHRASE", ".,.|.+", flags, &dummyFilterFunc }); // (attribute, input [, offset, input... ] [, analyzer])
//!!!!!! addFunction(functions, { "IN_RANGE", ".,.,.,.,.", flags, &dummyFilterFunc }); // (attribute, lower, upper, include lower, include upper)
addFunction(functions, { "MIN_MATCH", ".,.|.+", flags, &minMatchFunc }); // (filter expression [, filter expression, ... ], min match count)
addFunction(functions, { "BOOST", ".,.", flags, &contextFunc }); // (filter expression, boost)
addFunction(functions, { "ANALYZER", ".,.", flags, &contextFunc }); // (filter expression, analyzer)
Expand Down
Loading
0