From 6c67ac97f2d663ca82b36d00578eee70c4b05afe Mon Sep 17 00:00:00 2001 From: Andrey G Date: Tue, 21 Apr 2026 19:18:06 +0200 Subject: [PATCH 1/6] Replace "DSL" with "AEL" --- README.md | 26 +-- docs/api-reference.md | 40 ++-- docs/getting-started.md | 40 ++-- .../01-writing-your-first-expression.md | 22 +- docs/guides/02-working-with-lists-and-maps.md | 28 +-- .../guides/03-filtering-on-record-metadata.md | 20 +- docs/guides/04-arithmetic-expressions.md | 18 +- docs/guides/05-using-placeholders.md | 34 +-- docs/guides/06-using-secondary-indexes.md | 30 +-- ...07-conditional-logic-control-structures.md | 40 ++-- docs/installation.md | 28 +-- docs/troubleshooting.md | 14 +- pom.xml | 38 +--- .../com/aerospike/{dsl => ael}/Condition.g4 | 2 +- .../AelParseException.java} | 10 +- .../{dsl => ael}/ExpressionContext.java | 2 +- .../com/aerospike/{dsl => ael}/Index.java | 8 +- .../aerospike/{dsl => ael}/IndexContext.java | 10 +- .../aerospike/{dsl => ael}/ParseResult.java | 12 +- .../{dsl => ael}/ParsedExpression.java | 26 +-- .../{dsl => ael}/PlaceholderValues.java | 2 +- .../{dsl => ael}/annotation/Beta.java | 2 +- .../DSLParser.java => ael/api/AelParser.java} | 34 +-- .../client/AerospikeException.java | 2 +- .../{dsl => ael}/client/ResultCode.java | 2 +- .../aerospike/{dsl => ael}/client/Value.java | 12 +- .../{dsl => ael}/client/cdt/CTX.java | 12 +- .../client/cdt/ListReturnType.java | 2 +- .../{dsl => ael}/client/cdt/MapOrder.java | 2 +- .../client/cdt/MapReturnType.java | 2 +- .../{dsl => ael}/client/command/Buffer.java | 10 +- .../client/command/ParticleType.java | 2 +- .../{dsl => ael}/client/exp/Exp.java | 8 +- .../{dsl => ael}/client/exp/ExpReadFlags.java | 2 +- .../client/exp/ExpWriteFlags.java | 4 +- .../{dsl => ael}/client/exp/Expression.java | 6 +- .../{dsl => ael}/client/exp/ListExp.java | 12 +- .../{dsl => ael}/client/exp/MapExp.java | 10 +- .../client/fluent/AerospikeComparator.java | 4 +- .../{dsl => ael}/client/query/Filter.java | 16 +- .../client/query/IndexCollectionType.java | 2 +- .../{dsl => ael}/client/query/IndexType.java | 2 +- .../{dsl => ael}/client/query/RegexFlag.java | 2 +- .../{dsl => ael}/client/util/Crypto.java | 2 +- .../{dsl => ael}/client/util/Pack.java | 8 +- .../{dsl => ael}/client/util/Packer.java | 14 +- .../client/util/ThreadLocalData.java | 2 +- .../{dsl => ael}/client/util/Unpacker.java | 10 +- .../{dsl => ael}/client/util/Utf8.java | 4 +- .../impl/AelParserErrorListener.java} | 12 +- .../impl/AelParserImpl.java} | 46 ++-- .../{dsl => ael}/parts/AbstractPart.java | 8 +- .../parts/ExpressionContainer.java | 2 +- .../{dsl => ael}/parts/cdt/CdtPart.java | 16 +- .../parts/cdt/list/ListIndex.java | 14 +- .../parts/cdt/list/ListIndexRange.java | 22 +- .../{dsl => ael}/parts/cdt/list/ListPart.java | 12 +- .../{dsl => ael}/parts/cdt/list/ListRank.java | 14 +- .../parts/cdt/list/ListRankRange.java | 22 +- .../parts/cdt/list/ListRankRangeRelative.java | 26 +-- .../parts/cdt/list/ListTypeDesignator.java | 12 +- .../parts/cdt/list/ListValue.java | 18 +- .../parts/cdt/list/ListValueList.java | 20 +- .../parts/cdt/list/ListValueRange.java | 20 +- .../{dsl => ael}/parts/cdt/map/MapIndex.java | 14 +- .../parts/cdt/map/MapIndexRange.java | 22 +- .../parts/cdt/map/MapIndexRangeRelative.java | 24 +-- .../{dsl => ael}/parts/cdt/map/MapKey.java | 16 +- .../parts/cdt/map/MapKeyList.java | 20 +- .../parts/cdt/map/MapKeyRange.java | 20 +- .../{dsl => ael}/parts/cdt/map/MapPart.java | 8 +- .../{dsl => ael}/parts/cdt/map/MapRank.java | 14 +- .../parts/cdt/map/MapRankRange.java | 22 +- .../parts/cdt/map/MapRankRangeRelative.java | 26 +-- .../parts/cdt/map/MapTypeDesignator.java | 10 +- .../{dsl => ael}/parts/cdt/map/MapValue.java | 18 +- .../parts/cdt/map/MapValueList.java | 20 +- .../parts/cdt/map/MapValueRange.java | 20 +- .../parts/controlstructure/AndStructure.java | 6 +- .../controlstructure/ExclusiveStructure.java | 6 +- .../parts/controlstructure/LetStructure.java | 6 +- .../parts/controlstructure/OrStructure.java | 6 +- .../parts/controlstructure/WhenStructure.java | 4 +- .../parts/operand/BlobOperand.java | 6 +- .../parts/operand/BooleanOperand.java | 8 +- .../parts/operand/FloatOperand.java | 6 +- .../parts/operand/FunctionArgs.java | 4 +- .../parts/operand/IntOperand.java | 6 +- .../parts/operand/LetOperand.java | 4 +- .../parts/operand/ListOperand.java | 6 +- .../parts/operand/MapOperand.java | 6 +- .../parts/operand/MetadataOperand.java | 6 +- .../parts/operand/OperandFactory.java | 10 +- .../parts/operand/ParsedValueOperand.java | 2 +- .../parts/operand/PlaceholderOperand.java | 6 +- .../parts/operand/StringOperand.java | 10 +- .../parts/operand/VariableOperand.java | 6 +- .../{dsl => ael}/parts/path/BasePath.java | 6 +- .../{dsl => ael}/parts/path/BinPart.java | 6 +- .../{dsl => ael}/parts/path/Path.java | 14 +- .../{dsl => ael}/parts/path/PathFunction.java | 8 +- .../{dsl => ael}/util/ParsingUtils.java | 38 ++-- .../{dsl => ael}/util/PathOperandUtils.java | 40 ++-- .../{dsl => ael}/util/TypeUtils.java | 8 +- .../{dsl => ael}/util/ValidationUtils.java | 12 +- .../visitor/ExpressionConditionVisitor.java | 114 +++++----- .../visitor/NoApplicableFilterException.java | 8 +- .../{dsl => ael}/visitor/VisitorUtils.java | 160 +++++++------- .../aerospike/{dsl => ael}/ctx/CtxTests.java | 92 ++++---- .../ArithmeticExpressionsTests.java | 52 ++--- .../expression/BareGetFunctionTests.java | 58 ++--- .../expression/BinExpressionsTests.java | 16 +- .../{dsl => ael}/expression/BlobTests.java | 66 +++--- .../{dsl => ael}/expression/CastingTests.java | 32 +-- .../expression/ControlStructuresTests.java | 8 +- .../expression/ExplicitTypesTests.java | 48 ++--- .../expression/ImplicitTypesTests.java | 8 +- .../{dsl => ael}/expression/InBinTests.java | 20 +- .../expression/InCompositeTests.java | 14 +- .../expression/InExplicitTypeTests.java | 50 ++--- .../expression/InGrammarConflictTests.java | 22 +- .../expression/InLiteralTests.java | 22 +- .../expression/InNegativeTests.java | 110 +++++----- .../expression/InPlaceholderTests.java | 14 +- .../expression/ListExpressionsTests.java | 42 ++-- .../expression/LogicalExpressionsTests.java | 32 +-- .../MapAndListExpressionsTests.java | 20 +- .../expression/MapExpressionsTests.java | 42 ++-- .../expression/NumericLiteralsTests.java | 82 +++---- .../expression/RecordMetadataTests.java | 14 +- .../expression/SyntaxErrorTests.java | 84 ++++---- .../filter/ArithmeticFiltersTests.java | 16 +- .../{dsl => ael}/filter/BinFiltersTests.java | 18 +- .../filter/ExplicitTypesFiltersTests.java | 50 ++--- .../filter/ImplicitTypesFiltersTests.java | 6 +- .../filter/ListExpressionsTests.java | 20 +- .../{dsl => ael}/index/IndexContextTests.java | 8 +- .../{dsl => ael}/index/IndexTests.java | 6 +- .../parsedExpression/InExprTests.java | 114 +++++----- .../LogicalParsedExpressionTests.java | 200 +++++++++--------- .../parsedExpression/PlaceholdersTests.java | 90 ++++---- .../parts/operand/OperandFactoryTests.java | 6 +- .../{dsl => ael}/util/TestUtils.java | 76 +++---- 143 files changed, 1612 insertions(+), 1632 deletions(-) rename src/main/antlr4/com/aerospike/{dsl => ael}/Condition.g4 (99%) rename src/main/java/com/aerospike/{dsl/DslParseException.java => ael/AelParseException.java} (60%) rename src/main/java/com/aerospike/{dsl => ael}/ExpressionContext.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/Index.java (93%) rename src/main/java/com/aerospike/{dsl => ael}/IndexContext.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/ParseResult.java (65%) rename src/main/java/com/aerospike/{dsl => ael}/ParsedExpression.java (77%) rename src/main/java/com/aerospike/{dsl => ael}/PlaceholderValues.java (97%) rename src/main/java/com/aerospike/{dsl => ael}/annotation/Beta.java (92%) rename src/main/java/com/aerospike/{dsl/api/DSLParser.java => ael/api/AelParser.java} (87%) rename src/main/java/com/aerospike/{dsl => ael}/client/AerospikeException.java (99%) rename src/main/java/com/aerospike/{dsl => ael}/client/ResultCode.java (99%) rename src/main/java/com/aerospike/{dsl => ael}/client/Value.java (99%) rename src/main/java/com/aerospike/{dsl => ael}/client/cdt/CTX.java (94%) rename src/main/java/com/aerospike/{dsl => ael}/client/cdt/ListReturnType.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/cdt/MapOrder.java (97%) rename src/main/java/com/aerospike/{dsl => ael}/client/cdt/MapReturnType.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/command/Buffer.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/command/ParticleType.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/Exp.java (99%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/ExpReadFlags.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/ExpWriteFlags.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/Expression.java (95%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/ListExp.java (97%) rename src/main/java/com/aerospike/{dsl => ael}/client/exp/MapExp.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/fluent/AerospikeComparator.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/query/Filter.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/query/IndexCollectionType.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/query/IndexType.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/query/RegexFlag.java (97%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/Crypto.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/Pack.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/Packer.java (97%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/ThreadLocalData.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/Unpacker.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/client/util/Utf8.java (97%) rename src/main/java/com/aerospike/{dsl/impl/DSLParserErrorListener.java => ael/impl/AelParserErrorListener.java} (88%) rename src/main/java/com/aerospike/{dsl/impl/DSLParserImpl.java => ael/impl/AelParserImpl.java} (73%) rename src/main/java/com/aerospike/{dsl => ael}/parts/AbstractPart.java (85%) rename src/main/java/com/aerospike/{dsl => ael}/parts/ExpressionContainer.java (98%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/CdtPart.java (64%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListIndex.java (68%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListIndexRange.java (78%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListPart.java (78%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListRank.java (68%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListRankRange.java (78%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListRankRangeRelative.java (80%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListTypeDesignator.java (81%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListValue.java (63%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListValueList.java (77%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/list/ListValueRange.java (79%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapIndex.java (68%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapIndexRange.java (78%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapIndexRangeRelative.java (81%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapKey.java (66%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapKeyList.java (76%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapKeyRange.java (79%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapPart.java (87%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapRank.java (68%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapRankRange.java (78%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapRankRangeRelative.java (80%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapTypeDesignator.java (82%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapValue.java (63%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapValueList.java (77%) rename src/main/java/com/aerospike/{dsl => ael}/parts/cdt/map/MapValueRange.java (79%) rename src/main/java/com/aerospike/{dsl => ael}/parts/controlstructure/AndStructure.java (67%) rename src/main/java/com/aerospike/{dsl => ael}/parts/controlstructure/ExclusiveStructure.java (68%) rename src/main/java/com/aerospike/{dsl => ael}/parts/controlstructure/LetStructure.java (66%) rename src/main/java/com/aerospike/{dsl => ael}/parts/controlstructure/OrStructure.java (67%) rename src/main/java/com/aerospike/{dsl => ael}/parts/controlstructure/WhenStructure.java (76%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/BlobOperand.java (72%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/BooleanOperand.java (69%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/FloatOperand.java (75%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/FunctionArgs.java (77%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/IntOperand.java (75%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/LetOperand.java (87%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/ListOperand.java (74%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/MapOperand.java (75%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/MetadataOperand.java (94%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/OperandFactory.java (93%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/ParsedValueOperand.java (87%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/PlaceholderOperand.java (85%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/StringOperand.java (77%) rename src/main/java/com/aerospike/{dsl => ael}/parts/operand/VariableOperand.java (73%) rename src/main/java/com/aerospike/{dsl => ael}/parts/path/BasePath.java (85%) rename src/main/java/com/aerospike/{dsl => ael}/parts/path/BinPart.java (81%) rename src/main/java/com/aerospike/{dsl => ael}/parts/path/Path.java (84%) rename src/main/java/com/aerospike/{dsl => ael}/parts/path/PathFunction.java (90%) rename src/main/java/com/aerospike/{dsl => ael}/util/ParsingUtils.java (91%) rename src/main/java/com/aerospike/{dsl => ael}/util/PathOperandUtils.java (96%) rename src/main/java/com/aerospike/{dsl => ael}/util/TypeUtils.java (86%) rename src/main/java/com/aerospike/{dsl => ael}/util/ValidationUtils.java (76%) rename src/main/java/com/aerospike/{dsl => ael}/visitor/ExpressionConditionVisitor.java (93%) rename src/main/java/com/aerospike/{dsl => ael}/visitor/NoApplicableFilterException.java (79%) rename src/main/java/com/aerospike/{dsl => ael}/visitor/VisitorUtils.java (95%) rename src/test/java/com/aerospike/{dsl => ael}/ctx/CtxTests.java (83%) rename src/test/java/com/aerospike/{dsl => ael}/expression/ArithmeticExpressionsTests.java (94%) rename src/test/java/com/aerospike/{dsl => ael}/expression/BareGetFunctionTests.java (68%) rename src/test/java/com/aerospike/{dsl => ael}/expression/BinExpressionsTests.java (91%) rename src/test/java/com/aerospike/{dsl => ael}/expression/BlobTests.java (91%) rename src/test/java/com/aerospike/{dsl => ael}/expression/CastingTests.java (92%) rename src/test/java/com/aerospike/{dsl => ael}/expression/ControlStructuresTests.java (96%) rename src/test/java/com/aerospike/{dsl => ael}/expression/ExplicitTypesTests.java (94%) rename src/test/java/com/aerospike/{dsl => ael}/expression/ImplicitTypesTests.java (97%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InBinTests.java (85%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InCompositeTests.java (97%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InExplicitTypeTests.java (93%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InGrammarConflictTests.java (93%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InLiteralTests.java (93%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InNegativeTests.java (84%) rename src/test/java/com/aerospike/{dsl => ael}/expression/InPlaceholderTests.java (94%) rename src/test/java/com/aerospike/{dsl => ael}/expression/ListExpressionsTests.java (95%) rename src/test/java/com/aerospike/{dsl => ael}/expression/LogicalExpressionsTests.java (86%) rename src/test/java/com/aerospike/{dsl => ael}/expression/MapAndListExpressionsTests.java (92%) rename src/test/java/com/aerospike/{dsl => ael}/expression/MapExpressionsTests.java (96%) rename src/test/java/com/aerospike/{dsl => ael}/expression/NumericLiteralsTests.java (88%) rename src/test/java/com/aerospike/{dsl => ael}/expression/RecordMetadataTests.java (95%) rename src/test/java/com/aerospike/{dsl => ael}/expression/SyntaxErrorTests.java (75%) rename src/test/java/com/aerospike/{dsl => ael}/filter/ArithmeticFiltersTests.java (98%) rename src/test/java/com/aerospike/{dsl => ael}/filter/BinFiltersTests.java (91%) rename src/test/java/com/aerospike/{dsl => ael}/filter/ExplicitTypesFiltersTests.java (88%) rename src/test/java/com/aerospike/{dsl => ael}/filter/ImplicitTypesFiltersTests.java (80%) rename src/test/java/com/aerospike/{dsl => ael}/filter/ListExpressionsTests.java (88%) rename src/test/java/com/aerospike/{dsl => ael}/index/IndexContextTests.java (98%) rename src/test/java/com/aerospike/{dsl => ael}/index/IndexTests.java (97%) rename src/test/java/com/aerospike/{dsl => ael}/parsedExpression/InExprTests.java (94%) rename src/test/java/com/aerospike/{dsl => ael}/parsedExpression/LogicalParsedExpressionTests.java (91%) rename src/test/java/com/aerospike/{dsl => ael}/parsedExpression/PlaceholdersTests.java (85%) rename src/test/java/com/aerospike/{dsl => ael}/parts/operand/OperandFactoryTests.java (88%) rename src/test/java/com/aerospike/{dsl => ael}/util/TestUtils.java (74%) diff --git a/README.md b/README.md index ad92e726..f6e5ffaf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Aerospike Expression DSL -[![Build project](https://github.com/citrusleaf/expression-dsl-java/actions/workflows/build.yml/badge.svg)](https://github.com/citrusleaf/expression-dsl-java/actions/workflows/build.yml) +# Aerospike Expression Language +[![Build project](https://github.com/citrusleaf/aerospike-expression-lang-java/actions/workflows/build.yml/badge.svg)](https://github.com/citrusleaf/aerospike-expression-lang-java/actions/workflows/build.yml) > [!NOTE] > This is a developer preview, not yet ready for production use, but with future releases planned. We appreciate feedback from the Aerospike > developer community through GitHub issues. -Aerospike Expression DSL is a Java library that allows translating a canonical Aerospike Expression DSL string into an Aerospike Expression. +Aerospike Expression Language (AEL) is a Java library that allows translating a canonical AEL string into an Aerospike Expression. [Aerospike Expressions](https://aerospike.com/docs/server/guide/expressions) is a functional language for applying predicates to bin data and record metadata. Expressions are essential to different areas of server functionality: @@ -14,14 +14,14 @@ Expressions are essential to different areas of server functionality: * XDR Filter Expressions (introduced in Aerospike Database 5.3) * Operation Expressions (introduced in Aerospike Database 5.6) -## Why DSL +## Why AEL A filter expression is created by combining the expression predicate classes using Polish notation, compiling it, and then attaching it to the operation. This approach has several limitations, including a difficult developer experience. Expressions require the use of native language clients. As a result, filter expressions cannot be used in places that only accept a filter written in text. As a workaround, expressions can be created separately using a native client and exported as a base64-encoded string. -A text-based DSL can be converted into Expressions and be used across frameworks, connectors, gateways, data browsers, IDE plug-ins, and all language-native clients. +A text-based AEL can be converted into Expressions and be used across frameworks, connectors, gateways, data browsers, IDE plug-ins, and all language-native clients. Having a standard way to describe filters is easy to document and makes it accessible to developers regardless of their language preferences. ## Prerequisites @@ -29,23 +29,23 @@ Having a standard way to describe filters is easy to document and makes it acces * Aerospike Server version 5.2+ ## Build from source -Aerospike Expression DSL uses [ANTLR v4](https://github.com/antlr/antlr4) for its parsing capabilities. +Aerospike Expression Language uses [ANTLR v4](https://github.com/antlr/antlr4) for its parsing capabilities. When modifying the grammar file you will need to re-generate the ANTLR sources by running the following command: `mvn clean generate-sources compile` ## Usage examples -### Parsing DSL expression +### Parsing AEL expression ```java -import com.aerospike.dsl.api.DSLParser; -import com.aerospike.dsl.impl.DSLParserImpl; +import com.aerospike.ael.api.AelParser; +import com.aerospike.ael.impl.AelParserImpl; -// String DSL expression +// String AEL expression String input = "$.intBin1 > 100 and $.intBin2 > 100"; -// Instantiating DSL parser -DSLParser parser = new DSLParserImpl(); +// Instantiating AEL parser +AelParser parser = new AelParserImpl(); // Providing list of existing secondary indexes // At most only one index will be chosen based on its namespace and binValuesRatio (cardinality) // If cardinality of multiple indexes is the same, the index is chosen alphabetically @@ -54,7 +54,7 @@ List indexes = List.of( Index.builder().namespace("namespace").bin("intBin1").indexType(IndexType.NUMERIC).binValuesRatio(1).build(), Index.builder().namespace("namespace2").bin("intBin2").indexType(IndexType.NUMERIC).binValuesRatio(1).build() ); -// Parsing DSL expression +// Parsing AEL expression ParsedExpression expression = parser.parseExpression( // We provide expression context (it may also contain placeholders values as an optional argument) ExpressionContext.of(input), diff --git a/docs/api-reference.md b/docs/api-reference.md index 96366e75..b590b562 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1,49 +1,49 @@ # API Reference -The Expression DSL library has a concise API. This document highlights the most important classes and methods you will interact with. +The Expression Language library has a concise API. This document highlights the most important classes and methods you will interact with. For a complete, detailed reference, please consult the Javadoc for the library. ## Core Classes -### `com.aerospike.dsl.api.DSLParser` +### `com.aerospike.ael.api.AelParser` This is the main interface and entry point for the library. * **`ParsedExpression parseExpression(ExpressionContext input)`** - * **Description**: The primary method used to parse a DSL string when no secondary indexes are provided. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. + * **Description**: The primary method used to parse a AEL string when no secondary indexes are provided. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. * **`ParsedExpression parseExpression(ExpressionContext input, IndexContext indexContext)`** - * **Description**: The primary method used to parse a DSL string. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. + * **Description**: The primary method used to parse a AEL string. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. * **Parameters**: - * `input`: An `ExpressionContext` object containing the DSL string and any placeholder values. - * **Description**: The primary method used to parse a DSL string. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. + * `input`: An `ExpressionContext` object containing the AEL string and any placeholder values. + * **Description**: The primary method used to parse a AEL string. It returns a `ParsedExpression` object that contains the compiled result, which can be reused. * **Parameters**: - * `input`: An `ExpressionContext` object containing the DSL string and any placeholder values. + * `input`: An `ExpressionContext` object containing the AEL string and any placeholder values. * `indexContext`: An optional `IndexContext` object containing a list of available secondary indexes for query optimization. Can be `null`. * **Returns**: A `ParsedExpression` object representing the compiled expression tree. -### `com.aerospike.dsl.ExpressionContext` +### `com.aerospike.ael.ExpressionContext` -This class is a container for the DSL string and any values to be substituted for placeholders. +This class is a container for the AEL string and any values to be substituted for placeholders. -* **`static ExpressionContext of(String dslString)`**: Creates a context for a DSL string without placeholders. -* **`static ExpressionContext of(String dslString, PlaceholderValues values)`**: Creates a context for a DSL string that uses `?` placeholders, providing the values to be substituted. +* **`static ExpressionContext of(String aelString)`**: Creates a context for a AEL string without placeholders. +* **`static ExpressionContext of(String aelString, PlaceholderValues values)`**: Creates a context for a AEL string that uses `?` placeholders, providing the values to be substituted. -### `com.aerospike.dsl.ParsedExpression` +### `com.aerospike.ael.ParsedExpression` This object represents the compiled, reusable result of a parsing operation. It is thread-safe. * **`ParseResult getResult()`**: Returns the final `ParseResult` for an expression that does not contain placeholders. * **`ParseResult getResult(PlaceholderValues values)`**: Returns the final `ParseResult` by substituting the given placeholder values into the compiled expression tree. This is highly efficient as it bypasses the parsing step. -### `com.aerospike.dsl.ParseResult` +### `com.aerospike.ael.ParseResult` This class holds the final, concrete outputs of the parsing and substitution process. -* **`Filter getFilter()`**: Returns an Aerospike `Filter` object if the parser was able to optimize a portion of the DSL string into a secondary index query. Returns `null` if no optimization was possible. -* **`com.aerospike.client.exp.Expression.Exp getExp()`**: Returns the Aerospike `Exp` object representing the DSL filter logic. This is the part of the expression that will be executed on the server for records that pass the secondary index filter. If the entire DSL string was converted into a `Filter`, this may be `null`. +* **`Filter getFilter()`**: Returns an Aerospike `Filter` object if the parser was able to optimize a portion of the AEL string into a secondary index query. Returns `null` if no optimization was possible. +* **`com.aerospike.client.exp.Expression.Exp getExp()`**: Returns the Aerospike `Exp` object representing the AEL filter logic. This is the part of the expression that will be executed on the server for records that pass the secondary index filter. If the entire AEL string was converted into a `Filter`, this may be `null`. -### `com.aerospike.dsl.IndexContext` +### `com.aerospike.ael.IndexContext` A container for the information required for automatic secondary index optimization. @@ -67,7 +67,7 @@ A container for the information required for automatic secondary index optimizat matches using the normal automatic rules (for example, index type and cardinality, then alphabetically). If no index matches the bin and namespace, or `binToUse` is `null` or blank, the parser falls back to fully automatic index selection. -### `com.aerospike.dsl.Index` +### `com.aerospike.ael.Index` Represents an available secondary index for optimization. @@ -84,11 +84,11 @@ Here is a recap of how the classes work together in a typical use case: ```java // 1. Get a parser instance -DSLParser parser = new DSLParserImpl(); +AelParser parser = new AelParserImpl(); // 2. Define the context for the expression and placeholders -String dsl = "$.age > ?0"; -ExpressionContext context = ExpressionContext.of(dsl, PlaceholderValues.of(30)); +String ael = "$.age > ?0"; +ExpressionContext context = ExpressionContext.of(ael, PlaceholderValues.of(30)); // (Optional) Define the index context for optimization IndexContext indexContext = IndexContext.of("namespace", availableIndexes); diff --git a/docs/getting-started.md b/docs/getting-started.md index 8da2f59c..b7b9f859 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,10 +1,10 @@ -# Getting Started with Aerospike Expression DSL +# Getting Started with Aerospike Expression Language -Welcome to the Aerospike Expression DSL for Java! Let's walk you through the first steps, from setup to running your first query. +Welcome to the Aerospike Expression Language for Java! Let's walk you through the first steps, from setup to running your first query. -## What is the Expression DSL? +## What is the Expression Language? -The Aerospike Expression DSL is a Java library that provides a simple, string-based language to create powerful server-side filters. Instead of building complex filter objects in Java, you can write an intuitive expression string, which the library translates into a native Aerospike Expression. +The Aerospike Expression Language is a Java library that provides a simple, string-based language to create powerful server-side filters. Instead of building complex filter objects in Java, you can write an intuitive expression string, which the library translates into a native Aerospike Expression. For example, instead of writing this in Java: @@ -40,14 +40,14 @@ Let's build and run a complete example. ### 1. Project Setup -Add the Expression DSL and the Aerospike Java Client as dependencies to your project. +Add the Expression Language and the Aerospike Java Client as dependencies to your project. **Maven (`pom.xml`):** ```xml com.aerospike - aerospike-expression-dsl + aerospike-expression-lang-java 0.1.0 @@ -60,7 +60,7 @@ Add the Expression DSL and the Aerospike Java Client as dependencies to your pro ### 2. Write the Code -Here is a Java example. It connects to a local Aerospike instance, writes a few sample records, and then uses a DSL expression to query for a subset of that data. +Here is a Java example. It connects to a local Aerospike instance, writes a few sample records, and then uses a AEL expression to query for a subset of that data. ```java import com.aerospike.client.*; @@ -69,12 +69,12 @@ import com.aerospike.client.exp.Expression; import com.aerospike.client.policy.QueryPolicy; import com.aerospike.client.query.RecordSet; import com.aerospike.client.query.Statement; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.ParsedExpression; -import com.aerospike.dsl.api.DSLParser; -import com.aerospike.dsl.impl.DSLParserImpl; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.ParsedExpression; +import com.aerospike.ael.api.AelParser; +import com.aerospike.ael.impl.AelParserImpl; -public class DslQuickstart { +public class AelQuickstart { public static void main(String[] args) { // 1. Connect to Aerospike @@ -82,12 +82,12 @@ public class DslQuickstart { // 2. Write some sample data writeSampleData(client); - // 3. Define and Parse the DSL Expression - DSLParser parser = new DSLParserImpl(); - String dslString = "$.age > 30 and $.city == 'New York'"; - System.out.println("Using DSL Expression: " + dslString); + // 3. Define and Parse the AEL Expression + AelParser parser = new AelParserImpl(); + String aelString = "$.age > 30 and $.city == 'New York'"; + System.out.println("Using AEL Expression: " + aelString); - ParsedExpression parsedExpression = parser.parseExpression(ExpressionContext.of(dslString)); + ParsedExpression parsedExpression = parser.parseExpression(ExpressionContext.of(aelString)); Expression filterExpression = Exp.build(parsedExpression.getResult().getExp()); // 4. Create and Execute the Query @@ -127,18 +127,18 @@ public class DslQuickstart { ### 3. Run and Verify -When you run this code, you will see the following output. Notice that only the two records matching the DSL filter (`age > 30` AND `city == 'New York'`) are returned. +When you run this code, you will see the following output. Notice that only the two records matching the AEL filter (`age > 30` AND `city == 'New York'`) are returned. ``` Sample data written. -Using DSL Expression: $.age > 30 and $.city == 'New York' +Using AEL Expression: $.age > 30 and $.city == 'New York' Query Results: (gen:1),(exp:486523),(bins:(name:Bob),(age:35),(city:New York)) (gen:1),(exp:486523),(bins:(name:Charlie),(age:42),(city:New York)) ``` -Congratulations! You've successfully used the Expression DSL to filter records in Aerospike. +Congratulations! You've successfully used the Expression Language to filter records in Aerospike. ### Next Steps diff --git a/docs/guides/01-writing-your-first-expression.md b/docs/guides/01-writing-your-first-expression.md index 1c859e36..061c83a9 100644 --- a/docs/guides/01-writing-your-first-expression.md +++ b/docs/guides/01-writing-your-first-expression.md @@ -1,10 +1,10 @@ # Guide: Writing Your First Expression -This guide covers the fundamental syntax of the Aerospike Expression DSL. You will learn how to filter records based on bin values and combine multiple conditions. +This guide covers the fundamental syntax of the Aerospike Expression Language. You will learn how to filter records based on bin values and combine multiple conditions. -## Anatomy of the DSL +## Anatomy of the AEL -The Expression DSL is a functional language for applying predicates to Aerospike bin data and record metadata. Here’s a breakdown of a simple example: +The Aerospike Expression Language is a functional language for applying predicates to Aerospike bin data and record metadata. Here’s a breakdown of a simple example: ``` $.binName > 100 @@ -22,7 +22,7 @@ All expressions start with `$.` to signify the root of the record. You follow it ### Operators -The DSL supports a rich set of operators. +The AEL supports a rich set of operators. * **Comparison**: `==`, `!=`, `>`, `>=`, `<`, `<=` * **Logical**: `and`, `or`, `not()`, `exclusive()` @@ -43,7 +43,7 @@ Here are some examples of basic filters on different data types. To filter on a bin containing an integer or float, use standard comparison operators. -**DSL String:** +**AEL String:** ``` "$.age >= 30" ``` @@ -60,7 +60,7 @@ queryPolicy.filterExp = Exp.build(parsed.getResult().getExp()); Remember to enclose string literals in single quotes. -**DSL String:** +**AEL String:** ``` "$.country == 'US'" ``` @@ -73,7 +73,7 @@ ExpressionContext context = ExpressionContext.of("$.country == 'US'"); ### Boolean Bins -**DSL String:** +**AEL String:** ``` "$.active == true" ``` @@ -86,7 +86,7 @@ You can build complex filters by combining conditions with `and` and `or`. Use p Returns records that match **all** conditions. -**DSL String:** +**AEL String:** ``` "$.age > 30 and $.country == 'US'" ``` @@ -95,7 +95,7 @@ Returns records that match **all** conditions. Returns records that match **at least one** of the conditions. -**DSL String:** +**AEL String:** ``` "$.tier == 'premium' or $.logins > 100" ``` @@ -104,7 +104,7 @@ Returns records that match **at least one** of the conditions. Negates a condition. -**DSL String:** +**AEL String:** ``` "not($.country == 'US')" ``` @@ -113,7 +113,7 @@ Negates a condition. Creates an expression that returns true if only one of its parts is true. -**DSL String:** +**AEL String:** ``` "exclusive($.x < '5', $.x > '5')" ``` diff --git a/docs/guides/02-working-with-lists-and-maps.md b/docs/guides/02-working-with-lists-and-maps.md index 90b395e9..6878a188 100644 --- a/docs/guides/02-working-with-lists-and-maps.md +++ b/docs/guides/02-working-with-lists-and-maps.md @@ -1,6 +1,6 @@ # Guide: Working with Lists and Maps -The Expression DSL provides a powerful and intuitive syntax for filtering on Complex Data Types (CDTs), such as Lists and Maps. This guide will show you how to query these structures. +The Expression Language provides a powerful and intuitive syntax for filtering on Complex Data Types (CDTs), such as Lists and Maps. This guide will show you how to query these structures. The syntax allows to work with complex data filtering in a readable manner, leading to highly efficient queries. @@ -23,7 +23,7 @@ Let's say you have a `user` bin that is a map containing profile information. } ``` -**DSL String:** +**AEL String:** To find users with more than 100 logins, you can write: ``` "$.user.logins > 100" @@ -48,7 +48,7 @@ If a map key contains spaces or special characters, you can use single quotes. } ``` -**DSL String:** +**AEL String:** ``` "$.metrics.'daily logins' > 20" ``` @@ -70,14 +70,14 @@ Assuming we have the same map containing profile information: Indexes are 0-based. To access the first element, use `[0]`. -**DSL String:** +**AEL String:** To find records with element indexed at 0 having value `Alice`, you can write it in a short form: ``` "$.user.{0} == 'Alice'" ``` -Or use the full form of such DSL string if needed: +Or use the full form of such AEL string if needed: ``` "$.user.{0}.get(type: STRING, return: VALUE) == 'Alice'" @@ -85,7 +85,7 @@ Or use the full form of such DSL string if needed: ### Filtering by Map Value -**DSL String:** +**AEL String:** To find records having element with value 150, you can write: ``` "$.user.{=150}" @@ -110,7 +110,7 @@ Assuming we have an ordered map containing user preferences information: } } ``` -**DSL String:** +**AEL String:** To find records having value of an element with rank 2 larger than 20, you can write: ``` "$.user.{#2} > 20" @@ -135,7 +135,7 @@ Let's say you have a `scores` list bin containing test scores. } ``` -**DSL String:** +**AEL String:** To find records where the first score is greater than 90: ``` "$.scores.[0] > 90" @@ -143,7 +143,7 @@ To find records where the first score is greater than 90: ### Filtering by List Value -**DSL String:** +**AEL String:** To find records with a scores element equal to 90: ``` "$.scores.[=90]" @@ -156,7 +156,7 @@ For instance, you can use counting function to find if there are multiple record ### Filtering by List Rank -**DSL String:** +**AEL String:** To find records where the value of scores element with rank 2 is larger than 30: ``` "$.scores.[#2] > 30" @@ -164,7 +164,7 @@ To find records where the value of scores element with rank 2 is larger than 30: ## Querying Nested Structures -The real power of the DSL shines when you combine these accessors to query deeply nested data. +The real power of the AEL shines when you combine these accessors to query deeply nested data. ### Map containing a List @@ -180,7 +180,7 @@ Imagine a `user` bin where one of the map values is a list of roles. } ``` -**DSL String:** +**AEL String:** To find a user whose first role is "admin": ``` "$.user.roles.[0] == 'admin'" @@ -200,7 +200,7 @@ Now consider a list of `devices`, where each element is a map. } ``` -**DSL String:** +**AEL String:** To find records where the second device is a laptop: ``` "$.devices.[1].type == 'laptop'" @@ -210,7 +210,7 @@ To find records where the second device is a laptop: You can call functions on CDT bins, such as counting the size. -**DSL String:** +**AEL String:** To find records where the `devices` list contains more than 1 item: ``` "$.devices.count() > 1" diff --git a/docs/guides/03-filtering-on-record-metadata.md b/docs/guides/03-filtering-on-record-metadata.md index c6ca770a..268cb014 100644 --- a/docs/guides/03-filtering-on-record-metadata.md +++ b/docs/guides/03-filtering-on-record-metadata.md @@ -1,6 +1,6 @@ # Guide: Filtering on Record Metadata -Aerospike tracks several metadata fields for each record, such as its time-to-live (TTL), last update time and so on. The Expression DSL provides special functions to use this metadata in your filter expressions. +Aerospike tracks several metadata fields for each record, such as its time-to-live (TTL), last update time and so on. The Expression Language provides special functions to use this metadata in your filter expressions. All metadata functions are called on the record root, using the `$.` prefix. @@ -14,14 +14,14 @@ Returns the remaining TTL of the record in seconds. **Use Case:** Find all records that will expire in the next 24 hours. -**DSL String:** +**AEL String:** ``` "$.ttl() < 86400" // 86400 seconds = 24 hours ``` **Use Case:** Find all records that are set to never expire. The server represents this with a TTL of 0, but special care should be taken depending on server version. A common convention might be to check for a very large TTL if your application sets them. For records that are created without a TTL and the namespace has a default TTL, `ttl()` will reflect that. A record explicitly set to never expire (TTL -1 on write) will have a void time of 0, and its TTL will be calculated from that. On server versions 4.2+, a TTL of -1 can be used to signify "never expire". -**DSL String:** +**AEL String:** To find records that will not expire (assuming server 4.2+ and TTL set to -1 on write): ``` "$.ttl() == -1" @@ -37,7 +37,7 @@ Returns the timestamp of when the record was last updated, in nanoseconds since **Use Case:** Find records updated before the year 2023. -**DSL String:** +**AEL String:** ``` // Timestamp for 2023-01-01T00:00:00Z in nanoseconds "$.lastUpdate() < 1672531200000000000" @@ -49,7 +49,7 @@ Returns the number of milliseconds that have passed since the record was last up **Use Case:** Find all records that have not been modified in the last 7 days. -**DSL String:** +**AEL String:** ``` "$.sinceUpdate() > 604800000" // 7 * 24 * 60 * 60 * 1000 milliseconds ``` @@ -64,7 +64,7 @@ Returns the amount of storage the record occupies on disk, in bytes. **Use Case:** Find "large" records that consume more than 1 megabyte of disk space. -**DSL String:** +**AEL String:** ``` "$.deviceSize() > 1048576" // 1024 * 1024 bytes ``` @@ -73,7 +73,7 @@ Returns the amount of storage the record occupies on disk, in bytes. Returns the amount of storage the record occupies in memory, in bytes. This is relevant for hybrid storage namespaces (data in memory). -**DSL String:** +**AEL String:** ``` "$.memorySize() > 131072" // 128 KB ``` @@ -86,7 +86,7 @@ Returns `true` if the record is a tombstone (i.e., it has been deleted but not y **Use Case:** Find records that have been deleted but are still occupying space. -**DSL String:** +**AEL String:** ``` "$.isTombstone() == true" ``` @@ -97,7 +97,7 @@ Returns the name of the set the record belongs to. **Use Case:** Find records that are in either the 'customers' or 'prospects' set. -**DSL String:** +**AEL String:** ``` "$.setName() == 'customers' or $.setName() == 'prospects'" ``` @@ -108,7 +108,7 @@ Returns the record's digest (its unique ID) modulo some integer value. This is a **Use Case:** Process 1/4 of the records in a batch job. -**DSL String:** +**AEL String:** This expression will be true for roughly 25% of your records. ``` "$.digestModulo(4) == 0" diff --git a/docs/guides/04-arithmetic-expressions.md b/docs/guides/04-arithmetic-expressions.md index 5c559b91..5b1aaa61 100644 --- a/docs/guides/04-arithmetic-expressions.md +++ b/docs/guides/04-arithmetic-expressions.md @@ -1,12 +1,12 @@ # Advanced Topic: Arithmetic Expressions -The Expression DSL allows you to perform certain simple arithmetic operations directly on bin values within your expressions. This enables you to push mathematical computations to the Aerospike server, avoiding the need to pull data to the client for processing. +The Expression Language allows you to perform certain simple arithmetic operations directly on bin values within your expressions. This enables you to push mathematical computations to the Aerospike server, avoiding the need to pull data to the client for processing. This is useful for a wide range of scenarios, such as dynamic price calculations, scoring, or checking computed thresholds. ## Supported Arithmetic Operators -The DSL supports the standard set of arithmetic operators: +The AEL supports the standard set of arithmetic operators: * `+` (Addition) * `-` (Subtraction) @@ -20,7 +20,7 @@ You can use these operators on numeric bin values and literal numeric values. Imagine an e-commerce application where you want to find all orders that have a `quantity` of at least 5 and for which the `order_total` is greater than `quantity * price_per_item * 0.9` (representing a 10% discount threshold). -### DSL String +### AEL String You can write this complex logic as a single, clear expression: @@ -44,8 +44,8 @@ This entire computation happens on the server, which is efficient. **Java Usage:** ```java // Find orders with quantity larger than 5 and arithmetical condition on order_total -String dsl = "$.quantity >= 5 and $.order_total > ($.quantity * $.price_per_item * 0.9)"; -ExpressionContext context = ExpressionContext.of(dsl); +String ael = "$.quantity >= 5 and $.order_total > ($.quantity * $.price_per_item * 0.9)"; +ExpressionContext context = ExpressionContext.of(ael); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); @@ -64,7 +64,7 @@ Arithmetic expressions can be combined with placeholders to make them even more Let's say you want to find users whose `login_streak` (number of consecutive days logged in) is greater than their `account_age` (in days) divided by a configurable factor. -**DSL String with Placeholders:** +**AEL String with Placeholders:** ``` "$.login_streak > ($.account_age / ?0)" ``` @@ -72,9 +72,9 @@ Let's say you want to find users whose `login_streak` (number of consecutive day **Java Usage:** ```java // Find users whose streak is greater than their account age divided by 7 -String dsl = "$.login_streak > ($.account_age / ?0)"; +String ael = "$.login_streak > ($.account_age / ?0)"; PlaceholderValues values = PlaceholderValues.of(7); -ExpressionContext context = ExpressionContext.of(dsl, values); +ExpressionContext context = ExpressionContext.of(ael, values); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); @@ -87,7 +87,7 @@ queryPolicy.filterExp = filter; ## Operator Precedence -The DSL follows standard mathematical operator precedence. `*`, `/`, and `%` have higher precedence than `+` and `-`. You can use parentheses `()` to explicitly control the order of evaluation. +The AEL follows standard mathematical operator precedence. `*`, `/`, and `%` have higher precedence than `+` and `-`. You can use parentheses `()` to explicitly control the order of evaluation. **Example:** This expression: diff --git a/docs/guides/05-using-placeholders.md b/docs/guides/05-using-placeholders.md index 608eb548..ead79f00 100644 --- a/docs/guides/05-using-placeholders.md +++ b/docs/guides/05-using-placeholders.md @@ -1,12 +1,12 @@ # Guide: Using Placeholders for Security and Performance -Placeholders allow you to create parameterized DSL expressions. Instead of embedding literal values directly into your DSL string, you use special markers (starting with `?`) that are replaced with actual values at runtime. +Placeholders allow you to create parameterized AEL expressions. Instead of embedding literal values directly into your AEL string, you use special markers (starting with `?`) that are replaced with actual values at runtime. -This practice is recommended due to performance enhancement. It allows the DSL parser to compile the expression *once* and reuse the result many times with different values, which is much faster than re-parsing the string for every query. +This practice is recommended due to performance enhancement. It allows the AEL parser to compile the expression *once* and reuse the result many times with different values, which is much faster than re-parsing the string for every query. ## The Cost of Parsing -When you provide the `DSLParser` with a string, it performs several steps: +When you provide the `AelParser` with a string, it performs several steps: 1. **Lexing**: Breaks the string into a stream of tokens (e.g., `$.`, `age`, `>`, `100`). 2. **Parsing**: Builds an Abstract Syntax Tree (AST) representing the logical structure of the expression. 3. **Compilation**: Traverses the AST to create a template for the final result. @@ -17,7 +17,7 @@ This process has a small but non-zero CPU cost. If you are parsing the same stri Placeholders are denoted by a question mark followed by a zero-based index: `?0`, `?1`, `?2`, and so on. -**DSL String with Placeholders:** +**AEL String with Placeholders:** ``` "$.age > ?0 and $.city == ?1" ``` @@ -31,23 +31,23 @@ To use an expression with placeholders, you must provide the corresponding value ### Java Usage Example ```java -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.api.DSLParser; -import com.aerospike.dsl.impl.DSLParserImpl; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.api.AelParser; +import com.aerospike.ael.impl.AelParserImpl; // ... other imports -DSLParser parser = new DSLParserImpl(); +AelParser parser = new AelParserImpl(); -// The DSL string with indexed placeholders -String dsl = "$.age > ?0 and $.city == ?1"; +// The AEL string with indexed placeholders +String ael = "$.age > ?0 and $.city == ?1"; // Create a PlaceholderValues object with the values to substitute. // The order of values must match the placeholder indexes. PlaceholderValues values = PlaceholderValues.of(30, "New York"); // Create the ExpressionContext -ExpressionContext context = ExpressionContext.of(dsl, values); +ExpressionContext context = ExpressionContext.of(ael, values); // Parse the expression ParsedExpression parsedExpression = parser.parseExpression(context); @@ -65,12 +65,12 @@ The library automatically handles different data types for placeholders, includi **Example with different types:** ``` -String dsl = "$.lastLogin > ?0 and $.name == ?1"; +String ael = "$.lastLogin > ?0 and $.name == ?1"; // Provide a Long for the timestamp and a String for the name PlaceholderValues values = PlaceholderValues.of(1672531200000L, "Alice"); -ExpressionContext context = ExpressionContext.of(dsl, values); +ExpressionContext context = ExpressionContext.of(ael, values); // ... ``` @@ -84,9 +84,9 @@ Imagine an application that needs to query for users by age and city repeatedly. ```java // --- One-time setup --- -DSLParser parser = new DSLParserImpl(); -String dsl = "$.age > ?0 and $.city == ?1"; -ExpressionContext initialContext = ExpressionContext.of(dsl); // No values needed at first +AelParser parser = new AelParserImpl(); +String ael = "$.age > ?0 and $.city == ?1"; +ExpressionContext initialContext = ExpressionContext.of(ael); // No values needed at first // Parse the expression once and cache the result ParsedExpression cachedParsedExpression = parser.parseExpression(initialContext); diff --git a/docs/guides/06-using-secondary-indexes.md b/docs/guides/06-using-secondary-indexes.md index f191b406..17ecabbf 100644 --- a/docs/guides/06-using-secondary-indexes.md +++ b/docs/guides/06-using-secondary-indexes.md @@ -1,26 +1,26 @@ # Guide: Automatic Secondary Index Optimization -One of the most powerful features of the Expression DSL is its ability to automatically leverage accessible Aerospike secondary indexes (SI). +One of the most powerful features of the Expression Language is its ability to automatically leverage accessible Aerospike secondary indexes (SI). -When you provide the parser with a list of available indexes, it can analyze your DSL string and transform a part of it into a more performant secondary index filter. +When you provide the parser with a list of available indexes, it can analyze your AEL string and transform a part of it into a more performant secondary index filter. ## Why is this important? * **Performance**: A secondary index query is significantly faster than a full scan with a filter expression. An SI query allows the database to jump directly to the records that might match, whereas a filter expression requires the server to read every single record in the set and evaluate the expression against it. -* **Simplicity**: You don't need to manually decide which parts of your query should use an index. You can write a single, logical DSL string, and the parser will perform the optimization for you given that you +* **Simplicity**: You don't need to manually decide which parts of your query should use an index. You can write a single, logical AEL string, and the parser will perform the optimization for you given that you ## How it Works When you call `parser.parseExpression()`, you can optionally provide an `IndexContext`. This object tells the parser which namespace you are querying and which secondary indexes are available. The parser then does the following: -1. It analyzes the `and` components of your DSL expression if there are any. +1. It analyzes the `and` components of your AEL expression if there are any. 2. It compares each component against the list of available indexes. 3. If it finds a component that can be satisfied by a numeric or string range query on an indexed bin, it converts that component into an Aerospike secondary index `Filter` object. 4. It marks that component in order not to use it when building `Expression`. -5. The rest of the DSL string is converted into an `Expression`. +5. The rest of the AEL string is converted into an `Expression`. 6. The `ParseResult` then contains either one of the following entities or **both**: -* `Filter` (for the SI query) - given that the correct `IndexContext` was provided, and that the given DSL expression can be converted to a secondary index filter +* `Filter` (for the SI query) - given that the correct `IndexContext` was provided, and that the given AEL expression can be converted to a secondary index filter * `Expression` (for the scan expression filter) > **Note:** Only one secondary index can be used per query. The index will be chosen based on cardinality @@ -117,8 +117,8 @@ First, you need to represent your available index in code. ```java import com.aerospike.client.query.IndexType; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; import java.util.List; // Describe the available secondary index @@ -137,18 +137,18 @@ IndexContext indexContext = IndexContext.of("test", List.of(cityIndex)); ### 2. Parse the Expression using IndexContext -Now, provide the `indexContext` when you parse your DSL string. +Now, provide the `indexContext` when you parse your AEL string. -**DSL String:** +**AEL String:** ``` "$.city == 'New York' and $.age > 30" ``` **Java Code:** ```java -DSLParser parser = new DSLParserImpl(); -String dsl = "$.city == 'New York' and $.age > 30"; -ExpressionContext context = ExpressionContext.of(dsl); +AelParser parser = new AelParserImpl(); +String ael = "$.city == 'New York' and $.age > 30"; +ExpressionContext context = ExpressionContext.of(ael); // Provide the IndexContext to enable using SI filter ParsedExpression parsed = parser.parseExpression(context, indexContext); @@ -159,7 +159,7 @@ ParseResult result = parsed.getResult(); ```java // 3. Extract Both Filter and Expression -Filter siFilter = result.getFilter(); // This will be non-null if indexes are correct and DSL string input allows building SI filter, like in this example +Filter siFilter = result.getFilter(); // This will be non-null if indexes are correct and AEL string input allows building SI filter, like in this example Expression filterExpression = Exp.build(result.getExp()); // This will contain the scan expression filter // The parser has split the query: @@ -188,4 +188,4 @@ queryPolicy.filterExp = filterExpression; client.query(queryPolicy, stmt); ``` -By providing the `IndexContext`, you have allowed the DSL parser to transform a potentially slow scan into a fast, targeted query, without changing your original DSL logic. \ No newline at end of file +By providing the `IndexContext`, you have allowed the AEL parser to transform a potentially slow scan into a fast, targeted query, without changing your original AEL logic. \ No newline at end of file diff --git a/docs/guides/07-conditional-logic-control-structures.md b/docs/guides/07-conditional-logic-control-structures.md index cadcb3df..41923b7e 100644 --- a/docs/guides/07-conditional-logic-control-structures.md +++ b/docs/guides/07-conditional-logic-control-structures.md @@ -1,6 +1,6 @@ # Conditional Logic: Control Structures `let` and `when` -The Expression DSL supports conditional logic through `when` and `let` control structures, similar to a `CASE` statement in SQL. This allows you to build sophisticated expressions that can return different values based on a set of conditions. +The Expression Language supports conditional logic through `when` and `let` control structures, similar to a `CASE` statement in SQL. This allows you to build sophisticated expressions that can return different values based on a set of conditions. This is particularly useful for server-side data transformation or implementing complex business rules. @@ -31,9 +31,9 @@ Imagine you want to categorize users into different tiers based on their `rank` * If `rank` > 40, tier is "bronze" * Otherwise, the tier is "basic" -### DSL String +### AEL String -You can express this logic in a single DSL expression to verify a user's `tier`. +You can express this logic in a single AEL expression to verify a user's `tier`. ``` "$.tier == when($.rank > 90 => 'gold', $.rank > 70 => 'silver', $.rank > 40 => 'bronze', default => 'basic')" @@ -44,12 +44,12 @@ Let's break this down: 2. The outer expression then becomes `$.tier == 'gold'`. 3. The entire expression will return `true` if the `tier` bin for that record is indeed set to "gold", and `false` otherwise. -### Using Static DSL String in Java +### Using Static AEL String in Java ```java -String dslString = "$.tier == when($.rank > 90 => 'gold', $.rank > 70 => 'silver', $.rank > 40 => 'bronze', default => 'basic')"; +String aelString = "$.tier == when($.rank > 90 => 'gold', $.rank > 70 => 'silver', $.rank > 40 => 'bronze', default => 'basic')"; -ExpressionContext context = ExpressionContext.of(dslString); +ExpressionContext context = ExpressionContext.of(aelString); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); @@ -61,15 +61,15 @@ queryPolicy.filterExp = filter; // This query will now return only the records where the tier bin is correctly set according to the rank. ``` -### Using DSL String with Placeholders in Java +### Using AEL String with Placeholders in Java We can also use placeholders within a `when` expression for greater flexibility. Placeholders mark the places where values provided separately are matched by indexes. -This way the same DSL String can be used multiple times with different values for the same placeholders. +This way the same AEL String can be used multiple times with different values for the same placeholders. -For example, let's add placeholders to our previous DSL expression and use the same API for generating an `Expression`: +For example, let's add placeholders to our previous AEL expression and use the same API for generating an `Expression`: ```java -String dsl = "$.tier == when($.rank > ?0 => ?1, $.rank > ?2 => ?3, default => ?4)"; +String ael = "$.tier == when($.rank > ?0 => ?1, $.rank > ?2 => ?3, default => ?4)"; PlaceholderValues values = PlaceholderValues.of( 90, "gold", @@ -78,7 +78,7 @@ PlaceholderValues values = PlaceholderValues.of( "basic" ); -ExpressionContext context = ExpressionContext.of(dsl, values); +ExpressionContext context = ExpressionContext.of(ael, values); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); // ... @@ -127,7 +127,7 @@ Imagine we want to calculate a user's eligibility score based on multiple factor * Apply a multiplier based on credit score * User qualifies if final score exceeds threshold -### DSL String +### AEL String We can use the `let` construct to make this complex calculation more readable and maintainable: @@ -149,17 +149,17 @@ Let's break this down: 5. The final expression checks if the `finalScore` is at least 75 and if `premiumEligible` is true -### Using Static DSL String in Java +### Using Static AEL String in Java ```java -String dslString = "let (" + +String aelString = "let (" + "baseScore = $.accountAgeMonths * 0.5, " + "transactionBonus = $.transactionCount > 100 ? 25 : 0, " + "creditMultiplier = $.creditScore > 700 ? 1.5 : 1.0, " + "finalScore = (${baseScore} + ${transactionBonus}) * ${creditMultiplier}" + ") then (${finalScore} >= 75 && $.premiumEligible == true)"; -ExpressionContext context = ExpressionContext.of(dslString); +ExpressionContext context = ExpressionContext.of(aelString); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); @@ -171,15 +171,15 @@ queryPolicy.filterExp = filter; // This query will return only records of users who qualify for premium service ``` -### Using DSL String with Placeholders in Java +### Using AEL String with Placeholders in Java You can also use placeholders within a let expression for greater flexibility. Placeholders mark the places where values provided separately are matched by indexes. -This way the same DSL String can be used multiple times with different values for the same placeholders. +This way the same AEL String can be used multiple times with different values for the same placeholders. -For example, let's add placeholders to our previous DSL expression and use the same API for generating an `Expression`: +For example, let's add placeholders to our previous AEL expression and use the same API for generating an `Expression`: ```java -String dsl = "let (" + +String ael = "let (" + "baseScore = $.accountAgeMonths * ?0, " + "transactionThreshold = ?1, " + "transactionBonus = $.transactionCount > ${transactionThreshold} ? ?2 : 0, " + @@ -197,7 +197,7 @@ PlaceholderValues values = PlaceholderValues.of( 75 // Minimum score threshold ); -ExpressionContext context = ExpressionContext.of(dsl, values); +ExpressionContext context = ExpressionContext.of(ael, values); ParsedExpression parsed = parser.parseExpression(context); Expression filter = Exp.build(parsed.getResult().getExp()); // ... diff --git a/docs/installation.md b/docs/installation.md index f9ee81c2..86519957 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation & Setup -This guide provides detailed instructions for adding the Aerospike Expression DSL library to your project and configuring it. +This guide provides detailed instructions for adding the Aerospike Expression Language library to your project and configuring it. ## Prerequisites @@ -10,7 +10,7 @@ This guide provides detailed instructions for adding the Aerospike Expression DS ## Library Installation -To use the Expression DSL, you need to add this dependency to your project: `aerospike-expression-dsl`. Library versions prior to 0.3.0 had an additional dependency `aerospike-client-jdk8`. +To use the Expression Language, you need to add this dependency to your project: `aerospike-expression-lang-java`. Library versions prior to 0.3.0 had an additional dependency `aerospike-client-jdk8`. ### Maven @@ -18,10 +18,10 @@ Add the following dependencies to your `pom.xml` file: ```xml - + com.aerospike - aerospike-expression-dsl + aerospike-expression-lang-java 0.3.0 @@ -33,32 +33,32 @@ Add the following to your `build.gradle` file's `dependencies` block: ```groovy dependencies { - // The Expression DSL Library - implementation 'com.aerospike:aerospike-expression-dsl:0.3.0' + // The Expression Language Library + implementation 'com.aerospike:aerospike-expression-lang-java:0.3.0' } ``` ## Initializing the Parser -The main entry point for the library is the `DSLParser` interface. To get started, simply instantiate the default implementation: +The main entry point for the library is the `AelParser` interface. To get started, simply instantiate the default implementation: ```java -import com.aerospike.dsl.api.DSLParser; -import com.aerospike.dsl.impl.DSLParserImpl; +import com.aerospike.ael.api.AelParser; +import com.aerospike.ael.impl.AelParserImpl; // Create a reusable parser instance -DSLParser parser = new DSLParserImpl(); +AelParser parser = new AelParserImpl(); ``` -This `parser` object is thread-safe and can be reused across your application to parse different DSL expression strings. +This `parser` object is thread-safe and can be reused across your application to parse different AEL expression strings. ## Compatibility Table -It is important to ensure the versions of the DSL library, Java client, and Aerospike Server are compatible. +It is important to ensure the versions of the AEL library, Java client, and Aerospike Server are compatible. NOTE: Starting with version `0.3.0`, there is no dependency on Java client. -| `aerospike-expression-dsl` | `aerospike-client-jdk8` | Aerospike Server | +| `aerospike-expression-lang-java` | `aerospike-client-jdk8` | Aerospike Server | |:---------------------------|:------------------------|:-----------------| | 0.1.0 | 8.0.0+ | 5.7+ | | 0.2.0 | 8.0.0+ | 5.7+ | @@ -68,7 +68,7 @@ NOTE: Starting with version `0.3.0`, there is no dependency on Java client. If you need to build the library from source, you will need to regenerate the ANTLR sources first. -The grammar file is located at `src/main/antlr4/com/aerospike/dsl/Condition.g4`. +The grammar file is located at `src/main/antlr4/com/aerospike/ael/Condition.g4`. Run the following Maven command to re-generate the Java parser classes: diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 3a1317f4..fcff5de7 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1,12 +1,12 @@ # Troubleshooting & FAQ -This guide provides solutions to common problems and answers frequently asked questions about the Aerospike Expression DSL. +This guide provides solutions to common problems and answers frequently asked questions about the Aerospike Expression Language. ## Common Errors and Solutions -### `DslParseException` +### `AelParseException` -This is the most common exception thrown by the library, indicating a problem with the DSL string itself. +This is the most common exception thrown by the library, indicating a problem with the AEL string itself. | Cause | Example | Solution | |:----------------------------| :--- |:--------------------------------------------------------------------------------------------------------------------------------------------| @@ -18,20 +18,20 @@ This is the most common exception thrown by the library, indicating a problem wi ### `IllegalArgumentException: Missing value for placeholder` -This error occurs when your DSL string contains placeholders (`?0`, `?1`, etc.), but you did not provide a corresponding value in the `PlaceholderValues` object. +This error occurs when your AEL string contains placeholders (`?0`, `?1`, etc.), but you did not provide a corresponding value in the `PlaceholderValues` object. -**Example DSL:** `$.age > ?0 and $.city == ?1` +**Example AEL:** `$.age > ?0 and $.city == ?1` **Incorrect Code:** ```java // Only one value provided, but two are needed -ExpressionContext.of(dsl, PlaceholderValues.of(30)); +ExpressionContext.of(ael, PlaceholderValues.of(30)); ``` **Solution:** Ensure you provide a value for every placeholder in the correct order. ```java -ExpressionContext.of(dsl, PlaceholderValues.of(30, "New York")); +ExpressionContext.of(ael, PlaceholderValues.of(30, "New York")); ``` ### Query is Slow or Scans the Entire Dataset diff --git a/pom.xml b/pom.xml index c223243b..94f02f9f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,10 @@ 4.0.0 com.aerospike - aerospike-expression-dsl - aerospike-expression-dsl - Aerospike Expression DSL - https://github.com/aerospike/expression-dsl-java + aerospike-expression-lang-java + aerospike-expression-lang-java + Aerospike Expression Language + https://github.com/aerospike/aerospike-expression-lang-java jar 0.3.0 @@ -47,9 +47,9 @@ - https://github.com/aerospike/expression-dsl-java - scm:git:git://github.com/aerospike/expression-dsl-java.git - scm:git:ssh://git@github.com:aerospike/expression-dsl-java.git + https://github.com/aerospike/aerospike-expression-lang-java + scm:git:git://github.com/aerospike/aerospike-expression-lang-java.git + scm:git:ssh://git@github.com:aerospike/aerospike-expression-lang-java.git @@ -135,8 +135,8 @@ antlr4 - src/main/antlr4/com/aerospike/dsl - ${project.build.directory}/generated-sources/antlr4/com/aerospike/dsl + src/main/antlr4/com/aerospike/ael + ${project.build.directory}/generated-sources/antlr4/com/aerospike/ael false -visitor @@ -150,26 +150,6 @@ - - org.codehaus.mojo - build-helper-maven-plugin - ${build-helper-maven-plugin.version} - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/generated-sources/antlr4/ - - - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/src/main/antlr4/com/aerospike/dsl/Condition.g4 b/src/main/antlr4/com/aerospike/ael/Condition.g4 similarity index 99% rename from src/main/antlr4/com/aerospike/dsl/Condition.g4 rename to src/main/antlr4/com/aerospike/ael/Condition.g4 index 4189a154..9cffe30c 100644 --- a/src/main/antlr4/com/aerospike/dsl/Condition.g4 +++ b/src/main/antlr4/com/aerospike/ael/Condition.g4 @@ -1,7 +1,7 @@ grammar Condition; @header { - package com.aerospike.dsl; + package com.aerospike.ael; } parse: expression EOF; diff --git a/src/main/java/com/aerospike/dsl/DslParseException.java b/src/main/java/com/aerospike/ael/AelParseException.java similarity index 60% rename from src/main/java/com/aerospike/dsl/DslParseException.java rename to src/main/java/com/aerospike/ael/AelParseException.java index c7d4d735..375c8f34 100644 --- a/src/main/java/com/aerospike/dsl/DslParseException.java +++ b/src/main/java/com/aerospike/ael/AelParseException.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl; +package com.aerospike.ael; /** - * Represents a general processing exception that can occur during DSL expression parsing. + * Represents a general processing exception that can occur during AEL expression parsing. * It is typically not expected to be caught by the caller, but rather indicates a potentially * unrecoverable issue like invalid input, failing validation or unsupported functionality. */ -public class DslParseException extends RuntimeException { +public class AelParseException extends RuntimeException { - public DslParseException(String description) { + public AelParseException(String description) { super(description); } - public DslParseException(String description, Throwable cause) { + public AelParseException(String description, Throwable cause) { super(description, cause); } } diff --git a/src/main/java/com/aerospike/dsl/ExpressionContext.java b/src/main/java/com/aerospike/ael/ExpressionContext.java similarity index 96% rename from src/main/java/com/aerospike/dsl/ExpressionContext.java rename to src/main/java/com/aerospike/ael/ExpressionContext.java index 02b2cf9a..8adbe983 100644 --- a/src/main/java/com/aerospike/dsl/ExpressionContext.java +++ b/src/main/java/com/aerospike/ael/ExpressionContext.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl; +package com.aerospike.ael; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/aerospike/dsl/Index.java b/src/main/java/com/aerospike/ael/Index.java similarity index 93% rename from src/main/java/com/aerospike/dsl/Index.java rename to src/main/java/com/aerospike/ael/Index.java index 890b3c03..b67771d2 100644 --- a/src/main/java/com/aerospike/dsl/Index.java +++ b/src/main/java/com/aerospike/ael/Index.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl; +package com.aerospike.ael; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.query.IndexCollectionType; -import com.aerospike.dsl.client.query.IndexType; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.query.IndexCollectionType; +import com.aerospike.ael.client.query.IndexType; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/aerospike/dsl/IndexContext.java b/src/main/java/com/aerospike/ael/IndexContext.java similarity index 96% rename from src/main/java/com/aerospike/dsl/IndexContext.java rename to src/main/java/com/aerospike/ael/IndexContext.java index ce3b31ec..0daebe09 100644 --- a/src/main/java/com/aerospike/dsl/IndexContext.java +++ b/src/main/java/com/aerospike/ael/IndexContext.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl; +package com.aerospike.ael; import lombok.Getter; @@ -17,7 +17,7 @@ public class IndexContext { /** * Collection of {@link Index} objects to be used for creating secondary index Filter. * Namespace of indexes is matched with the given {@link #namespace}, bin name and index type are matched - * with bins in DSL String + * with bins in AEL String */ private final Collection indexes; /** @@ -37,7 +37,7 @@ private IndexContext(String namespace, Collection indexes, String preferr /** * Create index context with namespace and indexes. * - * @param namespace Namespace to be used for creating {@link com.aerospike.dsl.client.query.Filter}. + * @param namespace Namespace to be used for creating {@link com.aerospike.ael.client.query.Filter}. * Must not be null or blank * @param indexes Collection of {@link Index} objects to be used for creating Filter * @return A new instance of {@code IndexContext} @@ -53,7 +53,7 @@ public static IndexContext of(String namespace, Collection indexes) { * is kept so the selection algorithm can fall back automatically when the hint * cannot be applied (e.g. type mismatch). * - * @param namespace Namespace to be used for creating {@link com.aerospike.dsl.client.query.Filter}. + * @param namespace Namespace to be used for creating {@link com.aerospike.ael.client.query.Filter}. * Must not be null or blank * @param indexes Collection of {@link Index} objects to be used for creating Filter * @param indexToUse The name of an index to use. If null, blank, or not found in the collection, @@ -80,7 +80,7 @@ public static IndexContext of(String namespace, Collection indexes, Strin * applied (e.g. type mismatch or hinted bin not in query), the algorithm falls * back to cardinality-based selection across all indexes automatically. * - * @param namespace Namespace to be used for creating {@link com.aerospike.dsl.client.query.Filter}. + * @param namespace Namespace to be used for creating {@link com.aerospike.ael.client.query.Filter}. * Must not be null or blank * @param indexes Collection of {@link Index} objects to be used for creating Filter * @param binToUse The name of the bin whose index should be used. If not found, null, or blank, diff --git a/src/main/java/com/aerospike/dsl/ParseResult.java b/src/main/java/com/aerospike/ael/ParseResult.java similarity index 65% rename from src/main/java/com/aerospike/dsl/ParseResult.java rename to src/main/java/com/aerospike/ael/ParseResult.java index c5985d95..938362f3 100644 --- a/src/main/java/com/aerospike/dsl/ParseResult.java +++ b/src/main/java/com/aerospike/ael/ParseResult.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl; +package com.aerospike.ael; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.query.Filter; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.query.Filter; import lombok.AllArgsConstructor; import lombok.Getter; /** - * This class stores result of parsing DSL expression using {@link ParsedExpression#getResult()} + * This class stores result of parsing AEL expression using {@link ParsedExpression#getResult()} * in form of Java client's secondary index {@link Filter} and filter {@link Exp}. */ @AllArgsConstructor @@ -14,11 +14,11 @@ public class ParseResult { /** - * Secondary index {@link Filter}. Can be null in case of invalid or unsupported DSL string + * Secondary index {@link Filter}. Can be null in case of invalid or unsupported AEL string */ Filter filter; /** - * Filter {@link Exp}. Can be null in case of invalid or unsupported DSL string + * Filter {@link Exp}. Can be null in case of invalid or unsupported AEL string */ Exp exp; } diff --git a/src/main/java/com/aerospike/dsl/ParsedExpression.java b/src/main/java/com/aerospike/ael/ParsedExpression.java similarity index 77% rename from src/main/java/com/aerospike/dsl/ParsedExpression.java rename to src/main/java/com/aerospike/ael/ParsedExpression.java index b0519ce4..7c14f30c 100644 --- a/src/main/java/com/aerospike/dsl/ParsedExpression.java +++ b/src/main/java/com/aerospike/ael/ParsedExpression.java @@ -1,20 +1,20 @@ -package com.aerospike.dsl; +package com.aerospike.ael; -import com.aerospike.dsl.annotation.Beta; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.annotation.Beta; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; import java.util.List; import java.util.Map; -import static com.aerospike.dsl.parts.AbstractPart.PartType.EXPRESSION_CONTAINER; -import static com.aerospike.dsl.visitor.VisitorUtils.buildExpr; +import static com.aerospike.ael.parts.AbstractPart.PartType.EXPRESSION_CONTAINER; +import static com.aerospike.ael.visitor.VisitorUtils.buildExpr; /** - * A class to build and store the results of DSL expression parsing: parsed {@code expressionTree}, {@code indexesMap} + * A class to build and store the results of AEL expression parsing: parsed {@code expressionTree}, {@code indexesMap} * of given indexes, {@code placeholderValues} to match with placeholders and {@link ParseResult} that holds * a potential secondary index {@link Filter} and a potential {@link Exp}. */ @@ -43,8 +43,8 @@ public ParsedExpression(AbstractPart exprTree, PlaceholderValues placeholderValu /** * @return {@link ParseResult} containing secondary index {@link Filter} and/or filter {@link Exp}. - * Each can be null in case of invalid or unsupported DSL string - * @throws DslParseException If there was an error + * Each can be null in case of invalid or unsupported AEL string + * @throws AelParseException If there was an error */ public ParseResult getResult() { if (result == null) { @@ -58,8 +58,8 @@ public ParseResult getResult() { * * @param placeholderValues {@link PlaceholderValues} to match with placeholders by index * @return {@link ParseResult} containing secondary index {@link Filter} and/or {@link Exp}. - * Each can be null in case of invalid or unsupported DSL string - * @throws DslParseException If there was an error + * Each can be null in case of invalid or unsupported AEL string + * @throws AelParseException If there was an error */ public ParseResult getResult(PlaceholderValues placeholderValues) { if (expressionTree != null) { diff --git a/src/main/java/com/aerospike/dsl/PlaceholderValues.java b/src/main/java/com/aerospike/ael/PlaceholderValues.java similarity index 97% rename from src/main/java/com/aerospike/dsl/PlaceholderValues.java rename to src/main/java/com/aerospike/ael/PlaceholderValues.java index 9d5c259e..3ec27710 100644 --- a/src/main/java/com/aerospike/dsl/PlaceholderValues.java +++ b/src/main/java/com/aerospike/ael/PlaceholderValues.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl; +package com.aerospike.ael; /** * This class stores values to be matched with placeholders by indexes diff --git a/src/main/java/com/aerospike/dsl/annotation/Beta.java b/src/main/java/com/aerospike/ael/annotation/Beta.java similarity index 92% rename from src/main/java/com/aerospike/dsl/annotation/Beta.java rename to src/main/java/com/aerospike/ael/annotation/Beta.java index 0b96739a..95781f64 100644 --- a/src/main/java/com/aerospike/dsl/annotation/Beta.java +++ b/src/main/java/com/aerospike/ael/annotation/Beta.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl.annotation; +package com.aerospike.ael.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/aerospike/dsl/api/DSLParser.java b/src/main/java/com/aerospike/ael/api/AelParser.java similarity index 87% rename from src/main/java/com/aerospike/dsl/api/DSLParser.java rename to src/main/java/com/aerospike/ael/api/AelParser.java index 370bf1dc..87466056 100644 --- a/src/main/java/com/aerospike/dsl/api/DSLParser.java +++ b/src/main/java/com/aerospike/ael/api/AelParser.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.api; +package com.aerospike.ael.api; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.ParsedExpression; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.query.Filter; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.ParsedExpression; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.query.Filter; /** * Contains API to convert dot separated String path into an Aerospike filter - @@ -20,10 +20,10 @@ *
  • defining secondary indexes.
  • * */ -public interface DSLParser { +public interface AelParser { /** - * Parse DSL string into {@link ParsedExpression}. + * Parse AEL string into {@link ParsedExpression}. *

    * Examples: * @@ -91,12 +91,12 @@ public interface DSLParser { * @param input {@link ExpressionContext} containing input string of dot separated elements. If the input string has * placeholders, matching values must be provided within {@code input} too * @return {@link ParsedExpression} object - * @throws DslParseException in case of invalid syntax + * @throws AelParseException in case of invalid syntax */ ParsedExpression parseExpression(ExpressionContext input); /** - * Parse DSL string into {@link ParsedExpression}. + * Parse AEL string into {@link ParsedExpression}. *

    * Examples: *
    @@ -166,17 +166,17 @@ public interface DSLParser { * @param indexContext Class containing namespace and collection of {@link Index} objects that represent * existing secondary indexes. Required for creating {@link Filter}. Can be null * @return {@link ParsedExpression} object - * @throws DslParseException in case of invalid syntax + * @throws AelParseException in case of invalid syntax */ ParsedExpression parseExpression(ExpressionContext input, IndexContext indexContext); /** - * Parse DSL path with CDT context into an array of {@link CTX} objects. The argument must represent a path with context, + * Parse AEL path with CDT context into an array of {@link CTX} objects. The argument must represent a path with context, * e.g. $.listBinName.[1], $.mapBinName.ab etc. * - * @param dslPath Input string representing path with CDT context, must not be null + * @param aelPath Input string representing path with CDT context, must not be null * @return Array of {@link CTX} - * @throws DslParseException in case of invalid syntax + * @throws AelParseException in case of invalid syntax */ - CTX[] parseCTX(String dslPath); + CTX[] parseCTX(String aelPath); } diff --git a/src/main/java/com/aerospike/dsl/client/AerospikeException.java b/src/main/java/com/aerospike/ael/client/AerospikeException.java similarity index 99% rename from src/main/java/com/aerospike/dsl/client/AerospikeException.java rename to src/main/java/com/aerospike/ael/client/AerospikeException.java index fc8f6c69..9e63f91b 100644 --- a/src/main/java/com/aerospike/dsl/client/AerospikeException.java +++ b/src/main/java/com/aerospike/ael/client/AerospikeException.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client; +package com.aerospike.ael.client; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/client/ResultCode.java b/src/main/java/com/aerospike/ael/client/ResultCode.java similarity index 99% rename from src/main/java/com/aerospike/dsl/client/ResultCode.java rename to src/main/java/com/aerospike/ael/client/ResultCode.java index 716dd56e..b0155b7a 100644 --- a/src/main/java/com/aerospike/dsl/client/ResultCode.java +++ b/src/main/java/com/aerospike/ael/client/ResultCode.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client; +package com.aerospike.ael.client; /** * Database operation error codes. The positive numbers align with the server diff --git a/src/main/java/com/aerospike/dsl/client/Value.java b/src/main/java/com/aerospike/ael/client/Value.java similarity index 99% rename from src/main/java/com/aerospike/dsl/client/Value.java rename to src/main/java/com/aerospike/ael/client/Value.java index 600ba331..f5bea623 100644 --- a/src/main/java/com/aerospike/dsl/client/Value.java +++ b/src/main/java/com/aerospike/ael/client/Value.java @@ -14,13 +14,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client; +package com.aerospike.ael.client; -import com.aerospike.dsl.client.cdt.MapOrder; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.command.Buffer; -import com.aerospike.dsl.client.command.ParticleType; -import com.aerospike.dsl.client.util.Packer; +import com.aerospike.ael.client.cdt.MapOrder; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.command.Buffer; +import com.aerospike.ael.client.command.ParticleType; +import com.aerospike.ael.client.util.Packer; import java.nio.ByteBuffer; import java.util.Arrays; diff --git a/src/main/java/com/aerospike/dsl/client/cdt/CTX.java b/src/main/java/com/aerospike/ael/client/cdt/CTX.java similarity index 94% rename from src/main/java/com/aerospike/dsl/client/cdt/CTX.java rename to src/main/java/com/aerospike/ael/client/cdt/CTX.java index e6554ff0..7461d4ce 100644 --- a/src/main/java/com/aerospike/dsl/client/cdt/CTX.java +++ b/src/main/java/com/aerospike/ael/client/cdt/CTX.java @@ -14,13 +14,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.cdt; +package com.aerospike.ael.client.cdt; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.util.Crypto; -import com.aerospike.dsl.client.util.Pack; -import com.aerospike.dsl.client.util.Unpacker; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.util.Crypto; +import com.aerospike.ael.client.util.Pack; +import com.aerospike.ael.client.util.Unpacker; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/client/cdt/ListReturnType.java b/src/main/java/com/aerospike/ael/client/cdt/ListReturnType.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/cdt/ListReturnType.java rename to src/main/java/com/aerospike/ael/client/cdt/ListReturnType.java index 0d098ebd..fb5f02e2 100644 --- a/src/main/java/com/aerospike/dsl/client/cdt/ListReturnType.java +++ b/src/main/java/com/aerospike/ael/client/cdt/ListReturnType.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.cdt; +package com.aerospike.ael.client.cdt; /** * List return type. Type of data to return when selecting or removing items from the list. diff --git a/src/main/java/com/aerospike/dsl/client/cdt/MapOrder.java b/src/main/java/com/aerospike/ael/client/cdt/MapOrder.java similarity index 97% rename from src/main/java/com/aerospike/dsl/client/cdt/MapOrder.java rename to src/main/java/com/aerospike/ael/client/cdt/MapOrder.java index 04c136e5..efc72f6c 100644 --- a/src/main/java/com/aerospike/dsl/client/cdt/MapOrder.java +++ b/src/main/java/com/aerospike/ael/client/cdt/MapOrder.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.cdt; +package com.aerospike.ael.client.cdt; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/aerospike/dsl/client/cdt/MapReturnType.java b/src/main/java/com/aerospike/ael/client/cdt/MapReturnType.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/cdt/MapReturnType.java rename to src/main/java/com/aerospike/ael/client/cdt/MapReturnType.java index 71489625..6a8ba02a 100644 --- a/src/main/java/com/aerospike/dsl/client/cdt/MapReturnType.java +++ b/src/main/java/com/aerospike/ael/client/cdt/MapReturnType.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.cdt; +package com.aerospike.ael.client.cdt; /** * Map return type. Type of data to return when selecting or removing items from the map. diff --git a/src/main/java/com/aerospike/dsl/client/command/Buffer.java b/src/main/java/com/aerospike/ael/client/command/Buffer.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/command/Buffer.java rename to src/main/java/com/aerospike/ael/client/command/Buffer.java index 5fcbf5f0..852570ed 100644 --- a/src/main/java/com/aerospike/dsl/client/command/Buffer.java +++ b/src/main/java/com/aerospike/ael/client/command/Buffer.java @@ -14,12 +14,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.command; +package com.aerospike.ael.client.command; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.util.Unpacker; -import com.aerospike.dsl.client.util.Utf8; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.util.Unpacker; +import com.aerospike.ael.client.util.Utf8; import java.math.BigInteger; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/com/aerospike/dsl/client/command/ParticleType.java b/src/main/java/com/aerospike/ael/client/command/ParticleType.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/command/ParticleType.java rename to src/main/java/com/aerospike/ael/client/command/ParticleType.java index 13122ba0..8905c9e6 100644 --- a/src/main/java/com/aerospike/dsl/client/command/ParticleType.java +++ b/src/main/java/com/aerospike/ael/client/command/ParticleType.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.command; +package com.aerospike.ael.client.command; /** * Server particle types. diff --git a/src/main/java/com/aerospike/dsl/client/exp/Exp.java b/src/main/java/com/aerospike/ael/client/exp/Exp.java similarity index 99% rename from src/main/java/com/aerospike/dsl/client/exp/Exp.java rename to src/main/java/com/aerospike/ael/client/exp/Exp.java index 9a186b1f..ed088014 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/Exp.java +++ b/src/main/java/com/aerospike/ael/client/exp/Exp.java @@ -14,11 +14,11 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; -import com.aerospike.dsl.client.command.ParticleType; -import com.aerospike.dsl.client.query.RegexFlag; -import com.aerospike.dsl.client.util.Packer; +import com.aerospike.ael.client.command.ParticleType; +import com.aerospike.ael.client.query.RegexFlag; +import com.aerospike.ael.client.util.Packer; import java.util.Arrays; import java.util.Calendar; diff --git a/src/main/java/com/aerospike/dsl/client/exp/ExpReadFlags.java b/src/main/java/com/aerospike/ael/client/exp/ExpReadFlags.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/exp/ExpReadFlags.java rename to src/main/java/com/aerospike/ael/client/exp/ExpReadFlags.java index 8a7f6aec..ca96c22b 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/ExpReadFlags.java +++ b/src/main/java/com/aerospike/ael/client/exp/ExpReadFlags.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; /** * Expression read flags. diff --git a/src/main/java/com/aerospike/dsl/client/exp/ExpWriteFlags.java b/src/main/java/com/aerospike/ael/client/exp/ExpWriteFlags.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/exp/ExpWriteFlags.java rename to src/main/java/com/aerospike/ael/client/exp/ExpWriteFlags.java index 20b4133d..14c1e037 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/ExpWriteFlags.java +++ b/src/main/java/com/aerospike/ael/client/exp/ExpWriteFlags.java @@ -14,9 +14,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; -import com.aerospike.dsl.client.ResultCode; +import com.aerospike.ael.client.ResultCode; /** * Expression write bit flags. Use BITWISE OR to combine flags. Example: diff --git a/src/main/java/com/aerospike/dsl/client/exp/Expression.java b/src/main/java/com/aerospike/ael/client/exp/Expression.java similarity index 95% rename from src/main/java/com/aerospike/dsl/client/exp/Expression.java rename to src/main/java/com/aerospike/ael/client/exp/Expression.java index 10171ce5..1d28ddab 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/Expression.java +++ b/src/main/java/com/aerospike/ael/client/exp/Expression.java @@ -14,10 +14,10 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; -import com.aerospike.dsl.client.util.Crypto; -import com.aerospike.dsl.client.util.Packer; +import com.aerospike.ael.client.util.Crypto; +import com.aerospike.ael.client.util.Packer; import java.io.Serializable; import java.util.Arrays; diff --git a/src/main/java/com/aerospike/dsl/client/exp/ListExp.java b/src/main/java/com/aerospike/ael/client/exp/ListExp.java similarity index 97% rename from src/main/java/com/aerospike/dsl/client/exp/ListExp.java rename to src/main/java/com/aerospike/ael/client/exp/ListExp.java index 2173b235..8191dbdd 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/ListExp.java +++ b/src/main/java/com/aerospike/ael/client/exp/ListExp.java @@ -14,13 +14,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.util.Pack; -import com.aerospike.dsl.client.util.Packer; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.util.Pack; +import com.aerospike.ael.client.util.Packer; /** * List expression generator. See {@link Exp}. diff --git a/src/main/java/com/aerospike/dsl/client/exp/MapExp.java b/src/main/java/com/aerospike/ael/client/exp/MapExp.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/exp/MapExp.java rename to src/main/java/com/aerospike/ael/client/exp/MapExp.java index 8fe82c41..e6d9222d 100644 --- a/src/main/java/com/aerospike/dsl/client/exp/MapExp.java +++ b/src/main/java/com/aerospike/ael/client/exp/MapExp.java @@ -14,12 +14,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.exp; +package com.aerospike.ael.client.exp; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.util.Pack; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.util.Pack; /** * Map expression generator. See {@link Exp}. diff --git a/src/main/java/com/aerospike/dsl/client/fluent/AerospikeComparator.java b/src/main/java/com/aerospike/ael/client/fluent/AerospikeComparator.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/fluent/AerospikeComparator.java rename to src/main/java/com/aerospike/ael/client/fluent/AerospikeComparator.java index e2640ac4..bdd321a3 100644 --- a/src/main/java/com/aerospike/dsl/client/fluent/AerospikeComparator.java +++ b/src/main/java/com/aerospike/ael/client/fluent/AerospikeComparator.java @@ -15,9 +15,9 @@ * the License. */ -package com.aerospike.dsl.client.fluent; +package com.aerospike.ael.client.fluent; -import com.aerospike.dsl.client.Value; +import com.aerospike.ael.client.Value; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/com/aerospike/dsl/client/query/Filter.java b/src/main/java/com/aerospike/ael/client/query/Filter.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/query/Filter.java rename to src/main/java/com/aerospike/ael/client/query/Filter.java index 5d22c4a3..90a6c0d3 100644 --- a/src/main/java/com/aerospike/dsl/client/query/Filter.java +++ b/src/main/java/com/aerospike/ael/client/query/Filter.java @@ -14,14 +14,14 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.query; - -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.command.Buffer; -import com.aerospike.dsl.client.command.ParticleType; -import com.aerospike.dsl.client.exp.Expression; -import com.aerospike.dsl.client.util.Pack; +package com.aerospike.ael.client.query; + +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.command.Buffer; +import com.aerospike.ael.client.command.ParticleType; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.util.Pack; import lombok.Getter; import java.util.Arrays; diff --git a/src/main/java/com/aerospike/dsl/client/query/IndexCollectionType.java b/src/main/java/com/aerospike/ael/client/query/IndexCollectionType.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/query/IndexCollectionType.java rename to src/main/java/com/aerospike/ael/client/query/IndexCollectionType.java index 54b01b62..44a1aed9 100644 --- a/src/main/java/com/aerospike/dsl/client/query/IndexCollectionType.java +++ b/src/main/java/com/aerospike/ael/client/query/IndexCollectionType.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.query; +package com.aerospike.ael.client.query; /** * Secondary index collection type. diff --git a/src/main/java/com/aerospike/dsl/client/query/IndexType.java b/src/main/java/com/aerospike/ael/client/query/IndexType.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/query/IndexType.java rename to src/main/java/com/aerospike/ael/client/query/IndexType.java index c9c2c350..05eb2835 100644 --- a/src/main/java/com/aerospike/dsl/client/query/IndexType.java +++ b/src/main/java/com/aerospike/ael/client/query/IndexType.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.query; +package com.aerospike.ael.client.query; /** * Underlying data type of secondary index. diff --git a/src/main/java/com/aerospike/dsl/client/query/RegexFlag.java b/src/main/java/com/aerospike/ael/client/query/RegexFlag.java similarity index 97% rename from src/main/java/com/aerospike/dsl/client/query/RegexFlag.java rename to src/main/java/com/aerospike/ael/client/query/RegexFlag.java index 15d40317..acc89b89 100644 --- a/src/main/java/com/aerospike/dsl/client/query/RegexFlag.java +++ b/src/main/java/com/aerospike/ael/client/query/RegexFlag.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.query; +package com.aerospike.ael.client.query; /** * Regex bit flags. Use BITWISE OR to combine flags. Example: diff --git a/src/main/java/com/aerospike/dsl/client/util/Crypto.java b/src/main/java/com/aerospike/ael/client/util/Crypto.java similarity index 96% rename from src/main/java/com/aerospike/dsl/client/util/Crypto.java rename to src/main/java/com/aerospike/ael/client/util/Crypto.java index 2ffdbe0a..936cf18f 100644 --- a/src/main/java/com/aerospike/dsl/client/util/Crypto.java +++ b/src/main/java/com/aerospike/ael/client/util/Crypto.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; import gnu.crypto.util.Base64; diff --git a/src/main/java/com/aerospike/dsl/client/util/Pack.java b/src/main/java/com/aerospike/ael/client/util/Pack.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/util/Pack.java rename to src/main/java/com/aerospike/ael/client/util/Pack.java index ca7547aa..0728e556 100644 --- a/src/main/java/com/aerospike/dsl/client/util/Pack.java +++ b/src/main/java/com/aerospike/ael/client/util/Pack.java @@ -14,11 +14,11 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/client/util/Packer.java b/src/main/java/com/aerospike/ael/client/util/Packer.java similarity index 97% rename from src/main/java/com/aerospike/dsl/client/util/Packer.java rename to src/main/java/com/aerospike/ael/client/util/Packer.java index ccf4c66e..2592e527 100644 --- a/src/main/java/com/aerospike/dsl/client/util/Packer.java +++ b/src/main/java/com/aerospike/ael/client/util/Packer.java @@ -14,13 +14,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.MapOrder; -import com.aerospike.dsl.client.command.Buffer; -import com.aerospike.dsl.client.command.ParticleType; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.MapOrder; +import com.aerospike.ael.client.command.Buffer; +import com.aerospike.ael.client.command.ParticleType; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -29,7 +29,7 @@ import java.util.Map.Entry; import java.util.UUID; -import static com.aerospike.dsl.client.Value.MapValue.getMapOrder; +import static com.aerospike.ael.client.Value.MapValue.getMapOrder; /** * Serialize collection objects using MessagePack format specification: diff --git a/src/main/java/com/aerospike/dsl/client/util/ThreadLocalData.java b/src/main/java/com/aerospike/ael/client/util/ThreadLocalData.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/util/ThreadLocalData.java rename to src/main/java/com/aerospike/ael/client/util/ThreadLocalData.java index 4c2360c8..8e4c8780 100644 --- a/src/main/java/com/aerospike/dsl/client/util/ThreadLocalData.java +++ b/src/main/java/com/aerospike/ael/client/util/ThreadLocalData.java @@ -14,7 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/aerospike/dsl/client/util/Unpacker.java b/src/main/java/com/aerospike/ael/client/util/Unpacker.java similarity index 98% rename from src/main/java/com/aerospike/dsl/client/util/Unpacker.java rename to src/main/java/com/aerospike/ael/client/util/Unpacker.java index f3e99ea9..beedb186 100644 --- a/src/main/java/com/aerospike/dsl/client/util/Unpacker.java +++ b/src/main/java/com/aerospike/ael/client/util/Unpacker.java @@ -14,12 +14,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; -import com.aerospike.dsl.client.AerospikeException; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.command.Buffer; -import com.aerospike.dsl.client.command.ParticleType; +import com.aerospike.ael.client.AerospikeException; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.command.Buffer; +import com.aerospike.ael.client.command.ParticleType; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/src/main/java/com/aerospike/dsl/client/util/Utf8.java b/src/main/java/com/aerospike/ael/client/util/Utf8.java similarity index 97% rename from src/main/java/com/aerospike/dsl/client/util/Utf8.java rename to src/main/java/com/aerospike/ael/client/util/Utf8.java index 42af47e5..9f10b594 100644 --- a/src/main/java/com/aerospike/dsl/client/util/Utf8.java +++ b/src/main/java/com/aerospike/ael/client/util/Utf8.java @@ -11,9 +11,9 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package com.aerospike.dsl.client.util; +package com.aerospike.ael.client.util; -import com.aerospike.dsl.client.AerospikeException; +import com.aerospike.ael.client.AerospikeException; import static java.lang.Character.MAX_SURROGATE; import static java.lang.Character.MIN_SURROGATE; diff --git a/src/main/java/com/aerospike/dsl/impl/DSLParserErrorListener.java b/src/main/java/com/aerospike/ael/impl/AelParserErrorListener.java similarity index 88% rename from src/main/java/com/aerospike/dsl/impl/DSLParserErrorListener.java rename to src/main/java/com/aerospike/ael/impl/AelParserErrorListener.java index bf9fc1a6..9e17f17a 100644 --- a/src/main/java/com/aerospike/dsl/impl/DSLParserErrorListener.java +++ b/src/main/java/com/aerospike/ael/impl/AelParserErrorListener.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.impl; +package com.aerospike.ael.impl; -import com.aerospike.dsl.ConditionLexer; -import com.aerospike.dsl.DslParseException; +import com.aerospike.ael.ConditionLexer; +import com.aerospike.ael.AelParseException; import org.antlr.v4.runtime.BaseErrorListener; import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Recognizer; import org.antlr.v4.runtime.Token; -class DSLParserErrorListener extends BaseErrorListener { +class AelParserErrorListener extends BaseErrorListener { private String firstLexerError; private String firstParserError; @@ -24,7 +24,7 @@ public void syntaxError(Recognizer recognizer, Object offendingSymbol, // These throw immediately to provide a specific error message. if (token.getType() == ConditionLexer.LEADING_DOT_FLOAT_HEX_OR_BINARY || token.getType() == ConditionLexer.LEADING_DOT_FLOAT) { - throw new DslParseException("Invalid float literal: " + token.getText()); + throw new AelParseException("Invalid float literal: " + token.getText()); } // Detect malformed leading-dot floats like "..37": the lexer emits a bare '.' for the // first dot (LEADING_DOT_FLOAT requires a digit immediately after '.', so it can't @@ -32,7 +32,7 @@ public void syntaxError(Recognizer recognizer, Object offendingSymbol, if (".".equals(token.getText()) && msg != null && msg.contains("LEADING_DOT_FLOAT") && recognizer instanceof Parser parser) { String nextText = parser.getInputStream().LT(2).getText(); - throw new DslParseException("Invalid float literal: " + token.getText() + nextText); + throw new AelParseException("Invalid float literal: " + token.getText() + nextText); } } if (recognizer instanceof Parser) { diff --git a/src/main/java/com/aerospike/dsl/impl/DSLParserImpl.java b/src/main/java/com/aerospike/ael/impl/AelParserImpl.java similarity index 73% rename from src/main/java/com/aerospike/dsl/impl/DSLParserImpl.java rename to src/main/java/com/aerospike/ael/impl/AelParserImpl.java index 74b21ee2..3702405c 100644 --- a/src/main/java/com/aerospike/dsl/impl/DSLParserImpl.java +++ b/src/main/java/com/aerospike/ael/impl/AelParserImpl.java @@ -1,18 +1,18 @@ -package com.aerospike.dsl.impl; - -import com.aerospike.dsl.ConditionLexer; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.ParsedExpression; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.annotation.Beta; -import com.aerospike.dsl.api.DSLParser; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.visitor.ExpressionConditionVisitor; +package com.aerospike.ael.impl; + +import com.aerospike.ael.ConditionLexer; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.ParsedExpression; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.annotation.Beta; +import com.aerospike.ael.api.AelParser; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.visitor.ExpressionConditionVisitor; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; @@ -24,9 +24,9 @@ import java.util.Optional; import java.util.stream.Collectors; -import static com.aerospike.dsl.visitor.VisitorUtils.buildCtx; +import static com.aerospike.ael.visitor.VisitorUtils.buildCtx; -public class DSLParserImpl implements DSLParser { +public class AelParserImpl implements AelParser { @Override @Beta @@ -46,18 +46,18 @@ public ParsedExpression parseExpression(ExpressionContext expressionContext, Ind @Beta public CTX[] parseCTX(String pathToCtx) { if (pathToCtx == null || pathToCtx.isBlank()) { - throw new DslParseException("Path must not be null or empty"); + throw new AelParseException("Path must not be null or empty"); } try { ParseTree parseTree = getParseTree(pathToCtx); return buildCtx(new ExpressionConditionVisitor().visit(parseTree)); } catch (Exception e) { - throw new DslParseException("Could not parse the given DSL path input", e); + throw new AelParseException("Could not parse the given AEL path input", e); } } - private ConditionParser createParser(String input, DSLParserErrorListener errorListener) { + private ConditionParser createParser(String input, AelParserErrorListener errorListener) { ConditionLexer lexer = new ConditionLexer(CharStreams.fromString(input)); lexer.removeErrorListeners(); lexer.addErrorListener(errorListener); @@ -69,13 +69,13 @@ private ConditionParser createParser(String input, DSLParserErrorListener errorL } private ParseTree getParseTree(String input) { - DSLParserErrorListener errorListener = new DSLParserErrorListener(); + AelParserErrorListener errorListener = new AelParserErrorListener(); ConditionParser parser = createParser(input, errorListener); ParseTree tree = parser.parse(); String errorMessage = errorListener.getErrorMessage(); if (errorMessage != null) { - throw new DslParseException("Could not parse given DSL expression input: " + errorMessage); + throw new AelParseException("Could not parse given AEL expression input: " + errorMessage); } return tree; } @@ -95,7 +95,7 @@ private ParsedExpression getParsedExpression(ParseTree parseTree, PlaceholderVal AbstractPart resultingPart = new ExpressionConditionVisitor().visit(parseTree); if (resultingPart == null) { - throw new DslParseException("Could not parse given DSL expression input"); + throw new AelParseException("Could not parse given AEL expression input"); } return new ParsedExpression(resultingPart, placeholderValues, indexesMap, preferredBin); diff --git a/src/main/java/com/aerospike/dsl/parts/AbstractPart.java b/src/main/java/com/aerospike/ael/parts/AbstractPart.java similarity index 85% rename from src/main/java/com/aerospike/dsl/parts/AbstractPart.java rename to src/main/java/com/aerospike/ael/parts/AbstractPart.java index 28830f95..dae2a9fe 100644 --- a/src/main/java/com/aerospike/dsl/parts/AbstractPart.java +++ b/src/main/java/com/aerospike/ael/parts/AbstractPart.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.parts; +package com.aerospike.ael.parts; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.query.Filter; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.query.Filter; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/aerospike/dsl/parts/ExpressionContainer.java b/src/main/java/com/aerospike/ael/parts/ExpressionContainer.java similarity index 98% rename from src/main/java/com/aerospike/dsl/parts/ExpressionContainer.java rename to src/main/java/com/aerospike/ael/parts/ExpressionContainer.java index 1abc1491..77d573f3 100644 --- a/src/main/java/com/aerospike/dsl/parts/ExpressionContainer.java +++ b/src/main/java/com/aerospike/ael/parts/ExpressionContainer.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl.parts; +package com.aerospike.ael.parts; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/CdtPart.java b/src/main/java/com/aerospike/ael/parts/cdt/CdtPart.java similarity index 64% rename from src/main/java/com/aerospike/dsl/parts/cdt/CdtPart.java rename to src/main/java/com/aerospike/ael/parts/cdt/CdtPart.java index 4c7c0f05..c90f58dc 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/CdtPart.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/CdtPart.java @@ -1,11 +1,11 @@ -package com.aerospike.dsl.parts.cdt; +package com.aerospike.ael.parts.cdt; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.parts.path.PathFunction; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.parts.path.PathFunction; public abstract class CdtPart extends AbstractPart { @@ -17,7 +17,7 @@ protected CdtPart(PartType partType) { public CTX getContext() { // should print the subclass of the cdt type - throw new DslParseException("Context is not supported for %s".formatted(this.getClass().getName())); + throw new AelParseException("Context is not supported for %s".formatted(this.getClass().getName())); } public abstract int getReturnType(PathFunction.ReturnParam returnParam); diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndex.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndex.java similarity index 68% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndex.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListIndex.java index 44772656..23d86bb3 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndex.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndex.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; public class ListIndex extends ListPart { private final int index; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndexRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java similarity index 78% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndexRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java index 19812725..3de9d5e5 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListIndexRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListIndexRange extends ListPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static ListIndexRange from(ConditionParser.ListIndexRangeContext ctx) { return new ListIndexRange(isInverted, start, end); } - throw new DslParseException("Could not translate ListIndexRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate ListIndexRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListPart.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListPart.java similarity index 78% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListPart.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListPart.java index a71c5a35..e2e93531 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListPart.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListPart.java @@ -1,9 +1,9 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.parts.cdt.CdtPart; -import com.aerospike.dsl.parts.path.PathFunction; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.parts.cdt.CdtPart; +import com.aerospike.ael.parts.path.PathFunction; import lombok.Getter; @Getter @@ -27,7 +27,7 @@ public int getReturnType(PathFunction.ReturnParam returnParam) { case REVERSE_INDEX -> ListReturnType.REVERSE_INDEX; case REVERSE_RANK -> ListReturnType.REVERSE_RANK; default -> - throw new DslParseException("Unsupported Return Param for List CDT: %s".formatted(returnParam)); + throw new AelParseException("Unsupported Return Param for List CDT: %s".formatted(returnParam)); }; } diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRank.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRank.java similarity index 68% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListRank.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListRank.java index 1d3eea94..22aed385 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRank.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRank.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; public class ListRank extends ListPart { private final int rank; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java similarity index 78% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java index 776e7548..56d7d983 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListRankRange extends ListPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static ListRankRange from(ConditionParser.ListRankRangeContext ctx) { return new ListRankRange(isInverted, start, end); } - throw new DslParseException("Could not translate ListRankRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate ListRankRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java similarity index 80% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRangeRelative.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java index a5749eaa..e850137c 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListRankRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.util.ParsingUtils; -import static com.aerospike.dsl.util.ParsingUtils.objectToExp; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListRankRangeRelative extends ListPart { private final boolean isInverted; @@ -51,7 +51,7 @@ public static ListRankRangeRelative from(ConditionParser.ListRankRangeRelativeCo return new ListRankRangeRelative(isInverted, start, end, relativeValue); } - throw new DslParseException("Could not translate ListRankRangeRelative from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate ListRankRangeRelative from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListTypeDesignator.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListTypeDesignator.java similarity index 81% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListTypeDesignator.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListTypeDesignator.java index e82faa67..33e5f5bb 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListTypeDesignator.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListTypeDesignator.java @@ -1,10 +1,10 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.cdt.CdtPart; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.cdt.CdtPart; +import com.aerospike.ael.parts.path.BasePath; import java.util.Collections; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValue.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValue.java similarity index 63% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListValue.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListValue.java index 488a788f..0dbc557c 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValue.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValue.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.objectToExp; -import static com.aerospike.dsl.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; public class ListValue extends ListPart { private final Object value; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueList.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueList.java similarity index 77% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueList.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListValueList.java index 7ebf38d2..edf333ca 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueList.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueList.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.util.ParsingUtils; import java.util.List; @@ -37,7 +37,7 @@ public static ListValueList from(ConditionParser.ListValueListContext ctx) { return new ListValueList(isInverted, valueListObjects); } - throw new DslParseException("Could not translate ListValueList from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate ListValueList from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java similarity index 79% rename from src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java index a9b9bee8..461536c7 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/list/ListValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.list; +package com.aerospike.ael.parts.cdt.list; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; public class ListValueRange extends ListPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static ListValueRange from(ConditionParser.ListValueRangeContext ctx) { return new ListValueRange(isInverted, startValue, endValue); } - throw new DslParseException("Could not translate ListValueRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate ListValueRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndex.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndex.java similarity index 68% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndex.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapIndex.java index f0c6a9b7..79d44aae 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndex.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndex.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; public class MapIndex extends MapPart { private final int index; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java similarity index 78% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java index 68038d01..b56ce548 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapIndexRange extends MapPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static MapIndexRange from(ConditionParser.MapIndexRangeContext ctx) { return new MapIndexRange(isInverted, start, end); } - throw new DslParseException("Could not translate MapIndexRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapIndexRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java similarity index 81% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRangeRelative.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java index c2fe8812..0f117e4f 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapIndexRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.util.ParsingUtils; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapIndexRangeRelative extends MapPart { private final boolean isInverted; @@ -49,7 +49,7 @@ public static MapIndexRangeRelative from(ConditionParser.MapIndexRangeRelativeCo } return new MapIndexRangeRelative(isInverted, start, end, relativeKey); } - throw new DslParseException("Could not translate MapIndexRangeRelative from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapIndexRangeRelative from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKey.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java similarity index 66% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapKey.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java index 2963c2e7..adfccb4a 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKey.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.util.ParsingUtils; public class MapKey extends MapPart { private final String key; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyList.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java similarity index 76% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyList.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java index 565fbb66..d95f6dc9 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyList.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.util.ParsingUtils; import java.util.List; @@ -37,7 +37,7 @@ public static MapKeyList from(ConditionParser.MapKeyListContext ctx) { return new MapKeyList(isInverted, keyListStrings); } - throw new DslParseException("Could not translate MapKeyList from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapKeyList from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java similarity index 79% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java index b56c719a..57325610 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapKeyRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.util.ParsingUtils; import java.util.Optional; @@ -41,7 +41,7 @@ public static MapKeyRange from(ConditionParser.MapKeyRangeContext ctx) { return new MapKeyRange(isInverted, startKey, endKey); } - throw new DslParseException("Could not translate MapKeyRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapKeyRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapPart.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java similarity index 87% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapPart.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java index f42a1eb0..5c67845a 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapPart.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.parts.cdt.CdtPart; -import com.aerospike.dsl.parts.path.PathFunction; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.parts.cdt.CdtPart; +import com.aerospike.ael.parts.path.PathFunction; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRank.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRank.java similarity index 68% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapRank.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapRank.java index 5d1994de..ffde05b7 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRank.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRank.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; public class MapRank extends MapPart { private final int rank; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java similarity index 78% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java index 78baa22a..df27f4c5 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapRankRange extends MapPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static MapRankRange from(ConditionParser.MapRankRangeContext ctx) { return new MapRankRange(isInverted, start, end); } - throw new DslParseException("Could not translate MapRankRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapRankRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java similarity index 80% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRangeRelative.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java index 553bfc2f..36db2b66 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapRankRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.util.ParsingUtils; -import static com.aerospike.dsl.util.ParsingUtils.objectToExp; -import static com.aerospike.dsl.util.ParsingUtils.parseSignedInt; -import static com.aerospike.dsl.util.ParsingUtils.subtractNullable; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; +import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapRankRangeRelative extends MapPart { private final boolean isInverted; @@ -51,7 +51,7 @@ public static MapRankRangeRelative from(ConditionParser.MapRankRangeRelativeCont return new MapRankRangeRelative(isInverted, start, end, relativeValue); } - throw new DslParseException("Could not translate MapRankRangeRelative from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapRankRangeRelative from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapTypeDesignator.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapTypeDesignator.java similarity index 82% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapTypeDesignator.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapTypeDesignator.java index 9d4a3529..568e312c 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapTypeDesignator.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapTypeDesignator.java @@ -1,9 +1,9 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.cdt.CdtPart; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.cdt.CdtPart; +import com.aerospike.ael.parts.path.BasePath; /** * Designates that the element to the left is a Map. diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValue.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValue.java similarity index 63% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapValue.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapValue.java index 4d78fbc6..c677da05 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValue.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValue.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.objectToExp; -import static com.aerospike.dsl.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; public class MapValue extends MapPart { private final Object value; diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueList.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueList.java similarity index 77% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueList.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapValueList.java index 02cbb214..7661c1d8 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueList.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueList.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import com.aerospike.dsl.util.ParsingUtils; +import com.aerospike.ael.util.ParsingUtils; import java.util.List; @@ -37,7 +37,7 @@ public static MapValueList from(ConditionParser.MapValueListContext ctx) { return new MapValueList(isInverted, valueListObjects); } - throw new DslParseException("Could not translate MapValueList from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapValueList from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java similarity index 79% rename from src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueRange.java rename to src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java index efe433f6..b6230238 100644 --- a/src/main/java/com/aerospike/dsl/parts/cdt/map/MapValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.parts.cdt.map; +package com.aerospike.ael.parts.cdt.map; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.path.BasePath; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.dsl.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; public class MapValueRange extends MapPart { private final boolean isInverted; @@ -40,7 +40,7 @@ public static MapValueRange from(ConditionParser.MapValueRangeContext ctx) { return new MapValueRange(isInverted, startValue, endValue); } - throw new DslParseException("Could not translate MapValueRange from ctx: %s".formatted(ctx)); + throw new AelParseException("Could not translate MapValueRange from ctx: %s".formatted(ctx)); } @Override diff --git a/src/main/java/com/aerospike/dsl/parts/controlstructure/AndStructure.java b/src/main/java/com/aerospike/ael/parts/controlstructure/AndStructure.java similarity index 67% rename from src/main/java/com/aerospike/dsl/parts/controlstructure/AndStructure.java rename to src/main/java/com/aerospike/ael/parts/controlstructure/AndStructure.java index b351e744..8036e8be 100644 --- a/src/main/java/com/aerospike/dsl/parts/controlstructure/AndStructure.java +++ b/src/main/java/com/aerospike/ael/parts/controlstructure/AndStructure.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.controlstructure; +package com.aerospike.ael.parts.controlstructure; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/controlstructure/ExclusiveStructure.java b/src/main/java/com/aerospike/ael/parts/controlstructure/ExclusiveStructure.java similarity index 68% rename from src/main/java/com/aerospike/dsl/parts/controlstructure/ExclusiveStructure.java rename to src/main/java/com/aerospike/ael/parts/controlstructure/ExclusiveStructure.java index 9be7857e..17883c7d 100644 --- a/src/main/java/com/aerospike/dsl/parts/controlstructure/ExclusiveStructure.java +++ b/src/main/java/com/aerospike/ael/parts/controlstructure/ExclusiveStructure.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.controlstructure; +package com.aerospike.ael.parts.controlstructure; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/controlstructure/LetStructure.java b/src/main/java/com/aerospike/ael/parts/controlstructure/LetStructure.java similarity index 66% rename from src/main/java/com/aerospike/dsl/parts/controlstructure/LetStructure.java rename to src/main/java/com/aerospike/ael/parts/controlstructure/LetStructure.java index faaf0ebe..e6c37b5d 100644 --- a/src/main/java/com/aerospike/dsl/parts/controlstructure/LetStructure.java +++ b/src/main/java/com/aerospike/ael/parts/controlstructure/LetStructure.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.controlstructure; +package com.aerospike.ael.parts.controlstructure; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.operand.LetOperand; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.operand.LetOperand; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/controlstructure/OrStructure.java b/src/main/java/com/aerospike/ael/parts/controlstructure/OrStructure.java similarity index 67% rename from src/main/java/com/aerospike/dsl/parts/controlstructure/OrStructure.java rename to src/main/java/com/aerospike/ael/parts/controlstructure/OrStructure.java index edf472c6..3fc3947b 100644 --- a/src/main/java/com/aerospike/dsl/parts/controlstructure/OrStructure.java +++ b/src/main/java/com/aerospike/ael/parts/controlstructure/OrStructure.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.controlstructure; +package com.aerospike.ael.parts.controlstructure; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/controlstructure/WhenStructure.java b/src/main/java/com/aerospike/ael/parts/controlstructure/WhenStructure.java similarity index 76% rename from src/main/java/com/aerospike/dsl/parts/controlstructure/WhenStructure.java rename to src/main/java/com/aerospike/ael/parts/controlstructure/WhenStructure.java index 530cec76..66a32d59 100644 --- a/src/main/java/com/aerospike/dsl/parts/controlstructure/WhenStructure.java +++ b/src/main/java/com/aerospike/ael/parts/controlstructure/WhenStructure.java @@ -1,6 +1,6 @@ -package com.aerospike.dsl.parts.controlstructure; +package com.aerospike.ael.parts.controlstructure; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/aerospike/dsl/parts/operand/BlobOperand.java b/src/main/java/com/aerospike/ael/parts/operand/BlobOperand.java similarity index 72% rename from src/main/java/com/aerospike/dsl/parts/operand/BlobOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/BlobOperand.java index 713a9f59..dd20311d 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/BlobOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/BlobOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/operand/BooleanOperand.java b/src/main/java/com/aerospike/ael/parts/operand/BooleanOperand.java similarity index 69% rename from src/main/java/com/aerospike/dsl/parts/operand/BooleanOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/BooleanOperand.java index 431a3d2e..da458ef3 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/BooleanOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/BooleanOperand.java @@ -1,10 +1,10 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; -import static com.aerospike.dsl.parts.AbstractPart.PartType.BOOL_OPERAND; +import static com.aerospike.ael.parts.AbstractPart.PartType.BOOL_OPERAND; @Getter public class BooleanOperand extends AbstractPart implements ParsedValueOperand { diff --git a/src/main/java/com/aerospike/dsl/parts/operand/FloatOperand.java b/src/main/java/com/aerospike/ael/parts/operand/FloatOperand.java similarity index 75% rename from src/main/java/com/aerospike/dsl/parts/operand/FloatOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/FloatOperand.java index ca3ad048..3493cc4b 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/FloatOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/FloatOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/operand/FunctionArgs.java b/src/main/java/com/aerospike/ael/parts/operand/FunctionArgs.java similarity index 77% rename from src/main/java/com/aerospike/dsl/parts/operand/FunctionArgs.java rename to src/main/java/com/aerospike/ael/parts/operand/FunctionArgs.java index 378470df..be48fb3a 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/FunctionArgs.java +++ b/src/main/java/com/aerospike/ael/parts/operand/FunctionArgs.java @@ -1,6 +1,6 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/operand/IntOperand.java b/src/main/java/com/aerospike/ael/parts/operand/IntOperand.java similarity index 75% rename from src/main/java/com/aerospike/dsl/parts/operand/IntOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/IntOperand.java index 94f92d76..777ca80f 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/IntOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/IntOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/operand/LetOperand.java b/src/main/java/com/aerospike/ael/parts/operand/LetOperand.java similarity index 87% rename from src/main/java/com/aerospike/dsl/parts/operand/LetOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/LetOperand.java index 3c74d3f8..727c86f3 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/LetOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/LetOperand.java @@ -1,6 +1,6 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/aerospike/dsl/parts/operand/ListOperand.java b/src/main/java/com/aerospike/ael/parts/operand/ListOperand.java similarity index 74% rename from src/main/java/com/aerospike/dsl/parts/operand/ListOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/ListOperand.java index 244b029c..735c1405 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/ListOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/ListOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/operand/MapOperand.java b/src/main/java/com/aerospike/ael/parts/operand/MapOperand.java similarity index 75% rename from src/main/java/com/aerospike/dsl/parts/operand/MapOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/MapOperand.java index ecc17c59..590b8dfa 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/MapOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/MapOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import java.util.SortedMap; diff --git a/src/main/java/com/aerospike/dsl/parts/operand/MetadataOperand.java b/src/main/java/com/aerospike/ael/parts/operand/MetadataOperand.java similarity index 94% rename from src/main/java/com/aerospike/dsl/parts/operand/MetadataOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/MetadataOperand.java index 90597649..e77e1971 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/MetadataOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/MetadataOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/operand/OperandFactory.java b/src/main/java/com/aerospike/ael/parts/operand/OperandFactory.java similarity index 93% rename from src/main/java/com/aerospike/dsl/parts/operand/OperandFactory.java rename to src/main/java/com/aerospike/ael/parts/operand/OperandFactory.java index 3aab0d32..6a110383 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/OperandFactory.java +++ b/src/main/java/com/aerospike/ael/parts/operand/OperandFactory.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.fluent.AerospikeComparator; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.fluent.AerospikeComparator; +import com.aerospike.ael.parts.AbstractPart; import java.util.List; import java.util.Map; @@ -75,7 +75,7 @@ static AbstractPart createOperand(Object value) { sortedMap.putAll(objectMap); return new MapOperand(sortedMap); } catch (ClassCastException | NullPointerException | UnsupportedOperationException e) { - throw new DslParseException( + throw new AelParseException( "Map keys must be mutually comparable for operand creation", e); } } else { diff --git a/src/main/java/com/aerospike/dsl/parts/operand/ParsedValueOperand.java b/src/main/java/com/aerospike/ael/parts/operand/ParsedValueOperand.java similarity index 87% rename from src/main/java/com/aerospike/dsl/parts/operand/ParsedValueOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/ParsedValueOperand.java index c45680e8..14e25076 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/ParsedValueOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/ParsedValueOperand.java @@ -1,4 +1,4 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; /** * This interface provides an abstraction for an operand that returns a single value to be used for constructing diff --git a/src/main/java/com/aerospike/dsl/parts/operand/PlaceholderOperand.java b/src/main/java/com/aerospike/ael/parts/operand/PlaceholderOperand.java similarity index 85% rename from src/main/java/com/aerospike/dsl/parts/operand/PlaceholderOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/PlaceholderOperand.java index 1c11d0d2..365f6ad9 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/PlaceholderOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/PlaceholderOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/operand/StringOperand.java b/src/main/java/com/aerospike/ael/parts/operand/StringOperand.java similarity index 77% rename from src/main/java/com/aerospike/dsl/parts/operand/StringOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/StringOperand.java index 316464aa..94c0f660 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/StringOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/StringOperand.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import lombok.Setter; @@ -27,7 +27,7 @@ public Exp getExp() { byte[] byteValue = Base64.getDecoder().decode(value); return Exp.val(byteValue); } catch (IllegalArgumentException e) { - throw new DslParseException( + throw new AelParseException( "String compared to BLOB-typed path is not valid Base64: " + value, e); } } diff --git a/src/main/java/com/aerospike/dsl/parts/operand/VariableOperand.java b/src/main/java/com/aerospike/ael/parts/operand/VariableOperand.java similarity index 73% rename from src/main/java/com/aerospike/dsl/parts/operand/VariableOperand.java rename to src/main/java/com/aerospike/ael/parts/operand/VariableOperand.java index d8007606..6ba2e938 100644 --- a/src/main/java/com/aerospike/dsl/parts/operand/VariableOperand.java +++ b/src/main/java/com/aerospike/ael/parts/operand/VariableOperand.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/parts/path/BasePath.java b/src/main/java/com/aerospike/ael/parts/path/BasePath.java similarity index 85% rename from src/main/java/com/aerospike/dsl/parts/path/BasePath.java rename to src/main/java/com/aerospike/ael/parts/path/BasePath.java index d6eecbd1..884d612d 100644 --- a/src/main/java/com/aerospike/dsl/parts/path/BasePath.java +++ b/src/main/java/com/aerospike/ael/parts/path/BasePath.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.path; +package com.aerospike.ael.parts.path; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; import lombok.Getter; import java.util.List; diff --git a/src/main/java/com/aerospike/dsl/parts/path/BinPart.java b/src/main/java/com/aerospike/ael/parts/path/BinPart.java similarity index 81% rename from src/main/java/com/aerospike/dsl/parts/path/BinPart.java rename to src/main/java/com/aerospike/ael/parts/path/BinPart.java index 9ddf892d..e104d1dd 100644 --- a/src/main/java/com/aerospike/dsl/parts/path/BinPart.java +++ b/src/main/java/com/aerospike/ael/parts/path/BinPart.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.parts.path; +package com.aerospike.ael.parts.path; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.ExpressionContainer; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.ExpressionContainer; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/aerospike/dsl/parts/path/Path.java b/src/main/java/com/aerospike/ael/parts/path/Path.java similarity index 84% rename from src/main/java/com/aerospike/dsl/parts/path/Path.java rename to src/main/java/com/aerospike/ael/parts/path/Path.java index 94f5722a..f3a53d27 100644 --- a/src/main/java/com/aerospike/dsl/parts/path/Path.java +++ b/src/main/java/com/aerospike/ael/parts/path/Path.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.parts.path; +package com.aerospike.ael.parts.path; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.cdt.CdtPart; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.cdt.CdtPart; import lombok.Getter; import java.util.List; -import static com.aerospike.dsl.parts.cdt.CdtPart.isCdtPart; -import static com.aerospike.dsl.util.PathOperandUtils.*; +import static com.aerospike.ael.parts.cdt.CdtPart.isCdtPart; +import static com.aerospike.ael.util.PathOperandUtils.*; @Getter public class Path extends AbstractPart { diff --git a/src/main/java/com/aerospike/dsl/parts/path/PathFunction.java b/src/main/java/com/aerospike/ael/parts/path/PathFunction.java similarity index 90% rename from src/main/java/com/aerospike/dsl/parts/path/PathFunction.java rename to src/main/java/com/aerospike/ael/parts/path/PathFunction.java index 27750952..d54066ac 100644 --- a/src/main/java/com/aerospike/dsl/parts/path/PathFunction.java +++ b/src/main/java/com/aerospike/ael/parts/path/PathFunction.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.parts.path; +package com.aerospike.ael.parts.path; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer.ExprPartsOperation; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer.ExprPartsOperation; import lombok.Getter; @Getter diff --git a/src/main/java/com/aerospike/dsl/util/ParsingUtils.java b/src/main/java/com/aerospike/ael/util/ParsingUtils.java similarity index 91% rename from src/main/java/com/aerospike/dsl/util/ParsingUtils.java rename to src/main/java/com/aerospike/ael/util/ParsingUtils.java index d5b5b695..e9eec273 100644 --- a/src/main/java/com/aerospike/dsl/util/ParsingUtils.java +++ b/src/main/java/com/aerospike/ael/util/ParsingUtils.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.util; +package com.aerospike.ael.util; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.exp.Exp; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.exp.Exp; import lombok.NonNull; import lombok.experimental.UtilityClass; import org.antlr.v4.runtime.ParserRuleContext; @@ -29,7 +29,7 @@ public static int parseSignedInt(ConditionParser.SignedIntContext ctx) { String intText = ctx.INT().getText(); boolean isNegative = ctx.getText().startsWith("-"); if (isHexOrBinaryIntToken(intText)) { - throw new DslParseException("Only decimal integer literals are supported in this element: " + ctx.getText()); + throw new AelParseException("Only decimal integer literals are supported in this element: " + ctx.getText()); } BigInteger signedValue = getBigInteger(ctx, intText, isNegative); @@ -42,12 +42,12 @@ private static BigInteger getBigInteger(ConditionParser.SignedIntContext ctx, St try { value = new BigInteger(intText, 10); } catch (NumberFormatException e) { - throw new DslParseException("Invalid integer literal: " + ctx.getText(), e); + throw new AelParseException("Invalid integer literal: " + ctx.getText(), e); } BigInteger signedValue = isNegative ? value.negate() : value; if (signedValue.compareTo(INT_MIN_VALUE) < 0 || signedValue.compareTo(INT_MAX_VALUE) > 0) { - throw new DslParseException("Signed integer literal out of range for INT: " + ctx.getText()); + throw new AelParseException("Signed integer literal out of range for INT: " + ctx.getText()); } return signedValue; } @@ -69,7 +69,7 @@ private static boolean isHexOrBinaryIntToken(String intText) { public static long parseUnsignedLongLiteral(String text) { BigInteger value = parseUnsignedIntegerLiteral(text); if (value.compareTo(LONG_MIN_ABS) > 0) { - throw new DslParseException("Integer literal out of range: " + text); + throw new AelParseException("Integer literal out of range: " + text); } return value.longValue(); } @@ -90,7 +90,7 @@ private static BigInteger parseUnsignedIntegerLiteral(String text) { } return new BigInteger(digits, radix); } catch (NumberFormatException e) { - throw new DslParseException("Invalid integer literal: " + text, e); + throw new AelParseException("Invalid integer literal: " + text, e); } } @@ -129,7 +129,7 @@ public static String parseMapKey(ConditionParser.MapKeyContext ctx) { if (result != null) { return result; } - throw new DslParseException("Could not parse mapKey from ctx: %s".formatted(ctx.getText())); + throw new AelParseException("Could not parse mapKey from ctx: %s".formatted(ctx.getText())); } /** @@ -155,14 +155,14 @@ public static Object parseValueIdentifier(ConditionParser.ValueIdentifierContext if (b64Literal != null) { return parseB64ToBytes(b64Literal.getText()); } - throw new DslParseException("Could not parse valueIdentifier from ctx: %s".formatted(ctx.getText())); + throw new AelParseException("Could not parse valueIdentifier from ctx: %s".formatted(ctx.getText())); } // Token format: X'hexchars' or x'hexchars' — strip 2-char prefix and trailing quote public static byte[] parseHexToBytes(String text) { String hex = text.substring(2, text.length() - 1); if (hex.length() % 2 != 0) { - throw new DslParseException( + throw new AelParseException( "BLOB literal must contain an even number of hex characters: " + text); } byte[] bytes = new byte[hex.length() / 2]; @@ -178,7 +178,7 @@ public static byte[] parseB64ToBytes(String text) { try { return java.util.Base64.getDecoder().decode(b64); } catch (IllegalArgumentException e) { - throw new DslParseException( + throw new AelParseException( "Base64 BLOB literal contains invalid Base64 content: " + text, e); } } @@ -189,14 +189,14 @@ public static byte[] parseB64ToBytes(String text) { * * @param ctx The valueIdentifier context from the parser * @return The parsed integer value - * @throws DslParseException if the parsed value is not an integer + * @throws AelParseException if the parsed value is not an integer */ public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierContext ctx) { Object result = parseValueIdentifier(ctx); if (result instanceof Integer intValue) { return intValue; } - throw new DslParseException( + throw new AelParseException( "Value range requires integer operands, got: %s".formatted(ctx.getText())); } @@ -207,13 +207,13 @@ public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierC * * @param value The parsed value object * @return The corresponding {@link Exp} value expression - * @throws DslParseException if the value type is not supported + * @throws AelParseException if the value type is not supported */ public static Exp objectToExp(Object value) { if (value instanceof String s) return Exp.val(s); if (value instanceof Integer i) return Exp.val(i); if (value instanceof byte[] b) return Exp.val(b); - throw new DslParseException( + throw new AelParseException( "Unsupported value type for Exp conversion: " + value.getClass().getSimpleName()); } @@ -245,13 +245,13 @@ public static Integer subtractNullable(Integer a, @NonNull Integer b) { * * @param methodName The method name string * @return The extracted type string - * @throws DslParseException if the method name is not in the correct format + * @throws AelParseException if the method name is not in the correct format */ public static String extractTypeFromMethod(String methodName) { if (methodName.startsWith("as") && methodName.endsWith("()")) { return methodName.substring(2, methodName.length() - 2); } else { - throw new DslParseException("Invalid method name: %s".formatted(methodName)); + throw new AelParseException("Invalid method name: %s".formatted(methodName)); } } diff --git a/src/main/java/com/aerospike/dsl/util/PathOperandUtils.java b/src/main/java/com/aerospike/ael/util/PathOperandUtils.java similarity index 96% rename from src/main/java/com/aerospike/dsl/util/PathOperandUtils.java rename to src/main/java/com/aerospike/ael/util/PathOperandUtils.java index 8cac60c9..1bde8b57 100644 --- a/src/main/java/com/aerospike/dsl/util/PathOperandUtils.java +++ b/src/main/java/com/aerospike/ael/util/PathOperandUtils.java @@ -1,29 +1,29 @@ -package com.aerospike.dsl.util; - -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.cdt.CdtPart; -import com.aerospike.dsl.parts.cdt.list.ListPart; -import com.aerospike.dsl.parts.cdt.list.ListTypeDesignator; -import com.aerospike.dsl.parts.cdt.map.MapPart; -import com.aerospike.dsl.parts.cdt.map.MapTypeDesignator; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.parts.path.BinPart; -import com.aerospike.dsl.parts.path.PathFunction; +package com.aerospike.ael.util; + +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.cdt.CdtPart; +import com.aerospike.ael.parts.cdt.list.ListPart; +import com.aerospike.ael.parts.cdt.list.ListTypeDesignator; +import com.aerospike.ael.parts.cdt.map.MapPart; +import com.aerospike.ael.parts.cdt.map.MapTypeDesignator; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.parts.path.BinPart; +import com.aerospike.ael.parts.path.PathFunction; import lombok.experimental.UtilityClass; import java.util.ArrayList; import java.util.List; import java.util.function.UnaryOperator; -import static com.aerospike.dsl.parts.AbstractPart.PartType.LIST_PART; -import static com.aerospike.dsl.parts.AbstractPart.PartType.MAP_PART; -import static com.aerospike.dsl.parts.cdt.list.ListPart.ListPartType.*; -import static com.aerospike.dsl.parts.cdt.map.MapPart.MapPartType.MAP_TYPE_DESIGNATOR; -import static com.aerospike.dsl.parts.path.PathFunction.PathFunctionType.*; +import static com.aerospike.ael.parts.AbstractPart.PartType.LIST_PART; +import static com.aerospike.ael.parts.AbstractPart.PartType.MAP_PART; +import static com.aerospike.ael.parts.cdt.list.ListPart.ListPartType.*; +import static com.aerospike.ael.parts.cdt.map.MapPart.MapPartType.MAP_TYPE_DESIGNATOR; +import static com.aerospike.ael.parts.path.PathFunction.PathFunctionType.*; @UtilityClass public class PathOperandUtils { diff --git a/src/main/java/com/aerospike/dsl/util/TypeUtils.java b/src/main/java/com/aerospike/ael/util/TypeUtils.java similarity index 86% rename from src/main/java/com/aerospike/dsl/util/TypeUtils.java rename to src/main/java/com/aerospike/ael/util/TypeUtils.java index 85c66b18..8b92b460 100644 --- a/src/main/java/com/aerospike/dsl/util/TypeUtils.java +++ b/src/main/java/com/aerospike/ael/util/TypeUtils.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.util; +package com.aerospike.ael.util; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.cdt.map.MapTypeDesignator; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.cdt.map.MapTypeDesignator; import lombok.experimental.UtilityClass; @UtilityClass diff --git a/src/main/java/com/aerospike/dsl/util/ValidationUtils.java b/src/main/java/com/aerospike/ael/util/ValidationUtils.java similarity index 76% rename from src/main/java/com/aerospike/dsl/util/ValidationUtils.java rename to src/main/java/com/aerospike/ael/util/ValidationUtils.java index 25bede7b..a4554f01 100644 --- a/src/main/java/com/aerospike/dsl/util/ValidationUtils.java +++ b/src/main/java/com/aerospike/ael/util/ValidationUtils.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.util; +package com.aerospike.ael.util; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.exp.Exp; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.exp.Exp; import lombok.experimental.UtilityClass; @UtilityClass @@ -10,11 +10,11 @@ public class ValidationUtils { /** * Validates if two {@link Exp.Type} instances are comparable. * Comparison is allowed if both types are the same, or if one is {@code INT} and the other is {@code FLOAT}. - * If the types are not comparable, a {@link DslParseException} is thrown. + * If the types are not comparable, a {@link AelParseException} is thrown. * * @param leftType The {@link Exp.Type} of the left operand. Can be {@code null} * @param rightType The {@link Exp.Type} of the right operand. Can be {@code null} - * @throws DslParseException If both types are not {@code null} and are not comparable + * @throws AelParseException If both types are not {@code null} and are not comparable */ public static void validateComparableTypes(Exp.Type leftType, Exp.Type rightType) { if (leftType != null && rightType != null) { @@ -23,7 +23,7 @@ public static void validateComparableTypes(Exp.Type leftType, Exp.Type rightType (leftType.equals(Exp.Type.FLOAT) && rightType.equals(Exp.Type.INT)); if (!leftType.equals(rightType) && !isIntAndFloat) { - throw new DslParseException("Cannot compare %s to %s".formatted(leftType, rightType)); + throw new AelParseException("Cannot compare %s to %s".formatted(leftType, rightType)); } } } diff --git a/src/main/java/com/aerospike/dsl/visitor/ExpressionConditionVisitor.java b/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java similarity index 93% rename from src/main/java/com/aerospike/dsl/visitor/ExpressionConditionVisitor.java rename to src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java index 21bc6882..193c187b 100644 --- a/src/main/java/com/aerospike/dsl/visitor/ExpressionConditionVisitor.java +++ b/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java @@ -1,32 +1,32 @@ -package com.aerospike.dsl.visitor; - -import com.aerospike.dsl.ConditionBaseVisitor; -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.fluent.AerospikeComparator; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; -import com.aerospike.dsl.parts.cdt.list.ListIndex; -import com.aerospike.dsl.parts.cdt.list.ListIndexRange; -import com.aerospike.dsl.parts.cdt.list.ListRank; -import com.aerospike.dsl.parts.cdt.list.ListRankRange; -import com.aerospike.dsl.parts.cdt.list.ListRankRangeRelative; -import com.aerospike.dsl.parts.cdt.list.ListTypeDesignator; -import com.aerospike.dsl.parts.cdt.list.ListValue; -import com.aerospike.dsl.parts.cdt.list.ListValueList; -import com.aerospike.dsl.parts.cdt.list.ListValueRange; -import com.aerospike.dsl.parts.cdt.map.*; -import com.aerospike.dsl.parts.controlstructure.AndStructure; -import com.aerospike.dsl.parts.controlstructure.ExclusiveStructure; -import com.aerospike.dsl.parts.controlstructure.LetStructure; -import com.aerospike.dsl.parts.controlstructure.OrStructure; -import com.aerospike.dsl.parts.controlstructure.WhenStructure; -import com.aerospike.dsl.parts.operand.*; -import com.aerospike.dsl.parts.path.BasePath; -import com.aerospike.dsl.parts.path.BinPart; -import com.aerospike.dsl.parts.path.Path; -import com.aerospike.dsl.parts.path.PathFunction; +package com.aerospike.ael.visitor; + +import com.aerospike.ael.ConditionBaseVisitor; +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.fluent.AerospikeComparator; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; +import com.aerospike.ael.parts.cdt.list.ListIndex; +import com.aerospike.ael.parts.cdt.list.ListIndexRange; +import com.aerospike.ael.parts.cdt.list.ListRank; +import com.aerospike.ael.parts.cdt.list.ListRankRange; +import com.aerospike.ael.parts.cdt.list.ListRankRangeRelative; +import com.aerospike.ael.parts.cdt.list.ListTypeDesignator; +import com.aerospike.ael.parts.cdt.list.ListValue; +import com.aerospike.ael.parts.cdt.list.ListValueList; +import com.aerospike.ael.parts.cdt.list.ListValueRange; +import com.aerospike.ael.parts.cdt.map.*; +import com.aerospike.ael.parts.controlstructure.AndStructure; +import com.aerospike.ael.parts.controlstructure.ExclusiveStructure; +import com.aerospike.ael.parts.controlstructure.LetStructure; +import com.aerospike.ael.parts.controlstructure.OrStructure; +import com.aerospike.ael.parts.controlstructure.WhenStructure; +import com.aerospike.ael.parts.operand.*; +import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.parts.path.BinPart; +import com.aerospike.ael.parts.path.Path; +import com.aerospike.ael.parts.path.PathFunction; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.RuleNode; @@ -39,8 +39,8 @@ import java.util.SortedMap; import java.util.TreeMap; -import static com.aerospike.dsl.util.ParsingUtils.*; -import static com.aerospike.dsl.visitor.VisitorUtils.*; +import static com.aerospike.ael.util.ParsingUtils.*; +import static com.aerospike.ael.visitor.VisitorUtils.*; public class ExpressionConditionVisitor extends ConditionBaseVisitor { @@ -132,7 +132,7 @@ public AbstractPart visitNotExpression(ConditionParser.NotExpressionContext ctx) @Override public AbstractPart visitExclusiveExpression(ConditionParser.ExclusiveExpressionContext ctx) { if (ctx.expression().size() < 2) { - throw new DslParseException("Exclusive logical operator requires 2 or more expressions"); + throw new AelParseException("Exclusive logical operator requires 2 or more expressions"); } List expressions = new ArrayList<>(); // iterate through each sub-expression @@ -261,7 +261,7 @@ private AbstractPart tryParseLongMinLiteral(ConditionParser.UnaryExpressionConte private static long negateLongLiteral(long value, String input) { if (value == Long.MIN_VALUE) { - throw new DslParseException("Integer literal out of range: " + input); + throw new AelParseException("Integer literal out of range: " + input); } return -value; } @@ -282,15 +282,15 @@ public AbstractPart visitInExpression(ConditionParser.InExpressionContext ctx) { * the right operand is a list-compatible type (LIST_OPERAND, BIN_PART, * PATH_OPERAND, VARIABLE_OPERAND, or PLACEHOLDER_OPERAND). * - * @throws DslParseException if either operand is null or the right operand + * @throws AelParseException if either operand is null or the right operand * is not a list-compatible type */ private static void validateInRightOperand(AbstractPart left, AbstractPart right) { if (left == null) { - throw new DslParseException("Unable to parse left operand"); + throw new AelParseException("Unable to parse left operand"); } if (right == null) { - throw new DslParseException("Unable to parse right operand"); + throw new AelParseException("Unable to parse right operand"); } if (right.getPartType() == AbstractPart.PartType.PLACEHOLDER_OPERAND || right.getPartType() == AbstractPart.PartType.LIST_OPERAND @@ -299,7 +299,7 @@ private static void validateInRightOperand(AbstractPart left, AbstractPart right || right.getPartType() == AbstractPart.PartType.VARIABLE_OPERAND) { return; } - throw new DslParseException("IN operation requires a List as the right operand"); + throw new AelParseException("IN operation requires a List as the right operand"); } /** @@ -321,12 +321,12 @@ private static void inferInTypes(AbstractPart left, AbstractPart right) { if (!rightBin.isTypeExplicitlySet()) { rightBin.updateExp(Exp.Type.LIST); } else if (rightBin.getExpType() != Exp.Type.LIST) { - throw new DslParseException( + throw new AelParseException( "IN operation requires a List as the right operand"); } } else if (right.getPartType() == AbstractPart.PartType.PATH_OPERAND) { if (isPathExplicitlyNonList((Path) right)) { - throw new DslParseException( + throw new AelParseException( "IN operation requires a List as the right operand"); } } @@ -345,7 +345,7 @@ private static void inferInTypes(AbstractPart left, AbstractPart right) { * * @param left the left operand of the IN expression * @param inferredType the element type inferred from the right list (may be {@code null}) - * @throws DslParseException if the left operand type cannot be determined + * @throws AelParseException if the left operand type cannot be determined */ private static void validateLeftTypeNotAmbiguous(AbstractPart left, Exp.Type inferredType) { if (inferredType != null) { @@ -354,7 +354,7 @@ private static void validateLeftTypeNotAmbiguous(AbstractPart left, Exp.Type inf if (!isLeftTypeAmbiguous(left)) { return; } - throw new DslParseException( + throw new AelParseException( "cannot infer the type of the left operand for IN operation; " + "use .get(type: ) to specify it"); } @@ -494,7 +494,7 @@ private static void validateInVariableIsListCompatible(ExpressionContainer expr, String varName = ((VariableOperand) expr.getRight()).getValue(); AbstractPart boundPart = varBindings.get(varName); if (boundPart != null && isNotList(boundPart)) { - throw new DslParseException( + throw new AelParseException( "IN operation requires a List as the right operand; " + "variable '" + varName + "' contains a non-List type"); } @@ -645,7 +645,7 @@ public AbstractPart visitFunctionCall(ConditionParser.FunctionCallContext ctx) { // If error recovery created this node without actual parentheses, fail fast if (ctx.getChildCount() < 3 || !ctx.getChild(1).getText().equals("(")) { String name = ctx.getChildCount() > 0 ? ctx.getChild(0).getText() : ""; - throw new DslParseException("Unexpected identifier: " + name); + throw new AelParseException("Unexpected identifier: " + name); } String funcName = ctx.NAME_IDENTIFIER().getText(); @@ -701,20 +701,20 @@ yield new ExpressionContainer(args.get(0), args.get(1), yield new ExpressionContainer(args.get(0), args.get(1), ExpressionContainer.ExprPartsOperation.FIND_BIT_RIGHT); } - default -> throw new DslParseException("Unknown function: " + funcName); + default -> throw new AelParseException("Unknown function: " + funcName); }; } private void validateFunctionArgCount(String funcName, List args, int expected) { if (args.size() != expected) { - throw new DslParseException( + throw new AelParseException( "Function '%s' expects %d argument(s), got %d".formatted(funcName, expected, args.size())); } } private void validateFunctionArgCountAtLeast(String funcName, List args, int minCount) { if (args.size() < minCount) { - throw new DslParseException( + throw new AelParseException( "Function '%s' expects at least %d arguments, got %d".formatted(funcName, minCount, args.size())); } } @@ -843,7 +843,7 @@ public AbstractPart visitBinPart(ConditionParser.BinPartContext ctx) { if (ctx.IN() != null) { return new BinPart(ctx.IN().getText()); } - throw new DslParseException("Could not parse binPart from ctx: %s".formatted(ctx.getText())); + throw new AelParseException("Could not parse binPart from ctx: %s".formatted(ctx.getText())); } @Override @@ -870,13 +870,13 @@ public ListOperand readChildrenIntoListOperand(RuleNode listNode) { AbstractPart operand = visit(child); // delegate to a dedicated visitor if (operand == null) { - throw new DslParseException("Unable to parse list operand"); + throw new AelParseException("Unable to parse list operand"); } try { values.add(((ParsedValueOperand) operand).getValue()); } catch (ClassCastException e) { - throw new DslParseException("List constant contains elements of different type"); + throw new AelParseException("List constant contains elements of different type"); } } @@ -890,7 +890,7 @@ public AbstractPart visitOrderedMapConstant(ConditionParser.OrderedMapConstantCo public SortedMap getOrderedMapPair(ParseTree ctx) { if (ctx.getChild(0) == null || ctx.getChild(2) == null) { - throw new DslParseException("Unable to parse map operand"); + throw new AelParseException("Unable to parse map operand"); } Object key = ((ParsedValueOperand) visit(ctx.getChild(0))).getValue(); @@ -916,7 +916,7 @@ public MapOperand readChildrenIntoMapOperand(RuleNode mapNode) { try { mapOfPair.forEach(map::putIfAbsent); // put contents of the current map pair to the resulting map } catch (ClassCastException e) { - throw new DslParseException("Map constant contains elements of different type"); + throw new AelParseException("Map constant contains elements of different type"); } } @@ -956,7 +956,7 @@ public AbstractPart visitIntOperand(ConditionParser.IntOperandContext ctx) { private static long parseIntLiteral(String text) { long parsed = parseUnsignedLongLiteral(text); if (parsed == Long.MIN_VALUE) { - throw new DslParseException("Integer literal out of range: " + text); + throw new AelParseException("Integer literal out of range: " + text); } return parsed; } @@ -974,7 +974,7 @@ public AbstractPart visitFloatOperand(ConditionParser.FloatOperandContext ctx) { String leadingDotFloat = ctx.LEADING_DOT_FLOAT().getText(); return new FloatOperand(Double.parseDouble("0" + leadingDotFloat)); } catch (NumberFormatException e) { - throw new DslParseException("Invalid float literal: " + ctx.getText(), e); + throw new AelParseException("Invalid float literal: " + ctx.getText(), e); } } @@ -1005,12 +1005,12 @@ public AbstractPart visitBasePath(ConditionParser.BasePathContext ctx) { switch (part.getPartType()) { case BIN_PART -> binPart = (BinPart) part; case LIST_PART, MAP_PART -> cdtParts.add(part); - default -> throw new DslParseException("Unexpected path part: %s".formatted(part.getPartType())); + default -> throw new AelParseException("Unexpected path part: %s".formatted(part.getPartType())); } } if (binPart == null) { - throw new DslParseException("Expecting bin to be the first path part from the left"); + throw new AelParseException("Expecting bin to be the first path part from the left"); } return new BasePath(binPart, cdtParts); @@ -1074,7 +1074,7 @@ public AbstractPart visitListPart(ConditionParser.ListPartContext ctx) { if (ctx.listRankRange() != null) return ListRankRange.from(ctx.listRankRange()); if (ctx.listRankRangeRelative() != null) return ListRankRangeRelative.from(ctx.listRankRangeRelative()); - throw new DslParseException("Unexpected list part: %s".formatted(ctx.getText())); + throw new AelParseException("Unexpected list part: %s".formatted(ctx.getText())); } @Override @@ -1094,7 +1094,7 @@ public AbstractPart visitMapPart(ConditionParser.MapPartContext ctx) { return MapRankRangeRelative.from(ctx.mapRankRangeRelative()); if (ctx.mapIndexRangeRelative() != null) return MapIndexRangeRelative.from(ctx.mapIndexRangeRelative()); - throw new DslParseException("Unexpected map part: %s".formatted(ctx.getText())); + throw new AelParseException("Unexpected map part: %s".formatted(ctx.getText())); } @Override diff --git a/src/main/java/com/aerospike/dsl/visitor/NoApplicableFilterException.java b/src/main/java/com/aerospike/ael/visitor/NoApplicableFilterException.java similarity index 79% rename from src/main/java/com/aerospike/dsl/visitor/NoApplicableFilterException.java rename to src/main/java/com/aerospike/ael/visitor/NoApplicableFilterException.java index b602128e..939e464d 100644 --- a/src/main/java/com/aerospike/dsl/visitor/NoApplicableFilterException.java +++ b/src/main/java/com/aerospike/ael/visitor/NoApplicableFilterException.java @@ -1,11 +1,11 @@ -package com.aerospike.dsl.visitor; +package com.aerospike.ael.visitor; -import com.aerospike.dsl.client.query.Filter; +import com.aerospike.ael.client.query.Filter; /** - * Indicates that no applicable {@link Filter} could be generated for a given DSL expression. For internal use. + * Indicates that no applicable {@link Filter} could be generated for a given AEL expression. For internal use. * - *

    This exception is typically thrown when attempting to create a Filter for a DSL expression + *

    This exception is typically thrown when attempting to create a Filter for a AEL expression * but the structure or types of the expression do not match any supported filtering patterns * (e.g., comparing Strings using arithmetical operations, using OR-combined expression etc.). * It signifies that while the expression might be valid in a broader context, it cannot be represented with a diff --git a/src/main/java/com/aerospike/dsl/visitor/VisitorUtils.java b/src/main/java/com/aerospike/ael/visitor/VisitorUtils.java similarity index 95% rename from src/main/java/com/aerospike/dsl/visitor/VisitorUtils.java rename to src/main/java/com/aerospike/ael/visitor/VisitorUtils.java index e38e1d05..937fd1f2 100644 --- a/src/main/java/com/aerospike/dsl/visitor/VisitorUtils.java +++ b/src/main/java/com/aerospike/ael/visitor/VisitorUtils.java @@ -1,34 +1,34 @@ -package com.aerospike.dsl.visitor; - -import com.aerospike.dsl.ConditionParser; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; -import com.aerospike.dsl.parts.AbstractPart; -import com.aerospike.dsl.parts.ExpressionContainer; -import com.aerospike.dsl.parts.ExpressionContainer.ExprPartsOperation; -import com.aerospike.dsl.parts.controlstructure.AndStructure; -import com.aerospike.dsl.parts.controlstructure.ExclusiveStructure; -import com.aerospike.dsl.parts.controlstructure.LetStructure; -import com.aerospike.dsl.parts.controlstructure.OrStructure; -import com.aerospike.dsl.parts.controlstructure.WhenStructure; -import com.aerospike.dsl.parts.operand.BlobOperand; -import com.aerospike.dsl.parts.operand.FunctionArgs; -import com.aerospike.dsl.parts.operand.IntOperand; -import com.aerospike.dsl.parts.operand.LetOperand; -import com.aerospike.dsl.parts.operand.ListOperand; -import com.aerospike.dsl.parts.operand.MetadataOperand; -import com.aerospike.dsl.parts.operand.PlaceholderOperand; -import com.aerospike.dsl.parts.operand.StringOperand; -import com.aerospike.dsl.parts.path.BinPart; -import com.aerospike.dsl.parts.path.Path; -import com.aerospike.dsl.util.TypeUtils; +package com.aerospike.ael.visitor; + +import com.aerospike.ael.ConditionParser; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.Index; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; +import com.aerospike.ael.parts.AbstractPart; +import com.aerospike.ael.parts.ExpressionContainer; +import com.aerospike.ael.parts.ExpressionContainer.ExprPartsOperation; +import com.aerospike.ael.parts.controlstructure.AndStructure; +import com.aerospike.ael.parts.controlstructure.ExclusiveStructure; +import com.aerospike.ael.parts.controlstructure.LetStructure; +import com.aerospike.ael.parts.controlstructure.OrStructure; +import com.aerospike.ael.parts.controlstructure.WhenStructure; +import com.aerospike.ael.parts.operand.BlobOperand; +import com.aerospike.ael.parts.operand.FunctionArgs; +import com.aerospike.ael.parts.operand.IntOperand; +import com.aerospike.ael.parts.operand.LetOperand; +import com.aerospike.ael.parts.operand.ListOperand; +import com.aerospike.ael.parts.operand.MetadataOperand; +import com.aerospike.ael.parts.operand.PlaceholderOperand; +import com.aerospike.ael.parts.operand.StringOperand; +import com.aerospike.ael.parts.path.BinPart; +import com.aerospike.ael.parts.path.Path; +import com.aerospike.ael.util.TypeUtils; import lombok.experimental.UtilityClass; import org.antlr.v4.runtime.misc.Pair; import org.antlr.v4.runtime.tree.ParseTree; @@ -48,10 +48,10 @@ import java.util.function.Predicate; import java.util.function.UnaryOperator; -import static com.aerospike.dsl.parts.AbstractPart.PartType.*; -import static com.aerospike.dsl.parts.ExpressionContainer.ExprPartsOperation.*; -import static com.aerospike.dsl.util.ValidationUtils.validateComparableTypes; -import static com.aerospike.dsl.visitor.VisitorUtils.ArithmeticTermType.*; +import static com.aerospike.ael.parts.AbstractPart.PartType.*; +import static com.aerospike.ael.parts.ExpressionContainer.ExprPartsOperation.*; +import static com.aerospike.ael.util.ValidationUtils.validateComparableTypes; +import static com.aerospike.ael.visitor.VisitorUtils.ArithmeticTermType.*; @UtilityClass public class VisitorUtils { @@ -188,14 +188,14 @@ static String extractVariableNameOrFail(String variableReference) { * * @param left The left {@link AbstractPart} operand, whose type information might be updated * @param right The right {@link AbstractPart} operand, whose type information might be updated - * @throws DslParseException If either the left or right operand is {@code null} + * @throws AelParseException If either the left or right operand is {@code null} */ static void overrideTypeInfo(AbstractPart left, AbstractPart right) { if (left == null) { - throw new DslParseException("Unable to parse left operand"); + throw new AelParseException("Unable to parse left operand"); } if (right == null) { - throw new DslParseException("Unable to parse right operand"); + throw new AelParseException("Unable to parse right operand"); } if (left.getPartType() == PLACEHOLDER_OPERAND || right.getPartType() == PLACEHOLDER_OPERAND) { return; @@ -330,7 +330,7 @@ static boolean shouldVisitMapElement(int i, int size, ParseTree child) { * @param operator The binary operator to apply * @param isBinLeft Whether the bin is on the left side of the comparison * @return The resulting expression - * @throws DslParseException if the operand type is not supported + * @throws AelParseException if the operand type is not supported */ private static Exp getExpBinComparison(BinPart binPart, AbstractPart anotherPart, BinaryOperator operator, boolean isBinLeft) { @@ -381,7 +381,7 @@ private static Exp getExpBinComparison(BinPart binPart, AbstractPart anotherPart yield anotherPart.getExp(); } default -> - throw new DslParseException("Operand type not supported: %s".formatted(anotherPart.getPartType())); + throw new AelParseException("Operand type not supported: %s".formatted(anotherPart.getPartType())); }; return isBinLeft ? operator.apply(binExp, anotherExp) : operator.apply(anotherExp, binExp); @@ -393,7 +393,7 @@ private static Exp getExpBinComparison(BinPart binPart, AbstractPart anotherPart * @param binPart The {@link BinPart} involved in the comparison * @param stringOperand The {@link StringOperand} involved in the comparison * @return The {@link Exp} generated from the {@link StringOperand} - * @throws DslParseException if type validation fails (e.g., comparing a non-string/blob bin with a String) + * @throws AelParseException if type validation fails (e.g., comparing a non-string/blob bin with a String) */ private static Exp handleStringOperandComparison(BinPart binPart, StringOperand stringOperand) { boolean isBlobType = binPart.getExpType() != null && binPart.getExpType().equals(Exp.Type.BLOB); @@ -415,7 +415,7 @@ private static Exp handleStringOperandComparison(BinPart binPart, StringOperand * @param right The {@link AbstractPart} on the right side of the comparison * @param operator The binary operator to apply * @return The resulting {@link Exp} for the comparison - * @throws DslParseException if an unsupported operand type is encountered or type validation fails + * @throws AelParseException if an unsupported operand type is encountered or type validation fails */ private static Exp getExpLeftBinTypeComparison(BinPart left, AbstractPart right, BinaryOperator operator) { return getExpBinComparison(left, right, operator, true); @@ -428,7 +428,7 @@ private static Exp getExpLeftBinTypeComparison(BinPart left, AbstractPart right, * @param right The {@link BinPart} on the right side of the comparison * @param operator The binary operator to apply * @return The resulting {@link Exp} for the comparison - * @throws DslParseException if an unsupported operand type is encountered or type validation fails + * @throws AelParseException if an unsupported operand type is encountered or type validation fails */ private static Exp getExpRightBinTypeComparison(AbstractPart left, BinPart right, BinaryOperator operator) { return getExpBinComparison(right, left, operator, false); @@ -483,7 +483,7 @@ private static ArithmeticTermType getFilterTermType(ExprPartsOperation operation * @return A {@link Pair} representing the lower and upper bounds of the range for the bin. * A {@code null} value in the pair indicates no bound on that side * @throws NoApplicableFilterException if division by zero occurs or the term type is unsupported - * @throws DslParseException if undefined division (0/0) occurs + * @throws AelParseException if undefined division (0/0) occurs */ private static Pair getLimitsForDivisionForFilter(long left, long right, FilterOperationType type, ArithmeticTermType termType) { @@ -508,7 +508,7 @@ private static Pair getLimitsForDivisionForFilter(long left, long ri * @param operationType The type of the filter operation * @return A {@link Pair} representing the lower and upper bounds of the range for the bin. * A {@code null} value in the pair indicates no bound on that side - * @throws DslParseException if undefined division (0/0) occurs or if the operation type is not supported + * @throws AelParseException if undefined division (0/0) occurs or if the operation type is not supported */ private static Pair LimitsForBinDividend( long left, long right, FilterOperationType operationType @@ -517,7 +517,7 @@ private static Pair LimitsForBinDividend( // both operands are positive return getLimitsForBinDividendWithLeftNumberPositive(operationType, left, right); } else if (left == 0 && right == 0) { - throw new DslParseException("Undefined division for 0 / 0"); + throw new AelParseException("Undefined division for 0 / 0"); } else if (left < 0 && right < 0) { // both operands are negative return getLimitsForBinDividendWithLeftNumberNegative(operationType, left, right); @@ -528,7 +528,7 @@ private static Pair LimitsForBinDividend( // left negative, right positive return getLimitsForBinDividendWithLeftNumberNegative(operationType, left, right); } else if (left != 0) { - throw new DslParseException("Division by zero is not allowed"); + throw new AelParseException("Division by zero is not allowed"); } else { return new Pair<>(null, null); } @@ -541,7 +541,7 @@ private static Pair LimitsForBinDividend( * @param left The value of the dividend * @param right The value of the divisor * @return A {@link Pair} representing the lower and upper bounds of the range for the bin - * @throws DslParseException if the operation type is not supported for division + * @throws AelParseException if the operation type is not supported for division */ private static Pair getLimitsForBinDividendWithLeftNumberNegative( FilterOperationType operationType, long left, long right @@ -551,7 +551,7 @@ private static Pair getLimitsForBinDividendWithLeftNumberNegative( case GTEQ -> new Pair<>(Long.MIN_VALUE, left * right); case LT -> new Pair<>(left * right + 1, Long.MAX_VALUE); case LTEQ -> new Pair<>(left * right, Long.MAX_VALUE); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } @@ -562,7 +562,7 @@ private static Pair getLimitsForBinDividendWithLeftNumberNegative( * @param left The value of the dividend * @param right The value of the divisor * @return A {@link Pair} representing the lower and upper bounds of the range for the bin - * @throws DslParseException if the operation type is not supported for division + * @throws AelParseException if the operation type is not supported for division */ private static Pair getLimitsForBinDividendWithLeftNumberPositive( FilterOperationType operationType, long left, long right @@ -572,7 +572,7 @@ private static Pair getLimitsForBinDividendWithLeftNumberPositive( case GTEQ -> new Pair<>(left * right, Long.MAX_VALUE); case LT -> new Pair<>(Long.MIN_VALUE, left * right - 1); case LTEQ -> new Pair<>(Long.MIN_VALUE, left * right); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } @@ -584,7 +584,7 @@ private static Pair getLimitsForBinDividendWithLeftNumberPositive( * @param operationType The type of the filter operation * @return A {@link Pair} representing the lower and upper bounds of the range for the bin. * A {@code null} value in the pair indicates no bound on that side - * @throws DslParseException if division by zero occurs or if the operation type is not supported + * @throws AelParseException if division by zero occurs or if the operation type is not supported */ private static Pair getLimitsForBinDivisor(long left, long right, FilterOperationType operationType) { if (left > 0 && right > 0) { @@ -593,17 +593,17 @@ private static Pair getLimitsForBinDivisor(long left, long right, Fi case GT -> new Pair<>(1L, getClosestLongToTheLeft((float) left / right)); case GTEQ -> new Pair<>(1L, left / right); case LT, LTEQ -> new Pair<>(null, null); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } else if (left == 0 && right == 0) { - throw new DslParseException("Cannot divide by zero"); + throw new AelParseException("Cannot divide by zero"); } else if (left < 0 && right < 0) { // both operands are negative return switch (operationType) { case GT, GTEQ -> new Pair<>(null, null); case LT -> new Pair<>(1L, getClosestLongToTheLeft((float) left / right)); case LTEQ -> new Pair<>(1L, left / right); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } else if (left > 0 && right < 0) { // left positive, right negative @@ -611,7 +611,7 @@ private static Pair getLimitsForBinDivisor(long left, long right, Fi case GT, GTEQ -> new Pair<>(null, null); case LT -> new Pair<>(getClosestLongToTheRight((float) left / right), -1L); case LTEQ -> new Pair<>(left / right, -1L); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } else if (right > 0 && left < 0) { // right positive, left negative @@ -619,10 +619,10 @@ private static Pair getLimitsForBinDivisor(long left, long right, Fi case GT -> new Pair<>(getClosestLongToTheRight((float) left / right), -1L); case GTEQ -> new Pair<>(left / right, -1L); case LT, LTEQ -> new Pair<>(null, null); - default -> throw new DslParseException("OperationType not supported for division: " + operationType); + default -> throw new AelParseException("OperationType not supported for division: " + operationType); }; } else if (left != 0) { - throw new DslParseException("Division by zero is not allowed"); + throw new AelParseException("Division by zero is not allowed"); } else { return new Pair<>(null, null); } @@ -636,14 +636,14 @@ private static Pair getLimitsForBinDivisor(long left, long right, Fi * A {@code null} value in the pair indicates no bound on that side * @param type The type of the filter operation * @return A {@link Filter} representing the condition - * @throws DslParseException if the operation type is not supported for generating a filter + * @throws AelParseException if the operation type is not supported for generating a filter */ private static Filter getFilterForDivOrFail(String binName, Pair value, FilterOperationType type) { // Based on the operation type, generate the appropriate filter range return switch (type) { case GT, GTEQ, LT, LTEQ -> Filter.range(binName, value.a, value.b); // Range from 1 to value - 1 case EQ -> Filter.equal(binName, value.a); // Exact match for equality case - default -> throw new DslParseException("OperationType not supported for division: " + type); + default -> throw new AelParseException("OperationType not supported for division: " + type); }; } @@ -720,7 +720,7 @@ private static Filter getFilterFromPath(Path path, AbstractPart operand, FilterO * @param ctx Array of {@link CTX} objects representing CDT context, can be null * @return An Aerospike {@link Filter} for the string or blob comparison * @throws NoApplicableFilterException if the filter operation type is not equality - * @throws DslParseException if type validation fails or base64 decoding fails + * @throws AelParseException if type validation fails or base64 decoding fails */ private static Filter handleStringOperand(BinPart bin, String binName, String operandValue, FilterOperationType type, CTX[] ctx) { @@ -747,7 +747,7 @@ private static Filter handleStringOperand(BinPart bin, String binName, String op * @param right The right operand * @param type The filter operation type * @return The appropriate Filter, or null if no filter can be created - * @throws DslParseException if operands are invalid + * @throws AelParseException if operands are invalid */ private static Filter getFilterOrNull(AbstractPart left, AbstractPart right, FilterOperationType type) { validateOperands(left, right); @@ -785,7 +785,7 @@ private static Filter getFilterOrNull(AbstractPart left, AbstractPart right, Fil * @param otherOperand The other operand in the filter condition * @param type The type of the filter operation * @return A {@link Filter} if one can be generated from the nested expression, otherwise {@code null} - * @throws DslParseException if operands within the nested expression are null + * @throws AelParseException if operands within the nested expression are null * @throws NoApplicableFilterException if the nested expression structure is not supported for filtering */ private static Filter handleExpressionOperand(ExpressionContainer expr, AbstractPart otherOperand, @@ -851,7 +851,7 @@ private static Filter getFilterFromExpressionOrNull(AbstractPart exprLeft, Abstr * @param isBinOnLeft {@code true} if the bin is on the left side of the arithmetic operation, {@code false} otherwise * @return A {@link Filter} for the arithmetic condition * @throws NoApplicableFilterException if operands are not integers or if the operation is not supported - * @throws DslParseException if type validation fails + * @throws AelParseException if type validation fails */ private static Filter handleBinArithmeticExpression(BinPart bin, AbstractPart operand, AbstractPart externalOperand, @@ -879,14 +879,14 @@ private static Filter handleBinArithmeticExpression(BinPart bin, AbstractPart op * * @param left The left {@link AbstractPart} * @param right The right {@link AbstractPart} - * @throws DslParseException if either the left or right operand is null + * @throws AelParseException if either the left or right operand is null */ private static void validateOperands(AbstractPart left, AbstractPart right) { if (left == null) { - throw new DslParseException("Left operand cannot be null"); + throw new AelParseException("Left operand cannot be null"); } if (right == null) { - throw new DslParseException("Right operand cannot be null"); + throw new AelParseException("Right operand cannot be null"); } } @@ -903,7 +903,7 @@ private static void validateOperands(AbstractPart left, AbstractPart right) { * @return A secondary index {@link Filter} * @throws NoApplicableFilterException if the operation is not supported by secondary index filters, * division by zero occurs, or the calculated range is invalid - * @throws DslParseException if undefined division (0/0) occurs or other issues arise + * @throws AelParseException if undefined division (0/0) occurs or other issues arise */ private static Filter applyFilterOperator(String binName, IntOperand leftOperand, IntOperand rightOperand, ExprPartsOperation operationType, FilterOperationType type, @@ -1197,7 +1197,7 @@ private static void replacePlaceholdersInExprContainer(AbstractPart part, Placeh * resolves to a {@link java.util.List}. Called before placeholder resolution * so that the error message references the placeholder index. * - * @throws DslParseException if the placeholder index is missing or the placeholder value is not a List + * @throws AelParseException if the placeholder index is missing or the placeholder value is not a List */ private static void validateInPlaceholderValue(PlaceholderOperand placeholder, PlaceholderValues placeholderValues) { @@ -1206,10 +1206,10 @@ private static void validateInPlaceholderValue(PlaceholderOperand placeholder, try { value = placeholderValues.getValue(index); } catch (IllegalArgumentException e) { - throw new DslParseException(e.getMessage(), e); + throw new AelParseException(e.getMessage(), e); } if (!(value instanceof List)) { - throw new DslParseException( + throw new AelParseException( "IN operation requires a List as the right operand for placeholder ?" + index); } } @@ -1222,7 +1222,7 @@ private static void validateInPlaceholderValue(PlaceholderOperand placeholder, * * @param right the right operand of the IN expression * @return the inferred element type, or {@code null} when validation is not applicable - * @throws DslParseException if the list contains elements of different types + * @throws AelParseException if the list contains elements of different types */ static Exp.Type validateListHomogeneity(AbstractPart right) { if (right.getPartType() != LIST_OPERAND) { @@ -1259,7 +1259,7 @@ static void inferBinTypeFromList(AbstractPart left, Exp.Type inferredType) { *

    * Assumes/enforces that all non-null elements in the list are of the same * logical type. If heterogeneous element types are detected, a - * {@link DslParseException} is thrown to avoid silent type mismatches. + * {@link AelParseException} is thrown to avoid silent type mismatches. * * @return the inferred type, or {@code null} if the list is empty or contains only nulls * (no type can be inferred, so homogeneity validation is intentionally skipped) @@ -1276,13 +1276,13 @@ static Exp.Type inferTypeFromListElements(ListOperand listOperand) { } Exp.Type currentType = inferElementType(value); if (currentType == null) { - throw new DslParseException( + throw new AelParseException( "Unsupported element type in IN list: " + value.getClass().getName()); } if (inferredType == null) { inferredType = currentType; } else if (inferredType != currentType) { - throw new DslParseException( + throw new AelParseException( "IN list elements must all be of the same type; found " + inferredType + " and " + currentType); } @@ -1481,7 +1481,7 @@ private static Exp andStructureToExp(ExpressionContainer expr) { * * @param expr The expression to process * @return The processed Exp - * @throws DslParseException if left or right operands are null in a binary expression + * @throws AelParseException if left or right operands are null in a binary expression */ private static Exp processExpression(ExpressionContainer expr) { AbstractPart left = getExistingPart(expr.getLeft(), "Unable to parse left operand"); @@ -1547,7 +1547,7 @@ private static void rejectBlobArithmetic(AbstractPart left, AbstractPart right, if (ARITHMETIC_OPERATIONS.contains(opType) && (resolveExpType(left) == Exp.Type.BLOB || resolveExpType(right) == Exp.Type.BLOB)) { - throw new DslParseException( + throw new AelParseException( "BLOB type does not support arithmetic operations"); } } @@ -1669,18 +1669,18 @@ private static boolean isArithmeticExpressionContainer(AbstractPart part) { * Ensures that an {@link AbstractPart} object is not null. *

    * This is a utility method used to validate that the given {@link AbstractPart} exists. If the provided - * {@code part} is {@code null}, it indicates a parsing error, and a {@link DslParseException} + * {@code part} is {@code null}, it indicates a parsing error, and a {@link AelParseException} * is thrown with a custom error message. Otherwise, the method simply returns the non-null part. *

    * * @param part The part of the expression to be validated * @param errMsg The error message to be included in the exception if the part is null * @return The provided {@link AbstractPart}, if it is not null - * @throws DslParseException if the provided {@code part} is {@code null} + * @throws AelParseException if the provided {@code part} is {@code null} */ private static AbstractPart getExistingPart(AbstractPart part, String errMsg) { if (part == null) { - throw new DslParseException(errMsg); + throw new AelParseException(errMsg); } return part; } diff --git a/src/test/java/com/aerospike/dsl/ctx/CtxTests.java b/src/test/java/com/aerospike/ael/ctx/CtxTests.java similarity index 83% rename from src/test/java/com/aerospike/dsl/ctx/CtxTests.java rename to src/test/java/com/aerospike/ael/ctx/CtxTests.java index 5d8bf70d..227360f3 100644 --- a/src/test/java/com/aerospike/dsl/ctx/CtxTests.java +++ b/src/test/java/com/aerospike/ael/ctx/CtxTests.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.ctx; +package com.aerospike.ael.ctx; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseCtx; -import static com.aerospike.dsl.util.TestUtils.parseCtxAndCompareAsBase64; +import static com.aerospike.ael.util.TestUtils.parseCtx; +import static com.aerospike.ael.util.TestUtils.parseCtxAndCompareAsBase64; import static org.assertj.core.api.Assertions.assertThatThrownBy; class CtxTests { @@ -14,26 +14,26 @@ class CtxTests { @Test void listExpression_onlyBin_noCtx() { assertThatThrownBy(() -> parseCtx("$.listBin1")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("CDT context is not provided"); } @Test void listExpression_emptyOrMalformedInput() { assertThatThrownBy(() -> parseCtx(null)) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Path must not be null or empty"); assertThatThrownBy(() -> parseCtx("")) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Path must not be null or empty"); assertThatThrownBy(() -> parseCtx("$..listBin1")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input"); assertThatThrownBy(() -> parseCtx("$listBin1")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input"); } @Test @@ -49,35 +49,35 @@ void listExpression_oneLevel() { @Test void listExpression_oneLevel_withPathFunction() { assertThatThrownBy(() -> parseCtx("$.listBin1.[0].get(type: INT)")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasCauseInstanceOf(UnsupportedOperationException.class) .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.listBin1.[=100].get(type: INT, return: VALUE)")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.listBin1.[#-1].asInt()")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); } @Test - void listExpression_oneLevel_withFullDslExpression() { + void listExpression_oneLevel_withFullAelExpression() { assertThatThrownBy(() -> parseCtx("$.listBin1.[0] == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.listBin1.[=100].get(type: INT, return: VALUE) == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.listBin1.[#-1].asInt() == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); } @@ -105,8 +105,8 @@ void listExpression_threeLevels() { @Test void mapExpression_onlyBin_noCtx() { assertThatThrownBy(() -> parseCtx("$.mapBin1")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("CDT context is not provided"); } @@ -125,43 +125,43 @@ void mapExpression_oneLevel() { @Test void mapExpression_oneLevel_withPathFunction() { assertThatThrownBy(() -> parseCtx("$.mapBin1.a.get(type: INT)")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{0}.get(type: INT)")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{=100}.get(type: INT, return: VALUE)")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{#-1}.asInt()")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Path function is unsupported, please provide only path to convert to CTX[]"); } @Test - void mapExpression_oneLevel_withFullDslExpression() { + void mapExpression_oneLevel_withFullAelExpression() { assertThatThrownBy(() -> parseCtx("$.mapBin1.a == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{0}.get(type: INT, return: VALUE) == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{=100}.asInt() == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); assertThatThrownBy(() -> parseCtx("$.mapBin1.{#-1}.asInt() == 100")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasStackTraceContaining("Unsupported input expression type 'EXPRESSION_CONTAINER', " + "please provide only path to convert to CTX[]"); } diff --git a/src/test/java/com/aerospike/dsl/expression/ArithmeticExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ArithmeticExpressionsTests.java similarity index 94% rename from src/test/java/com/aerospike/dsl/expression/ArithmeticExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/ArithmeticExpressionsTests.java index ef8053a4..132476e5 100644 --- a/src/test/java/com/aerospike/dsl/expression/ArithmeticExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ArithmeticExpressionsTests.java @@ -1,16 +1,16 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class ArithmeticExpressionsTests { @@ -490,7 +490,7 @@ void bitwiseInFunctionArg() { @Test void negativeUnknownFunction() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("unknown($.a) == 5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Unknown function"); } @@ -498,7 +498,7 @@ void negativeUnknownFunction() { void negativeWrongArgCountUnary() { // abs expects 1 arg, given 2 assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("abs($.a, $.b) == 5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("expects 1 argument(s)"); } @@ -506,7 +506,7 @@ void negativeWrongArgCountUnary() { void negativeWrongArgCountBinary() { // log expects 2 args, given 1 assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("log(2.0) == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("expects 2 argument(s)"); } @@ -514,24 +514,24 @@ void negativeWrongArgCountBinary() { void negativeMinTooFewArgs() { // min with 1 arg should fail (needs >= 2) assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("min(5) == 5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("at least 2 arguments"); } @Test void negativeArithmetic() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.apples.get(type: STRING) + 5) > 10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare STRING to INT"); // Cannot use arithmetic operations on Strings assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.apples + \"stringVal\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare INT to STRING"); // Result of an arithmetic operation is not a String assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.apples * $.bananas) != \"stringVal\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare INT to STRING"); } @@ -541,32 +541,32 @@ void negativeFloatOpComparedToString() { // (Message order varies: binary ops detect the mismatch at the bin-type check level, // unary ops detect it at the comparison-level validation.) assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.a ** 2.0) == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("STRING") .hasMessageContaining("FLOAT"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("log($.a, 2.0) == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("STRING") .hasMessageContaining("FLOAT"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("ceil($.price) == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare FLOAT to STRING"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("floor($.price) == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare FLOAT to STRING"); } @Test void negativeArithmeticInvalidLeftAndRightOperands() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("(0xGG + $.apples) > 10"))) - .isInstanceOf(DslParseException.class); + .isInstanceOf(AelParseException.class); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.apples + 0b2) > 10"))) - .isInstanceOf(DslParseException.class); + .isInstanceOf(AelParseException.class); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("(--9223372036854775808 + $.apples) > 10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.apples + ++9223372036854775808) > 10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } } diff --git a/src/test/java/com/aerospike/dsl/expression/BareGetFunctionTests.java b/src/test/java/com/aerospike/ael/expression/BareGetFunctionTests.java similarity index 68% rename from src/test/java/com/aerospike/dsl/expression/BareGetFunctionTests.java rename to src/test/java/com/aerospike/ael/expression/BareGetFunctionTests.java index 365818ae..b30a01a1 100644 --- a/src/test/java/com/aerospike/dsl/expression/BareGetFunctionTests.java +++ b/src/test/java/com/aerospike/ael/expression/BareGetFunctionTests.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.Expression; -import com.aerospike.dsl.impl.DSLParserImpl; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.impl.AelParserImpl; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseCtx; -import static com.aerospike.dsl.util.TestUtils.parseDslAndCompare; +import static com.aerospike.ael.util.TestUtils.parseCtx; +import static com.aerospike.ael.util.TestUtils.parseAelAndCompare; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -19,85 +19,85 @@ */ class BareGetFunctionTests { - private static final DSLParserImpl parser = new DSLParserImpl(); + private static final AelParserImpl parser = new AelParserImpl(); // --- Plain bin paths --- @Test void binComparison() { - parseDslAndCompare("$.intBin1.get() != 100", "$.intBin1 != 100"); + parseAelAndCompare("$.intBin1.get() != 100", "$.intBin1 != 100"); } @Test void binComparisonBothSides() { - parseDslAndCompare("$.intBin1.get() > $.intBin2.get()", "$.intBin1 > $.intBin2"); + parseAelAndCompare("$.intBin1.get() > $.intBin2.get()", "$.intBin1 > $.intBin2"); } // --- List CDT paths --- @Test void listByIndex() { - parseDslAndCompare("$.listBin1.[0].get() == 100", "$.listBin1.[0] == 100"); + parseAelAndCompare("$.listBin1.[0].get() == 100", "$.listBin1.[0] == 100"); } @Test void listByValue() { - parseDslAndCompare("$.listBin1.[=100].get() == 100", "$.listBin1.[=100] == 100"); + parseAelAndCompare("$.listBin1.[=100].get() == 100", "$.listBin1.[=100] == 100"); } @Test void listByRank() { - parseDslAndCompare("$.listBin1.[#-1].get() == 100", "$.listBin1.[#-1] == 100"); + parseAelAndCompare("$.listBin1.[#-1].get() == 100", "$.listBin1.[#-1] == 100"); } // --- Map CDT paths --- @Test void mapByKey() { - parseDslAndCompare("$.mapBin1.a.get() == 100", "$.mapBin1.a == 100"); + parseAelAndCompare("$.mapBin1.a.get() == 100", "$.mapBin1.a == 100"); } @Test void mapByIndex() { - parseDslAndCompare("$.mapBin1.{0}.get() == 100", "$.mapBin1.{0} == 100"); + parseAelAndCompare("$.mapBin1.{0}.get() == 100", "$.mapBin1.{0} == 100"); } @Test void mapByValue() { - parseDslAndCompare("$.mapBin1.{=100}.get() == 100", "$.mapBin1.{=100} == 100"); + parseAelAndCompare("$.mapBin1.{=100}.get() == 100", "$.mapBin1.{=100} == 100"); } @Test void mapByRank() { - parseDslAndCompare("$.mapBin1.{#-1}.get() == 100", "$.mapBin1.{#-1} == 100"); + parseAelAndCompare("$.mapBin1.{#-1}.get() == 100", "$.mapBin1.{#-1} == 100"); } // --- Nested and mixed CDT paths --- @Test void nestedListIndexes() { - parseDslAndCompare( + parseAelAndCompare( "$.listBin1.[0].[0].[0].get() == 100", "$.listBin1.[0].[0].[0] == 100"); } @Test void nestedMapKeys() { - parseDslAndCompare( + parseAelAndCompare( "$.mapBin1.a.bb.bcc.get() == 100", "$.mapBin1.a.bb.bcc == 100"); } @Test void mapToList() { - parseDslAndCompare( + parseAelAndCompare( "$.mapBin1.a.cc.[2].get() > 100", "$.mapBin1.a.cc.[2] > 100"); } @Test void listToMap() { - parseDslAndCompare( + parseAelAndCompare( "$.listBin1.[2].cc.get() > 100", "$.listBin1.[2].cc > 100"); } @@ -106,21 +106,21 @@ void listToMap() { @Test void arithmetic() { - parseDslAndCompare( + parseAelAndCompare( "($.intBin1.get() + $.intBin2) > 10", "($.intBin1 + $.intBin2) > 10"); } @Test void logical() { - parseDslAndCompare( + parseAelAndCompare( "$.intBin1.get() > 5 and $.intBin2.get() < 10", "$.intBin1 > 5 and $.intBin2 < 10"); } @Test void inExpression() { - parseDslAndCompare( + parseAelAndCompare( "$.intBin1.get() in [1, 2, 3]", "$.intBin1 in [1, 2, 3]"); } @@ -140,8 +140,8 @@ void placeholder() { @Test void negParseCtxRejectsBareGet() { assertThatThrownBy(() -> parseCtx("$.listBin1.[0].get()")) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse the given DSL path input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") .hasCauseInstanceOf(UnsupportedOperationException.class) .hasStackTraceContaining("Path function is unsupported"); } diff --git a/src/test/java/com/aerospike/dsl/expression/BinExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/BinExpressionsTests.java similarity index 91% rename from src/test/java/com/aerospike/dsl/expression/BinExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/BinExpressionsTests.java index fd5e8f26..0f141df8 100644 --- a/src/test/java/com/aerospike/dsl/expression/BinExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/BinExpressionsTests.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; import static org.assertj.core.api.Assertions.assertThatThrownBy; class BinExpressionsTests { @@ -65,8 +65,8 @@ void binNotEquals() { @Test void negativeStringBinEquals() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.strBin == yes"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input ''") .hasMessageContaining("at character 15"); } diff --git a/src/test/java/com/aerospike/dsl/expression/BlobTests.java b/src/test/java/com/aerospike/ael/expression/BlobTests.java similarity index 91% rename from src/test/java/com/aerospike/dsl/expression/BlobTests.java rename to src/test/java/com/aerospike/ael/expression/BlobTests.java index 43598213..7f7ef3d4 100644 --- a/src/test/java/com/aerospike/dsl/expression/BlobTests.java +++ b/src/test/java/com/aerospike/ael/expression/BlobTests.java @@ -1,20 +1,20 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.Expression; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.fluent.AerospikeComparator; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.fluent.AerospikeComparator; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.List; import java.util.SortedMap; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -108,7 +108,7 @@ void hexAndB64Equivalence() { void negativeOddHexLength() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'f' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("even number of hex characters"); } @@ -116,7 +116,7 @@ void negativeOddHexLength() { void negativeOddThreeHexChars() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'abc' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("even number of hex characters"); } @@ -124,39 +124,39 @@ void negativeOddThreeHexChars() { void negativeNonHexChars() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ZZZZ' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input"); } @Test void negativeHexWhitespace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff 00' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input"); } @Test void negativeInvalidB64Chars() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("b64'!!!!' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input"); } @Test void negativeB64Whitespace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("b64'AQ ID' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input"); + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input"); } @Test void negativeInvalidB64Content() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("b64'A' == $.b.get(type: BLOB)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Base64 BLOB literal contains invalid Base64 content"); } @@ -256,7 +256,7 @@ void cdtPathStringReversed() { void negativeBlobVsString() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.blobBin.get(type: BLOB) == $.strBin.get(type: STRING)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare BLOB to STRING"); } @@ -273,7 +273,7 @@ void stringAsBase64NotHex() { void negativeInvalidBase64StringVsBlob() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.b.get(type: BLOB) == \"not-base64!!!\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("not valid Base64"); } @@ -288,7 +288,7 @@ void getTypeBlobTwoBins() { void negativeBlobVsInt() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.b.get(type: BLOB) == 42"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare BLOB to INT"); } @@ -352,7 +352,7 @@ void blobLiteralInBlobList() { void negativeHeterogeneousInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'aa' IN [X'aa', 1]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -474,7 +474,7 @@ void b64CdtValueSelector() { void negativeBlobIntArithmetic() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' + 42 == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -482,7 +482,7 @@ void negativeBlobIntArithmetic() { void negativeSameTypeBlobArith() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' + X'ee' == X'dd'"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -490,7 +490,7 @@ void negativeSameTypeBlobArith() { void negativeBlobMultiplicative() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' * 2 == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -498,7 +498,7 @@ void negativeBlobMultiplicative() { void negativeBlobModulo() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' % 2 == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -506,7 +506,7 @@ void negativeBlobModulo() { void negativeBlobPower() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' ** 2 == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -514,7 +514,7 @@ void negativeBlobPower() { void negativeUnaryMinusBlob() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("-X'ff' == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("BLOB type does not support arithmetic operations"); } @@ -522,7 +522,7 @@ void negativeUnaryMinusBlob() { void negativeMixedTypeBitwise() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("X'ff' & 42 == 1"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare BLOB to INT"); } diff --git a/src/test/java/com/aerospike/dsl/expression/CastingTests.java b/src/test/java/com/aerospike/ael/expression/CastingTests.java similarity index 92% rename from src/test/java/com/aerospike/dsl/expression/CastingTests.java rename to src/test/java/com/aerospike/ael/expression/CastingTests.java index 19fe9fbc..1c275200 100644 --- a/src/test/java/com/aerospike/dsl/expression/CastingTests.java +++ b/src/test/java/com/aerospike/ael/expression/CastingTests.java @@ -1,18 +1,18 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.util.TestUtils; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.Value; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.util.TestUtils; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.Value; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class CastingTests { @@ -20,7 +20,7 @@ public class CastingTests { @Test void negativeInvalidTypesComparison() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.stringBin1.get(type: STRING) > $.intBin2.asFloat()"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare STRING to FLOAT"); } @@ -81,14 +81,14 @@ void longMinIntLiteralToFloat() { @Test void castToFloatComparedToStringThrows() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("28.asFloat() == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @Test void castToIntComparedToStringThrows() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("28.0.asInt() == \"hello\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } diff --git a/src/test/java/com/aerospike/dsl/expression/ControlStructuresTests.java b/src/test/java/com/aerospike/ael/expression/ControlStructuresTests.java similarity index 96% rename from src/test/java/com/aerospike/dsl/expression/ControlStructuresTests.java rename to src/test/java/com/aerospike/ael/expression/ControlStructuresTests.java index bf0ca665..84c13fb7 100644 --- a/src/test/java/com/aerospike/dsl/expression/ControlStructuresTests.java +++ b/src/test/java/com/aerospike/ael/expression/ControlStructuresTests.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; public class ControlStructuresTests { diff --git a/src/test/java/com/aerospike/dsl/expression/ExplicitTypesTests.java b/src/test/java/com/aerospike/ael/expression/ExplicitTypesTests.java similarity index 94% rename from src/test/java/com/aerospike/dsl/expression/ExplicitTypesTests.java rename to src/test/java/com/aerospike/ael/expression/ExplicitTypesTests.java index 6b2da133..48123e7a 100644 --- a/src/test/java/com/aerospike/dsl/expression/ExplicitTypesTests.java +++ b/src/test/java/com/aerospike/ael/expression/ExplicitTypesTests.java @@ -1,16 +1,16 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.Base64; import java.util.List; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; // Explicit types tests, list and map explicit types are tested in their own test classes @@ -47,8 +47,8 @@ void stringComparisonNegativeTest() { assertThatThrownBy(() -> TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.stringBin1.get(type: STRING) == yes"), Exp.eq(Exp.stringBin("stringBin1"), Exp.val("yes")))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input ''") .hasMessageContaining("at character 37"); } @@ -88,7 +88,7 @@ void booleanComparison() { @Test void negativeBooleanComparison() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.boolBin1.get(type: BOOL) == 5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare BOOL to INT"); } @@ -131,8 +131,8 @@ void listComparison_constantOnRightSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.get(type: LIST) == [yes, of course]"), Exp.eq(Exp.listBin("listBin1"), Exp.val(List.of("yes", "of course")))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input ','") .hasMessageContaining("at character 34"); } @@ -176,8 +176,8 @@ void listComparison_constantOnLeftSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("[yes, of course] == $.listBin1.get(type: LIST)"), Exp.eq(Exp.val(List.of("yes", "of course")), Exp.listBin("listBin1"))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 4"); } @@ -248,8 +248,8 @@ void mapComparison_constantOnRightSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.get(type: MAP) == {yes, of course}"), Exp.eq(Exp.mapBin("mapBin1"), Exp.val(treeMapOf("yes", "of course")))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input 'yes'") .hasMessageContaining("at character 29"); @@ -257,7 +257,7 @@ void mapComparison_constantOnRightSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.get(type: MAP) == ['yes', 'of course']"), Exp.eq(Exp.mapBin("mapBin1"), Exp.val(List.of("yes", "of course")))) ) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessage("Cannot compare MAP to LIST"); // Map key can only be Integer or String @@ -265,8 +265,8 @@ void mapComparison_constantOnRightSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.get(type: MAP) == {[100]:[100]}"), Exp.eq(Exp.mapBin("mapBin1"), Exp.val(List.of("yes", "of course")))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input '['") .hasMessageContaining("at character 29"); } @@ -321,8 +321,8 @@ void mapComparison_constantOnLeftSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("{yes, of course} == $.mapBin1.get(type: MAP)"), Exp.eq(Exp.mapBin("mapBin1"), Exp.val(treeMapOf("of course", "yes")))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 1"); @@ -330,7 +330,7 @@ void mapComparison_constantOnLeftSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("['yes', 'of course'] == $.mapBin1.get(type: MAP)"), // incorrect: must be {} Exp.eq(Exp.val(List.of("yes", "of course")), Exp.mapBin("mapBin1"))) ) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessage("Cannot compare MAP to LIST"); // Map key can only be Integer or String @@ -338,8 +338,8 @@ void mapComparison_constantOnLeftSide_NegativeTest() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("{[100]:[100]} == $.mapBin1.get(type: MAP)"), Exp.eq(Exp.val(List.of("yes", "of course")), Exp.mapBin("mapBin1"))) ) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 1"); } @@ -371,7 +371,7 @@ void twoBlobBinsComparison() { @Test void negativeTwoDifferentBinTypesComparison() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.stringBin1.get(type: STRING) == $.floatBin2.get(type: FLOAT)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare STRING to FLOAT"); } diff --git a/src/test/java/com/aerospike/dsl/expression/ImplicitTypesTests.java b/src/test/java/com/aerospike/ael/expression/ImplicitTypesTests.java similarity index 97% rename from src/test/java/com/aerospike/dsl/expression/ImplicitTypesTests.java rename to src/test/java/com/aerospike/ael/expression/ImplicitTypesTests.java index 66679770..4b3e984d 100644 --- a/src/test/java/com/aerospike/dsl/expression/ImplicitTypesTests.java +++ b/src/test/java/com/aerospike/ael/expression/ImplicitTypesTests.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; public class ImplicitTypesTests { diff --git a/src/test/java/com/aerospike/dsl/expression/InBinTests.java b/src/test/java/com/aerospike/ael/expression/InBinTests.java similarity index 85% rename from src/test/java/com/aerospike/dsl/expression/InBinTests.java rename to src/test/java/com/aerospike/ael/expression/InBinTests.java index 4d143287..705338cb 100644 --- a/src/test/java/com/aerospike/dsl/expression/InBinTests.java +++ b/src/test/java/com/aerospike/ael/expression/InBinTests.java @@ -1,18 +1,18 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; import org.junit.jupiter.api.Test; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; class InBinTests { diff --git a/src/test/java/com/aerospike/dsl/expression/InCompositeTests.java b/src/test/java/com/aerospike/ael/expression/InCompositeTests.java similarity index 97% rename from src/test/java/com/aerospike/dsl/expression/InCompositeTests.java rename to src/test/java/com/aerospike/ael/expression/InCompositeTests.java index 37f0c74e..ab405d92 100644 --- a/src/test/java/com/aerospike/dsl/expression/InCompositeTests.java +++ b/src/test/java/com/aerospike/ael/expression/InCompositeTests.java @@ -1,15 +1,15 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; class InCompositeTests { diff --git a/src/test/java/com/aerospike/dsl/expression/InExplicitTypeTests.java b/src/test/java/com/aerospike/ael/expression/InExplicitTypeTests.java similarity index 93% rename from src/test/java/com/aerospike/dsl/expression/InExplicitTypeTests.java rename to src/test/java/com/aerospike/ael/expression/InExplicitTypeTests.java index 081d3157..f30410ee 100644 --- a/src/test/java/com/aerospike/dsl/expression/InExplicitTypeTests.java +++ b/src/test/java/com/aerospike/ael/expression/InExplicitTypeTests.java @@ -1,19 +1,19 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; import static org.assertj.core.api.Assertions.assertThatThrownBy; class InExplicitTypeTests { @@ -371,7 +371,7 @@ void countListBin() { void negExplicitIntTypeOnRightBin() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in $.tags.get(type: INT)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -379,7 +379,7 @@ void negExplicitIntTypeOnRightBin() { void negExplicitStringTypeOnRightBin() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in $.tags.get(type: STRING)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -387,7 +387,7 @@ void negExplicitStringTypeOnRightBin() { void negNestedPathExplicitStringOnRight() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in $.tags.nested.get(type: STRING)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -395,7 +395,7 @@ void negNestedPathExplicitStringOnRight() { void negExplicitStringInIntList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in [1, 2]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -403,7 +403,7 @@ void negExplicitStringInIntList() { void negExplicitIntInStringList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.age.get(type: INT) in [\"a\", \"b\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -411,7 +411,7 @@ void negExplicitIntInStringList() { void negExplicitBoolInIntList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.flag.get(type: BOOL) in [1, 2]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -419,7 +419,7 @@ void negExplicitBoolInIntList() { void negExplicitIntInBoolList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.val.get(type: INT) in [true, false]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -427,7 +427,7 @@ void negExplicitIntInBoolList() { void negExplicitFloatInStringList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.val.get(type: FLOAT) in [\"a\", \"b\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -435,7 +435,7 @@ void negExplicitFloatInStringList() { void negExplicitFloatInBoolList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.val.get(type: FLOAT) in [true, false]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -443,7 +443,7 @@ void negExplicitFloatInBoolList() { void negExplicitStringInFloatList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in [1.5, 2.5]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -451,7 +451,7 @@ void negExplicitStringInFloatList() { void negExplicitStringInBoolList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in [true, false]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -459,7 +459,7 @@ void negExplicitStringInBoolList() { void negExplicitBoolInStringList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.flag.get(type: BOOL) in [\"a\", \"b\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } @@ -467,7 +467,7 @@ void negExplicitBoolInStringList() { void negExplicitBoolInFloatList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.flag.get(type: BOOL) in [1.5, 2.5]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Cannot compare"); } } diff --git a/src/test/java/com/aerospike/dsl/expression/InGrammarConflictTests.java b/src/test/java/com/aerospike/ael/expression/InGrammarConflictTests.java similarity index 93% rename from src/test/java/com/aerospike/dsl/expression/InGrammarConflictTests.java rename to src/test/java/com/aerospike/ael/expression/InGrammarConflictTests.java index 2fd48c56..e86faf97 100644 --- a/src/test/java/com/aerospike/dsl/expression/InGrammarConflictTests.java +++ b/src/test/java/com/aerospike/ael/expression/InGrammarConflictTests.java @@ -1,18 +1,18 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; +package com.aerospike.ael.expression; + +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; class InGrammarConflictTests { diff --git a/src/test/java/com/aerospike/dsl/expression/InLiteralTests.java b/src/test/java/com/aerospike/ael/expression/InLiteralTests.java similarity index 93% rename from src/test/java/com/aerospike/dsl/expression/InLiteralTests.java rename to src/test/java/com/aerospike/ael/expression/InLiteralTests.java index 6a5c9a32..1d379394 100644 --- a/src/test/java/com/aerospike/dsl/expression/InLiteralTests.java +++ b/src/test/java/com/aerospike/ael/expression/InLiteralTests.java @@ -1,19 +1,19 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; +package com.aerospike.ael.expression; + +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; import org.junit.jupiter.api.Test; import java.util.List; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; class InLiteralTests { diff --git a/src/test/java/com/aerospike/dsl/expression/InNegativeTests.java b/src/test/java/com/aerospike/ael/expression/InNegativeTests.java similarity index 84% rename from src/test/java/com/aerospike/dsl/expression/InNegativeTests.java rename to src/test/java/com/aerospike/ael/expression/InNegativeTests.java index 4166492c..63a8f4d5 100644 --- a/src/test/java/com/aerospike/dsl/expression/InNegativeTests.java +++ b/src/test/java/com/aerospike/ael/expression/InNegativeTests.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; class InNegativeTests { @@ -16,28 +16,28 @@ class InNegativeTests { @Test void negativeRightOperandString() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.name in \"Bob\""))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @Test void negativeRightOperandInt() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.name in 42"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @Test void negativeRightOperandFloat() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.name in 1.5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @Test void negativeRightOperandBool() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.name in true"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -45,14 +45,14 @@ void negativeRightOperandBool() { void negativeRightOperandMap() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in {\"a\": 1}"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @Test void negativeRightOperandMetadata() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.name in $.ttl()"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -60,7 +60,7 @@ void negativeRightOperandMetadata() { void negMixedIntAndStringInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [1, \"hello\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -68,7 +68,7 @@ void negMixedIntAndStringInList() { void negMixedBoolAndIntInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [true, 42]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -76,7 +76,7 @@ void negMixedBoolAndIntInList() { void negMixedFloatAndStringInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [1.5, \"hello\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -84,7 +84,7 @@ void negMixedFloatAndStringInList() { void negMixedIntAndFloatInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [1, 1.5]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -92,7 +92,7 @@ void negMixedIntAndFloatInList() { void negPlaceholderResolvesToStr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of("Bob")))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -100,7 +100,7 @@ void negPlaceholderResolvesToStr() { void negPlaceholderResolvesToInt() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of(42)))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -108,7 +108,7 @@ void negPlaceholderResolvesToInt() { void negPlaceholderResolvesToFloat() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of(1.5)))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -116,7 +116,7 @@ void negPlaceholderResolvesToFloat() { void negPlaceholderResolvesToBool() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of(true)))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -125,7 +125,7 @@ void negPlaceholderResolvesToMap() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of(Map.of("a", 1))))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -133,7 +133,7 @@ void negPlaceholderResolvesToMap() { void negLiteralInMixedTypeList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("\"x\" in [1, \"y\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -143,7 +143,7 @@ void negPlaceholderInMixedTypeList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("?0 in [1, \"y\"]", PlaceholderValues.of(42)))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -151,7 +151,7 @@ void negPlaceholderInMixedTypeList() { void negPathInMixedTypeList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.rooms.room1.name in [1, \"y\"]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -160,7 +160,7 @@ void negMixedTypeListViaPlaceholder() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in ?0", PlaceholderValues.of(List.of(1, "hello"))))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -168,7 +168,7 @@ void negMixedTypeListViaPlaceholder() { void negVariableInMixedTypeList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = 1) then (${x} in [1, \"y\"])"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } @@ -178,7 +178,7 @@ void negVariableInMixedTypeList() { void negBinInBinAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.itemType in $.allowedItems"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -186,7 +186,7 @@ void negBinInBinAmbiguous() { void negBinInPathAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in $.rooms.room1.name"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -194,7 +194,7 @@ void negBinInPathAmbiguous() { void negBinInListDesignatorAmb() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in $.binName.[]"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -202,7 +202,7 @@ void negBinInListDesignatorAmb() { void negBinInPlaceholderAmb() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -210,7 +210,7 @@ void negBinInPlaceholderAmb() { void negVarBoundToInt() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = 1) then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -219,7 +219,7 @@ void negVarBoundToInt() { void negVarBoundToFloat() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = 1.5) then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -228,7 +228,7 @@ void negVarBoundToFloat() { void negVarBoundToBool() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = true) then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -237,7 +237,7 @@ void negVarBoundToBool() { void negVarBoundToString() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = \"hello\") then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -246,7 +246,7 @@ void negVarBoundToString() { void negVarBoundToMap() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = {\"a\": 1}) then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -255,7 +255,7 @@ void negVarBoundToMap() { void negVarBoundToMetadata() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = $.ttl()) then (\"100\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -266,7 +266,7 @@ void negVarBoundToMetadata() { void negVarBoundToArithmeticExpr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = 1 + 2) then (\"foo\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -275,7 +275,7 @@ void negVarBoundToArithmeticExpr() { void negVarBoundToFunctionExpr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = abs(1)) then (\"foo\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -287,7 +287,7 @@ void negVarBoundToExplicitIntBin() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = $.someBin.get(type: INT)) then (\"foo\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -297,7 +297,7 @@ void negVarBoundToExplicitStrPath() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = $.a.b.get(type: STRING)) then (\"foo\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -309,7 +309,7 @@ void negNestedLetOuterNonListVar() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 1) then (let(y = [1, 2]) then (\"foo\" in ${x}))"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -319,7 +319,7 @@ void negNestedShadowedVarLetScalar() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = [1]) then (let(x = 1) then (\"foo\" in ${x}))"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -329,7 +329,7 @@ void negNotWrappingInLetScalarVar() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 1) then (not(\"foo\" in ${x}))"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -339,7 +339,7 @@ void negVarBoundToCountPath() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = $.a.[].count()) then (\"foo\" in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -349,7 +349,7 @@ void negVarDefLetInScalarVar() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("variable 'x'"); } @@ -358,7 +358,7 @@ void negVarDefLetInScalarVar() { void negBinInVariableAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = [\"a\"]) then ($.name in ${x})"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -366,7 +366,7 @@ void negBinInVariableAmbiguous() { void negPathInBinAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.rooms.room1.name in $.list"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -374,7 +374,7 @@ void negPathInBinAmbiguous() { void negPathInPathAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.rooms.room1.a in $.rooms.room2.b"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -382,7 +382,7 @@ void negPathInPathAmbiguous() { void negPathInPlaceholderAmbiguous() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.rooms.room1.name in ?0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -391,7 +391,7 @@ void negExplicitBinInNotList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in ?0", PlaceholderValues.of("Bob")))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("placeholder ?0"); } @@ -401,7 +401,7 @@ void negPlaceholderInNotList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("?0 in ?1", PlaceholderValues.of("gold", "notAList")))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand") .hasMessageContaining("placeholder ?1"); } @@ -412,7 +412,7 @@ void negPlaceholderInNotList() { void negPlaceholderMissingValue() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in ?0", PlaceholderValues.of()))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Missing value for placeholder ?0"); } @@ -420,7 +420,7 @@ void negPlaceholderMissingValue() { void negPlaceholderIndexOutOfBounds() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name.get(type: STRING) in ?1", PlaceholderValues.of(42)))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Missing value for placeholder ?1"); } @@ -431,7 +431,7 @@ void negAmbiguousLeftInWhenCond() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("when($.name in $.allowedNames => \"ok\"," + " default => \"no\")"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("cannot infer the type of the left operand for IN operation"); } @@ -440,7 +440,7 @@ void negNonListRightInWhenCond() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("when($.name.get(type: STRING) in \"Bob\" => \"ok\"," + " default => \"no\")"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN operation requires a List as the right operand"); } @@ -449,7 +449,7 @@ void negMixedTypeListInWhenCond() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("when($.name in [1, \"hello\"] => \"ok\"," + " default => \"no\")"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("IN list elements must all be of the same type"); } } diff --git a/src/test/java/com/aerospike/dsl/expression/InPlaceholderTests.java b/src/test/java/com/aerospike/ael/expression/InPlaceholderTests.java similarity index 94% rename from src/test/java/com/aerospike/dsl/expression/InPlaceholderTests.java rename to src/test/java/com/aerospike/ael/expression/InPlaceholderTests.java index 024f6c65..3846f037 100644 --- a/src/test/java/com/aerospike/dsl/expression/InPlaceholderTests.java +++ b/src/test/java/com/aerospike/ael/expression/InPlaceholderTests.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.List; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; class InPlaceholderTests { diff --git a/src/test/java/com/aerospike/dsl/expression/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java similarity index 95% rename from src/test/java/com/aerospike/dsl/expression/ListExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java index a10498ca..b9c27ba1 100644 --- a/src/test/java/com/aerospike/dsl/expression/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; class ListExpressionsTests { @@ -83,16 +83,16 @@ void listByValue() { @Test void listByValueHexAndBinarySelectorsAreUnsupported() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=0xff] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=0b10] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=-0xff] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=-0b10] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); } @@ -139,16 +139,16 @@ void listByRank() { @Test void listByRankHexAndBinarySelectorsAreUnsupported() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[#0xff] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[#0b10] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[#-0xff] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[#-0b10] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); } @@ -168,7 +168,7 @@ void listByRankIntegerMinDecimal() { @Test void listByRankOutOfRangeSignedLiteral() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[#-2147483649] == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @@ -302,8 +302,8 @@ void listBinElementCount() { @Test void negativeSyntaxList() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[stringValue] == 100"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 12"); } diff --git a/src/test/java/com/aerospike/dsl/expression/LogicalExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/LogicalExpressionsTests.java similarity index 86% rename from src/test/java/com/aerospike/dsl/expression/LogicalExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/LogicalExpressionsTests.java index 08b6af43..53ee007d 100644 --- a/src/test/java/com/aerospike/dsl/expression/LogicalExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/LogicalExpressionsTests.java @@ -1,13 +1,13 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import org.opentest4j.AssertionFailedError; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class LogicalExpressionsTests { @@ -93,26 +93,26 @@ void flatHierarchyAnd() { @Test void negativeSyntaxLogicalOperators() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.intBin1 > 100 and ($.intBin2 > 100) or"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 41"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("and ($.intBin1 > 100 and ($.intBin2 > 100)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input 'and'") .hasMessageContaining("at character 0"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.intBin1 > 100 and ($.intBin2 > 100) not"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 39"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("($.intBin1 > 100 and ($.intBin2 > 100) exclusive"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 39"); } @@ -122,8 +122,8 @@ void negativeBinLogicalExclusiveWithOneParam() { assertThatThrownBy(() -> TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("exclusive($.hand == \"hook\")"), Exp.exclusive( Exp.eq(Exp.stringBin("hand"), Exp.val("hook"))))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 26"); } diff --git a/src/test/java/com/aerospike/dsl/expression/MapAndListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapAndListExpressionsTests.java similarity index 92% rename from src/test/java/com/aerospike/dsl/expression/MapAndListExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/MapAndListExpressionsTests.java index c508afa7..d085c0e2 100644 --- a/src/test/java/com/aerospike/dsl/expression/MapAndListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapAndListExpressionsTests.java @@ -1,14 +1,14 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; public class MapAndListExpressionsTests { diff --git a/src/test/java/com/aerospike/dsl/expression/MapExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java similarity index 96% rename from src/test/java/com/aerospike/dsl/expression/MapExpressionsTests.java rename to src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java index 64790886..9f14544d 100644 --- a/src/test/java/com/aerospike/dsl/expression/MapExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java @@ -1,20 +1,20 @@ -package com.aerospike.dsl.expression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class MapExpressionsTests { @@ -250,16 +250,16 @@ void mapByValue() { @Test void mapByValueHexAndBinarySelectorsAreUnsupported() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=0xff} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=0b10} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=-0xff} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=-0b10} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); } @@ -306,16 +306,16 @@ void mapByRank() { @Test void mapByRankHexAndBinarySelectorsAreUnsupported() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{#0xff} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{#0b10} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{#-0xff} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{#-0b10} == 100"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Only decimal integer literals are supported in this element"); } diff --git a/src/test/java/com/aerospike/dsl/expression/NumericLiteralsTests.java b/src/test/java/com/aerospike/ael/expression/NumericLiteralsTests.java similarity index 88% rename from src/test/java/com/aerospike/dsl/expression/NumericLiteralsTests.java rename to src/test/java/com/aerospike/ael/expression/NumericLiteralsTests.java index 781734bd..9417621a 100644 --- a/src/test/java/com/aerospike/dsl/expression/NumericLiteralsTests.java +++ b/src/test/java/com/aerospike/ael/expression/NumericLiteralsTests.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; /** @@ -247,8 +247,8 @@ void doubleUnaryPlusIntOnRightOperand() { void invalidHexDigits() { // 0xGG is not valid hex -- lexer produces INT(0) + NAME_IDENTIFIER(xGG) assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0xGG == 0"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 5"); } @@ -257,8 +257,8 @@ void invalidHexDigits() { void invalidBinaryDigits() { // 0b2 is not valid binary -- lexer produces INT(0) + NAME_IDENTIFIER(b2) assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0b2 == 0"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 4"); } @@ -267,8 +267,8 @@ void invalidBinaryDigits() { void trailingDotFloat() { // "10." is not valid FLOAT -- requires digits after dot assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("10. == 10.0"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 4"); } @@ -276,175 +276,175 @@ void trailingDotFloat() { @Test void leadingDotHexIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of(".0x10 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == .0x10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithMinusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("-.0x10 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithMinusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == -.0x10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithPlusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("+.0x10 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithPlusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == +.0x10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithDoubleMinusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("--.0x10 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithDoubleMinusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == --.0x10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithDoublePlusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("++.0x10 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotHexWithDoublePlusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == ++.0x10"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of(".0b11 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == .0b11"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithMinusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("-.0b11 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithMinusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == -.0b11"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithPlusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("+.0b11 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithPlusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == +.0b11"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithDoubleMinusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("--.0b11 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithDoubleMinusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == --.0b11"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithDoublePlusSignIsRejected() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("++.0b11 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void leadingDotBinaryWithDoublePlusSignIsRejectedOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == ++.0b11"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void decimalIntOverflowPositive() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("9223372036854775808 == 0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @Test void decimalIntOverflowNegative() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("-9223372036854775809 == 0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @Test void decimalIntOverflowDoubleUnaryMinusLongMin() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("--9223372036854775808 == 0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @Test void decimalIntOverflowDoubleUnaryMinusLongMinCast() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("--9223372036854775808.asFloat() == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @Test void hexIntOverflowPositive() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0x8000000000000001 == 0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("out of range"); } @@ -486,14 +486,14 @@ void leadingDotFloatInExpression() { void doubleDotFloat() { // "..37" has an extraneous leading dot before a valid leading-dot float assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("..37 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void doubleDotFloatOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == ..37"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @@ -501,14 +501,14 @@ void doubleDotFloatOnRight() { void embeddedDotFloat() { // ".3.7" has digits both before and after an extra dot assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of(".3.7 == 0.0"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } @Test void embeddedDotFloatOnRight() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("0.0 == .3.7"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Invalid float literal"); } } diff --git a/src/test/java/com/aerospike/dsl/expression/RecordMetadataTests.java b/src/test/java/com/aerospike/ael/expression/RecordMetadataTests.java similarity index 95% rename from src/test/java/com/aerospike/dsl/expression/RecordMetadataTests.java rename to src/test/java/com/aerospike/ael/expression/RecordMetadataTests.java index 62af9afa..620eee0f 100644 --- a/src/test/java/com/aerospike/dsl/expression/RecordMetadataTests.java +++ b/src/test/java/com/aerospike/ael/expression/RecordMetadataTests.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; import static org.assertj.core.api.Assertions.assertThatThrownBy; class RecordMetadataTests { @@ -129,7 +129,7 @@ void ttl() { void negativeTtlAsDifferentType() { // TODO: should be supported when adding operator + metadata validations (requires a refactor) assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.ttl() == true"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Expecting non-bin operand, got BOOL_OPERAND"); } diff --git a/src/test/java/com/aerospike/dsl/expression/SyntaxErrorTests.java b/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java similarity index 75% rename from src/test/java/com/aerospike/dsl/expression/SyntaxErrorTests.java rename to src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java index f78217e5..c20f010a 100644 --- a/src/test/java/com/aerospike/dsl/expression/SyntaxErrorTests.java +++ b/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java @@ -1,12 +1,12 @@ -package com.aerospike.dsl.expression; +package com.aerospike.ael.expression; -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.client.exp.Exp; +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.exp.Exp; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilterExp; -import static com.aerospike.dsl.util.TestUtils.parseFilterExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; import static org.assertj.core.api.Assertions.assertThatThrownBy; class SyntaxErrorTests { @@ -16,8 +16,8 @@ class SyntaxErrorTests { @Test void negNonsensePathFunction() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("1.0 == $.f1.nonsense()"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input '()'") .hasMessageContaining("at character 20"); } @@ -25,8 +25,8 @@ void negNonsensePathFunction() { @Test void negNonsensePathFunctionOnLeft() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.f1.nonsense() == 1.0"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input '()'") .hasMessageContaining("at character 13"); } @@ -34,8 +34,8 @@ void negNonsensePathFunctionOnLeft() { @Test void negTrailingGarbageTokens() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.intBin1 > 100 garbage"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input 'garbage'") .hasMessageContaining("at character 16"); } @@ -59,8 +59,8 @@ void negVarBareNameInThenBody() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x})) then (y == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 55"); } @@ -70,8 +70,8 @@ void negVarDollarNoInThenBody() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x})) then ($y == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Lexer] token recognition error at: '$y'") .hasMessageContaining("at character 53") .hasMessageContaining("[Parser] no viable alternative at input") @@ -83,8 +83,8 @@ void negVarMissingCloseBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x)) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Lexer] token recognition error at: '${x)'") .hasMessageContaining("at character 40") .hasMessageContaining("[Parser] no viable alternative at input") @@ -96,8 +96,8 @@ void negVarMissingDollarAndOpen() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in x})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 41"); } @@ -107,8 +107,8 @@ void negVarBareNameInLetExpr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in x)) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 41"); } @@ -118,8 +118,8 @@ void negVarDoubleOpenBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${{x})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Lexer] token recognition error at: '${{'") .hasMessageContaining("at character 40") .hasMessageContaining("[Parser] no viable alternative at input") @@ -131,8 +131,8 @@ void negVarDoubleCloseBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x}})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 44"); } @@ -142,8 +142,8 @@ void negVarDoubleDollarSign() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in $${x})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Lexer] token recognition error at: '$$'") .hasMessageContaining("at character 40") .hasMessageContaining("[Parser] no viable alternative at input") @@ -155,8 +155,8 @@ void negVarDoubleDollarSign() { @Test void negOrphanedParentheses() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.intBin1 > ()"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input '()'") .hasMessageContaining("at character 12"); } @@ -166,8 +166,8 @@ void negGetFuncMissingCloseParen() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT in ${x})) then (${y} == true)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 36"); } @@ -178,8 +178,8 @@ void negGetFuncMissingCloseParen() { void negLetMissingThen() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x = 5) (${x} + 1)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 11"); } @@ -188,8 +188,8 @@ void negLetMissingThen() { void negLetEmptyDefs() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let() then (1 + 2)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 3"); } @@ -198,8 +198,8 @@ void negLetEmptyDefs() { void negLetMissingEquals() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("let(x 5) then (${x} + 1)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 6"); } @@ -210,8 +210,8 @@ void negLetMissingEquals() { void negWhenMissingDefault() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("when($.x == 1 => \"a\")"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 20"); } @@ -220,8 +220,8 @@ void negWhenMissingDefault() { void negWhenMissingArrow() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("when($.x == 1 \"a\", default => \"b\")"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 14"); } diff --git a/src/test/java/com/aerospike/dsl/filter/ArithmeticFiltersTests.java b/src/test/java/com/aerospike/ael/filter/ArithmeticFiltersTests.java similarity index 98% rename from src/test/java/com/aerospike/dsl/filter/ArithmeticFiltersTests.java rename to src/test/java/com/aerospike/ael/filter/ArithmeticFiltersTests.java index 929328cb..a17daf74 100644 --- a/src/test/java/com/aerospike/dsl/filter/ArithmeticFiltersTests.java +++ b/src/test/java/com/aerospike/ael/filter/ArithmeticFiltersTests.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.filter; +package com.aerospike.ael.filter; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilter; -import static com.aerospike.dsl.util.TestUtils.parseFilterAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilter; +import static com.aerospike.ael.util.TestUtils.parseFilterAndCompare; import static org.assertj.core.api.Assertions.assertThat; public class ArithmeticFiltersTests { diff --git a/src/test/java/com/aerospike/dsl/filter/BinFiltersTests.java b/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java similarity index 91% rename from src/test/java/com/aerospike/dsl/filter/BinFiltersTests.java rename to src/test/java/com/aerospike/ael/filter/BinFiltersTests.java index 2f53aba0..98b3522a 100644 --- a/src/test/java/com/aerospike/dsl/filter/BinFiltersTests.java +++ b/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java @@ -1,22 +1,22 @@ -package com.aerospike.dsl.filter; +package com.aerospike.ael.filter; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilter; -import static com.aerospike.dsl.util.TestUtils.parseFilterAndCompare; +import static com.aerospike.ael.util.TestUtils.parseFilter; +import static com.aerospike.ael.util.TestUtils.parseFilterAndCompare; import static org.assertj.core.api.Assertions.assertThat; class BinFiltersTests { String NAMESPACE = "test1"; - List INDEXES = List.of( + List INDEXES = List.of( Index.builder().namespace(NAMESPACE).bin("intBin1").indexType(IndexType.NUMERIC).binValuesRatio(1).build(), Index.builder().namespace(NAMESPACE).bin("stringBin1").indexType(IndexType.STRING).binValuesRatio(1).build() ); diff --git a/src/test/java/com/aerospike/dsl/filter/ExplicitTypesFiltersTests.java b/src/test/java/com/aerospike/ael/filter/ExplicitTypesFiltersTests.java similarity index 88% rename from src/test/java/com/aerospike/dsl/filter/ExplicitTypesFiltersTests.java rename to src/test/java/com/aerospike/ael/filter/ExplicitTypesFiltersTests.java index 85b52e47..ddae049b 100644 --- a/src/test/java/com/aerospike/dsl/filter/ExplicitTypesFiltersTests.java +++ b/src/test/java/com/aerospike/ael/filter/ExplicitTypesFiltersTests.java @@ -1,19 +1,19 @@ -package com.aerospike.dsl.filter; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.filter; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.Base64; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseFilter; +import static com.aerospike.ael.util.TestUtils.parseFilter; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -58,8 +58,8 @@ void stringComparison() { void stringComparisonNegativeTest() { // A String constant must be quoted assertThatThrownBy(() -> parseFilter(ExpressionContext.of("$.stringBin1.get(type: STRING) == yes"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input ''") .hasMessageContaining("at character 37"); } @@ -93,7 +93,7 @@ void booleanComparison() { @Test void negativeBooleanComparison() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("$.boolBin1.get(type: BOOL) == 5"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessage("Cannot compare BOOL to INT"); } @@ -106,8 +106,8 @@ void listComparison_constantOnRightSide() { @Test void listComparison_constantOnRightSide_NegativeTest() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("$.listBin1.get(type: LIST) == [yes, of course]"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] mismatched input ','") .hasMessageContaining("at character 34"); } @@ -120,8 +120,8 @@ void listComparison_constantOnLeftSide() { @Test void listComparison_constantOnLeftSide_NegativeTest() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("[yes, of course] == $.listBin1.get(type: LIST)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 4"); } @@ -134,8 +134,8 @@ void mapComparison_constantOnRightSide() { @Test void mapComparison_constantOnRightSide_NegativeTest() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("$.mapBin1.get(type: MAP) == {yes, of course}"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] extraneous input 'yes'") .hasMessageContaining("at character 29"); } @@ -148,8 +148,8 @@ void mapComparison_constantOnLeftSide() { @Test void mapComparison_constantOnLeftSide_NegativeTest() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("{yes, of course} == $.mapBin1.get(type: MAP)"))) - .isInstanceOf(DslParseException.class) - .hasMessageContaining("Could not parse given DSL expression input") + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse given AEL expression input") .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 1"); } @@ -178,7 +178,7 @@ void twoBlobBinsComparison() { @Test void negativeTwoDifferentBinTypesComparison() { assertThatThrownBy(() -> parseFilter(ExpressionContext.of("$.stringBin1.get(type: STRING) == $.floatBin2.get(type: FLOAT)"))) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessage("Cannot compare STRING to FLOAT"); } @@ -218,7 +218,7 @@ void b64FilterReversed() { @Test void blobInequalityNoFilter() { - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.blobBin1.get(type: BLOB) != X'ff00'"), null, Exp.ne(Exp.blobBin("blobBin1"), Exp.val(new byte[]{(byte) 0xff, 0x00})), @@ -227,7 +227,7 @@ void blobInequalityNoFilter() { @Test void blobOrderingNoFilter() { - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.blobBin1.get(type: BLOB) > X'ff00'"), null, Exp.gt(Exp.blobBin("blobBin1"), Exp.val(new byte[]{(byte) 0xff, 0x00})), diff --git a/src/test/java/com/aerospike/dsl/filter/ImplicitTypesFiltersTests.java b/src/test/java/com/aerospike/ael/filter/ImplicitTypesFiltersTests.java similarity index 80% rename from src/test/java/com/aerospike/dsl/filter/ImplicitTypesFiltersTests.java rename to src/test/java/com/aerospike/ael/filter/ImplicitTypesFiltersTests.java index 42d7d1ab..67f1116a 100644 --- a/src/test/java/com/aerospike/dsl/filter/ImplicitTypesFiltersTests.java +++ b/src/test/java/com/aerospike/ael/filter/ImplicitTypesFiltersTests.java @@ -1,9 +1,9 @@ -package com.aerospike.dsl.filter; +package com.aerospike.ael.filter; -import com.aerospike.dsl.ExpressionContext; +import com.aerospike.ael.ExpressionContext; import org.junit.jupiter.api.Test; -import static com.aerospike.dsl.util.TestUtils.parseFilter; +import static com.aerospike.ael.util.TestUtils.parseFilter; import static org.assertj.core.api.Assertions.assertThat; public class ImplicitTypesFiltersTests { diff --git a/src/test/java/com/aerospike/dsl/filter/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/filter/ListExpressionsTests.java similarity index 88% rename from src/test/java/com/aerospike/dsl/filter/ListExpressionsTests.java rename to src/test/java/com/aerospike/ael/filter/ListExpressionsTests.java index e8338132..59fb7fa8 100644 --- a/src/test/java/com/aerospike/dsl/filter/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/filter/ListExpressionsTests.java @@ -1,18 +1,18 @@ -package com.aerospike.dsl.filter; +package com.aerospike.ael.filter; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; -import com.aerospike.dsl.util.TestUtils; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.client.query.IndexCollectionType.LIST; +import static com.aerospike.ael.client.query.IndexCollectionType.LIST; class ListExpressionsTests { diff --git a/src/test/java/com/aerospike/dsl/index/IndexContextTests.java b/src/test/java/com/aerospike/ael/index/IndexContextTests.java similarity index 98% rename from src/test/java/com/aerospike/dsl/index/IndexContextTests.java rename to src/test/java/com/aerospike/ael/index/IndexContextTests.java index 948ed0d9..bba905ee 100644 --- a/src/test/java/com/aerospike/dsl/index/IndexContextTests.java +++ b/src/test/java/com/aerospike/ael/index/IndexContextTests.java @@ -1,8 +1,8 @@ -package com.aerospike.dsl.index; +package com.aerospike.ael.index; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.query.IndexType; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.query.IndexType; import org.junit.jupiter.api.Test; import java.util.Collection; diff --git a/src/test/java/com/aerospike/dsl/index/IndexTests.java b/src/test/java/com/aerospike/ael/index/IndexTests.java similarity index 97% rename from src/test/java/com/aerospike/dsl/index/IndexTests.java rename to src/test/java/com/aerospike/ael/index/IndexTests.java index 7f37359a..58d0af7c 100644 --- a/src/test/java/com/aerospike/dsl/index/IndexTests.java +++ b/src/test/java/com/aerospike/ael/index/IndexTests.java @@ -1,7 +1,7 @@ -package com.aerospike.dsl.index; +package com.aerospike.ael.index; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.client.query.IndexType; +import com.aerospike.ael.Index; +import com.aerospike.ael.client.query.IndexType; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/aerospike/dsl/parsedExpression/InExprTests.java b/src/test/java/com/aerospike/ael/parsedExpression/InExprTests.java similarity index 94% rename from src/test/java/com/aerospike/dsl/parsedExpression/InExprTests.java rename to src/test/java/com/aerospike/ael/parsedExpression/InExprTests.java index 889f778a..332fff2e 100644 --- a/src/test/java/com/aerospike/dsl/parsedExpression/InExprTests.java +++ b/src/test/java/com/aerospike/ael/parsedExpression/InExprTests.java @@ -1,19 +1,19 @@ -package com.aerospike.dsl.parsedExpression; - -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; +package com.aerospike.ael.parsedExpression; + +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.NAMESPACE; -import static com.aerospike.dsl.util.TestUtils.parseDslExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.NAMESPACE; +import static com.aerospike.ael.util.TestUtils.parseAelExpressionAndCompare; class InExprTests { @@ -30,7 +30,7 @@ void inAndEq_allIndexed() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -46,7 +46,7 @@ void eqAndIn_allIndexed() { Filter filter = Filter.equal("intBin1", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 == 100 and $.intBin2 in [1, 2, 3]"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -66,7 +66,7 @@ void eqAndInAndLt_allIndexed() { Exp.eq(Exp.intBin("intBin1"), Exp.val(100)), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(1, 2, 3)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 == 100 and $.intBin2 in [1, 2, 3] and $.intBin3 < 50"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -82,7 +82,7 @@ void inAndGt_allIndexed() { Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(10, 20))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [10, 20] and $.intBin2 > 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -98,7 +98,7 @@ void gtAndIn_allIndexed() { Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(10, 20))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 > 100 and $.intBin2 in [10, 20]"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -119,7 +119,7 @@ void twoIns_allIndexed() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4]"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -132,7 +132,7 @@ void twoIns_noIndexes() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4]"), filter, exp); } @@ -153,7 +153,7 @@ void twoInsAndEq_allIndexed() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4] and $.intBin3 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -174,7 +174,7 @@ void eqAndTwoIns_allIndexed() { Exp.intBin("intBin2"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin3"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 == 100 and $.intBin2 in [1, 2] and $.intBin3 in [3, 4]"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -198,7 +198,7 @@ void twoInsAndLtAndGt_allIndexed() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("b3"), Exp.val(List.of(2))), Exp.gt(Exp.intBin("b4"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.b1 in [1] and $.b2 < 50 and $.b3 in [2] and $.b4 > 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -216,7 +216,7 @@ void inBinHighestCard_fallback() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -232,7 +232,7 @@ void inBinHighestCard_fallbackGt() { Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 > 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -252,7 +252,7 @@ void inBinHighestCard_3exprs() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.lt(Exp.intBin("intBin3"), Exp.val(50))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 < 50"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -268,7 +268,7 @@ void inBinOnlyIndexed() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -291,7 +291,7 @@ void twoInBinsHighestCard() { Exp.intBin("b1"), Exp.val(List.of(1))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("b2"), Exp.val(List.of(2)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.b1 in [1] and $.b2 in [2] and $.b3 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -310,7 +310,7 @@ void twoInBinsHighestCard_noOther() { Exp.intBin("b1"), Exp.val(List.of(1))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("b2"), Exp.val(List.of(2)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.b1 in [1] and $.b2 in [2]"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -334,7 +334,7 @@ void twoInBinsHighCard_withGtLt() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("b3"), Exp.val(List.of(2))), Exp.lt(Exp.intBin("b4"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.b1 in [1] and $.b2 > 50 and $.b3 in [2] and $.b4 < 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -354,7 +354,7 @@ void twoInsOnlyIndexed() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("b2"), Exp.val(List.of(2))), Exp.eq(Exp.intBin("b3"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.b1 in [1] and $.b2 in [2] and $.b3 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -372,7 +372,7 @@ void inAndEq_indexHint_selectsEq() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin2")); } @@ -388,7 +388,7 @@ void inAndEq_indexHint_onInBin() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -408,7 +408,7 @@ void inAndEqAndGt_indexHint_overrides() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin3")); } @@ -429,7 +429,7 @@ void twoInsAndEq_indexHint() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4] and $.intBin3 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin3")); } @@ -448,7 +448,7 @@ void twoIns_indexHint_noFilter() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4]"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -464,7 +464,7 @@ void inAndEq_indexHint_unavailable() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "nonExistent")); } @@ -480,7 +480,7 @@ void inAndEq_indexHint_nsMismatch() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -496,7 +496,7 @@ void inAndEq_indexHint_null() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, null)); } @@ -512,7 +512,7 @@ void inAndEq_indexHint_empty() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "")); } @@ -532,7 +532,7 @@ void inAndEq_indexHint_overridesAlpha() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin3")); } @@ -554,7 +554,7 @@ void inAndEqAndGt_indexHint_onInBin() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.gt(Exp.intBin("intBin3"), Exp.val(50))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -575,7 +575,7 @@ void twoInsAndLt_indexHint_onInBin() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4] and $.intBin3 < 50"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -595,7 +595,7 @@ void inOrEq_indexHint_noFilter() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] or $.intBin2 == 100"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin2")); } @@ -615,7 +615,7 @@ void orInAndGt_indexHint_onOrInBin() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("($.intBin1 in [1, 2] or $.intBin2 == 100) and $.intBin3 > 50"), filter, exp, IndexContext.of(NAMESPACE, indexes, "idx_intBin1")); } @@ -633,7 +633,7 @@ void inAndEq_binHint_selectsEq() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin2")); } @@ -649,7 +649,7 @@ void inAndEq_binHint_onInBin() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } @@ -669,7 +669,7 @@ void inAndEqAndGt_binHint_overrides() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin3")); } @@ -690,7 +690,7 @@ void twoInsAndEq_binHint() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4] and $.intBin3 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin3")); } @@ -709,7 +709,7 @@ void twoIns_binHint_noFilter() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4]"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } @@ -725,7 +725,7 @@ void inAndEq_binHint_noMatch() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "nonExistent")); } @@ -741,7 +741,7 @@ void inAndEq_binHint_null() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, null)); } @@ -757,7 +757,7 @@ void inAndEq_binHint_nsMismatch() { Filter filter = Filter.equal("intBin2", 100); Exp exp = ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2, 3))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2, 3] and $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } @@ -777,7 +777,7 @@ void inAndEq_binHint_overridesAlpha() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin3")); } @@ -799,7 +799,7 @@ void inAndEqAndGt_binHint_onInBin() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.gt(Exp.intBin("intBin3"), Exp.val(50))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 == 100 and $.intBin3 > 50"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } @@ -820,7 +820,7 @@ void twoInsAndLt_binHint_onInBin() { Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin2"), Exp.val(List.of(3, 4)))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] and $.intBin2 in [3, 4] and $.intBin3 < 50"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } @@ -840,7 +840,7 @@ void inOrEq_binHint_noFilter() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 in [1, 2] or $.intBin2 == 100"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin2")); } @@ -860,7 +860,7 @@ void orInAndGt_binHint_onOrInBin() { ListExp.getByValue(ListReturnType.EXISTS, Exp.intBin("intBin1"), Exp.val(List.of(1, 2))), Exp.eq(Exp.intBin("intBin2"), Exp.val(100))); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("($.intBin1 in [1, 2] or $.intBin2 == 100) and $.intBin3 > 50"), filter, exp, IndexContext.withBinHint(NAMESPACE, indexes, "intBin1")); } diff --git a/src/test/java/com/aerospike/dsl/parsedExpression/LogicalParsedExpressionTests.java b/src/test/java/com/aerospike/ael/parsedExpression/LogicalParsedExpressionTests.java similarity index 91% rename from src/test/java/com/aerospike/dsl/parsedExpression/LogicalParsedExpressionTests.java rename to src/test/java/com/aerospike/ael/parsedExpression/LogicalParsedExpressionTests.java index 3fdc6fb3..d2a2412a 100644 --- a/src/test/java/com/aerospike/dsl/parsedExpression/LogicalParsedExpressionTests.java +++ b/src/test/java/com/aerospike/ael/parsedExpression/LogicalParsedExpressionTests.java @@ -1,17 +1,17 @@ -package com.aerospike.dsl.parsedExpression; - -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.parsedExpression; + +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.List; -import static com.aerospike.dsl.util.TestUtils.parseDslExpressionAndCompare; +import static com.aerospike.ael.util.TestUtils.parseAelExpressionAndCompare; public class LogicalParsedExpressionTests { @@ -20,7 +20,7 @@ void binLogical_AND_no_indexes() { Filter filter = null; Exp exp = Exp.and(Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100))); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp); + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp); } @Test @@ -33,7 +33,7 @@ void binLogical_AND_all_indexes() { ); Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -47,7 +47,7 @@ void binLogical_AND_all_indexes_no_cardinality() { Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); // Complementary Exp is provided for the remaining part of the expression Exp exp = Exp.gt(Exp.intBin("intBin2"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -57,7 +57,7 @@ void binLogical_AND_one_index() { Index.builder().namespace(TestUtils.NAMESPACE).bin("intBin1").indexType(IndexType.NUMERIC).binValuesRatio(0).build()); Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin2"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -69,7 +69,7 @@ void binLogical_AND_AND_no_indexes() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp); } @@ -84,7 +84,7 @@ void binLogical_AND_OR_OR_no_indexes() { Exp.gt(Exp.intBin("intBin3"), Exp.val(100)), Exp.gt(Exp.intBin("intBin4"), Exp.val(100)) ); - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 or $.intBin3 > 100 or $.intBin4 > 100"), filter, exp); } @@ -99,7 +99,7 @@ void binLogical_OR_AND_AND_no_indexes() { Exp.gt(Exp.intBin("intBin4"), Exp.val(100)) ) ); - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 and $.intBin3 > 100 and $.intBin4 > 100"), filter, exp); } @@ -115,7 +115,7 @@ void binLogical_AND_AND_all_indexes() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -132,7 +132,7 @@ void binLogical_AND_AND_all_indexes_same_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -149,7 +149,7 @@ void binLogical_AND_AND_all_indexes_no_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -167,7 +167,7 @@ void binLogical_AND_AND_all_indexes_partial_data() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -186,7 +186,7 @@ void binLogical_AND_AND_explicitly_given_index() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, // Manually selecting the index by its name IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin1")); } @@ -204,7 +204,7 @@ void binLogical_AND_AND_explicitly_given_index_unavailable() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, // There is no index with the name "intBin10" IndexContext.of(TestUtils.NAMESPACE, indexes, "intBin10")); } @@ -218,7 +218,7 @@ void binLogical_AND_AND_explicitly_given_index_namespace_mismatch() { // idx_bin1 name matches but belongs to a different namespace, so falls back to automatic selection Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin1")); } @@ -235,7 +235,7 @@ void binLogical_AND_AND_explicitly_given_index_null() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, null)); } @@ -252,7 +252,7 @@ void binLogical_AND_AND_explicitly_given_index_empty_string() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "")); } @@ -269,7 +269,7 @@ void binLogical_AND_AND_explicitly_given_index_overrides_alphabetical() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin2")); } @@ -291,7 +291,7 @@ void binLogical_AND_AND_with_OR_subexpression_explicitly_given_index() { Exp.gt(Exp.intBin("intBin4"), Exp.val(100)) ) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and ($.intBin3 > 100 or $.intBin4 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin1")); @@ -303,7 +303,7 @@ void binLogical_single_bin_explicitly_given_index() { Index.builder().namespace(TestUtils.NAMESPACE).name("idx_bin1").bin("intBin1").indexType(IndexType.NUMERIC).binValuesRatio(0).build() ); Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100"), filter, null, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100"), filter, null, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin1")); } @@ -318,7 +318,7 @@ void binLogical_AND_AND_two_indexes() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -327,7 +327,7 @@ void binLogical_OR_no_indexes() { Filter filter = null; Exp exp = Exp.or(Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100))); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp); + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp); } @Test @@ -341,7 +341,7 @@ void binLogical_OR_all_indexes() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -355,7 +355,7 @@ void binLogical_OR_one_index() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -372,7 +372,7 @@ void binLogical_OR_OR_all_indexes() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -389,7 +389,7 @@ void binLogical_OR_OR_all_indexes_same_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -407,7 +407,7 @@ void binLogical_OR_OR_provided_index_no_filter_created() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_bin1")); } @@ -426,9 +426,9 @@ void binLogical_prioritizedAND_OR_indexed() { ), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 or $.intBin3 > 100"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 or $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin1 > 100 and $.intBin2 > 100) or $.intBin3 > 100"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin1 > 100 and $.intBin2 > 100) or $.intBin3 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -444,9 +444,9 @@ void binLogical_AND_prioritizedOR_indexed() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -463,9 +463,9 @@ void binLogical_AND_prioritizedOR_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -482,9 +482,9 @@ void binLogical_AND_prioritizedOR_indexed_no_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -503,9 +503,9 @@ void binLogical_OR_prioritizedOR_indexed() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100)"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100))"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -524,9 +524,9 @@ void binLogical_OR_prioritizedOR_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100)"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100))"), filter, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -545,9 +545,9 @@ void binLogical_OR_prioritizedAND_indexed() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -566,9 +566,9 @@ void binLogical_OR_prioritizedAND_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -591,10 +591,10 @@ void binLogical_prioritizedAND_OR_prioritizedAND_indexed() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and $.intBin4 > 100) or" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and $.intBin4 > 100) or" + " ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 and $.intBin4 > 100) or" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 and $.intBin4 > 100) or" + " ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -618,9 +618,9 @@ void binLogical_prioritizedAND_OR_prioritizedAND_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and $.intBin4 > 100) or" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 and $.intBin4 > 100) or" + " ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 and $.intBin4 > 100) or" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 and $.intBin4 > 100) or" + " ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -643,9 +643,9 @@ void binLogical_prioritizedOR_AND_prioritizedOR_indexed() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -668,9 +668,9 @@ void binLogical_prioritizedOR_AND_prioritizedOR_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 or $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 or $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -690,9 +690,9 @@ void binLogical_prioritizedOR_AND_prioritizedAND_indexed() { ), Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -712,9 +712,9 @@ void binLogical_prioritizedOR_AND_prioritizedAND_indexed_same_cardinality() { ), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 and $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and" + " ($.intBin2 > 100 and $.intBin1 > 100))"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -734,9 +734,9 @@ void binLogical_prioritizedOR_prioritizedAND_AND_indexed_withFilter() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -758,9 +758,9 @@ void binLogical_prioritizedOR_prioritizedAND_AND_indexed_withTheOnlyFilter() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -780,9 +780,9 @@ void binLogical_prioritizedOR_prioritizedAND_AND_indexed_same_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ) ); - parseDslExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100 and $.intBin2 > 100) and" + " $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -804,9 +804,9 @@ void binLogical_prioritizedOR_prioritizedAND_AND_indexed_withFilterPerCardinalit ), Exp.gt(Exp.intBin("intBin1"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("(($.intBin3 > 100 or $.intBin4 > 100) and $.intBin2 > 100) and" + " $.intBin1 > 100"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("((($.intBin3 > 100 or $.intBin4 > 100) and $.intBin2 > 100) and" + + parseAelExpressionAndCompare(ExpressionContext.of("((($.intBin3 > 100 or $.intBin4 > 100) and $.intBin2 > 100) and" + " $.intBin1 > 100)"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -834,10 +834,10 @@ void binLogical_OR2_OR1_AND2_AND_AND1_indexed_no_cardinality() { ), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - String dslString = "(($.intBin3 > 100 or $.intBin4 > 100) or ($.intBin5 > 100 and $.intBin6 > 100)) " + + String aelString = "(($.intBin3 > 100 or $.intBin4 > 100) or ($.intBin5 > 100 and $.intBin6 > 100)) " + "and ($.intBin2 > 100 and $.intBin1 > 100)"; - parseDslExpressionAndCompare(ExpressionContext.of(dslString), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(" + dslString + ")"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of(aelString), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); + parseAelExpressionAndCompare(ExpressionContext.of("(" + aelString + ")"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -877,10 +877,10 @@ void binLogical_OR2_OR1_AND2_AND_AND2_OR1_AND2_indexed_no_cardinality() { ) ) ); - String dslString = "(($.intBin3 > 100 or $.intBin4 > 100) or ($.intBin5 > 100 and $.intBin6 > 100)) " + + String aelString = "(($.intBin3 > 100 or $.intBin4 > 100) or ($.intBin5 > 100 and $.intBin6 > 100)) " + "and (($.intBin2 > 100 and $.intBin1 > 100) or ($.intBin7 > 100 and $.intBin8 > 100))"; - parseDslExpressionAndCompare(ExpressionContext.of(dslString), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); - parseDslExpressionAndCompare(ExpressionContext.of("(" + dslString + ")"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of(aelString), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); + parseAelExpressionAndCompare(ExpressionContext.of("(" + aelString + ")"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes)); } @@ -897,7 +897,7 @@ void binLogical_AND_AND_bin_hint_selects_index_overrides_cardinality() { Exp.gt(Exp.intBin("intBin2"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin1")); } @@ -914,7 +914,7 @@ void binLogical_AND_AND_bin_hint_no_match_falls_back_to_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin99")); } @@ -927,7 +927,7 @@ void binLogical_AND_AND_bin_hint_namespace_mismatch_falls_back_to_automatic() { // intBin1 bin matches but belongs to a different namespace, so falls back to automatic selection Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin1")); } @@ -944,7 +944,7 @@ void binLogical_AND_AND_bin_hint_null_falls_back_to_automatic() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, null)); } @@ -958,7 +958,7 @@ void binLogical_AND_AND_bin_hint_multiple_indexes_same_bin_falls_back_to_automat // Two indexes on intBin1 → ambiguous → fallback to full automatic; intBin1 NUMERIC wins by cardinality Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin2"), Exp.val(100)); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin1")); } @@ -975,7 +975,7 @@ void binLogical_AND_AND_bin_hint_overrides_alphabetical_same_cardinality() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin3"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 and $.intBin2 > 100 and $.intBin3 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin2")); } @@ -991,7 +991,7 @@ void binLogical_OR_bin_hint_produces_no_filter() { Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100)) ); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100 or $.intBin2 > 100"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin1")); } @@ -1001,7 +1001,7 @@ void binLogical_single_bin_bin_hint_exact_match() { Index.builder().namespace(TestUtils.NAMESPACE).bin("intBin1").indexType(IndexType.NUMERIC).binValuesRatio(0).build() ); Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); - parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100"), filter, null, + parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > 100"), filter, null, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "intBin1")); } @@ -1012,7 +1012,7 @@ void binLogical_EXCL_no_indexes() { Exp.eq(Exp.stringBin("hand"), Exp.val("stand")), Exp.eq(Exp.stringBin("pun"), Exp.val("done")) ); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("exclusive($.hand == \"stand\", $.pun == \"done\")"), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("exclusive($.hand == \"stand\", $.pun == \"done\")"), filter, exp); } @@ -1028,7 +1028,7 @@ void withBinHint_mixedTypes_numericQuerySelectsNumeric() { ); Filter filter = Filter.equal("value", 19); Exp exp = Exp.eq(Exp.stringBin("name"), Exp.val("Tim")); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.name == 'Tim'"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "value")); @@ -1043,7 +1043,7 @@ void withBinHint_mixedTypes_stringQuerySelectsString() { .indexType(IndexType.NUMERIC).binValuesRatio(3).build() ); Filter filter = Filter.equal("status", "active"); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.status == 'active'"), filter, null, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "status")); @@ -1059,7 +1059,7 @@ void withBinHint_singleIndexTypeMismatch_noFilter() { Exp.eq(Exp.intBin("value"), Exp.val(19)), Exp.eq(Exp.stringBin("name"), Exp.val("Tim")) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.name == 'Tim'"), null, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "value")); @@ -1077,7 +1077,7 @@ void withBinHint_allIndexesTypeMismatch_noFilter() { Exp.eq(Exp.intBin("value"), Exp.val(19)), Exp.eq(Exp.stringBin("name"), Exp.val("Tim")) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.name == 'Tim'"), null, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "value")); @@ -1093,7 +1093,7 @@ void withBinHint_hintedBinNotInQuery_fallsBack() { ); Filter filter = Filter.equal("age", 30); Exp exp = Exp.eq(Exp.stringBin("name"), Exp.val("Tim")); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.age == 30 and $.name == 'Tim'"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "city")); @@ -1109,7 +1109,7 @@ void withBinHint_typeMismatch_fallsBackToOther() { ); Filter filter = Filter.range("age", 26, Long.MAX_VALUE); Exp exp = Exp.eq(Exp.intBin("value"), Exp.val(19)); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.age > 25"), filter, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "value")); @@ -1127,7 +1127,7 @@ void withBinHint_allFallbackMismatch_noFilter() { Exp.eq(Exp.intBin("value"), Exp.val(19)), Exp.gt(Exp.intBin("age"), Exp.val(25)) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.age > 25"), null, exp, IndexContext.withBinHint(TestUtils.NAMESPACE, indexes, "value")); @@ -1153,7 +1153,7 @@ void withBinHint_andWithOrSubexpr_fallsBack() { Exp.gt(Exp.intBin("intBin4"), Exp.val(100)) ) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of( "$.intBin1 > 100 and $.intBin2 > 100 and ($.intBin3 > 100 or $.intBin4 > 100)"), filter, exp, @@ -1170,7 +1170,7 @@ void explicitHint_wrongBin_fallsBackToAutomatic() { ); Filter filter = Filter.equal("age", 30); Exp exp = Exp.eq(Exp.stringBin("name"), Exp.val("Tim")); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.age == 30 and $.name == 'Tim'"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_users_city")); @@ -1186,7 +1186,7 @@ void explicitHint_correctBinWrongType_noFilter() { Exp.eq(Exp.intBin("age"), Exp.val(30)), Exp.eq(Exp.stringBin("name"), Exp.val("Tim")) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.age == 30 and $.name == 'Tim'"), null, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_age_str")); @@ -1202,7 +1202,7 @@ void explicitHint_correctBin_producesFilter() { ); Filter filter = Filter.equal("city", "London"); Exp exp = Exp.gt(Exp.intBin("age"), Exp.val(30)); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.city == 'London' and $.age > 30"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_users_city")); @@ -1218,7 +1218,7 @@ void explicitHint_typeMismatch_fallsBackToOther() { ); Filter filter = Filter.range("age", 26, Long.MAX_VALUE); Exp exp = Exp.eq(Exp.intBin("value"), Exp.val(19)); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.age > 25"), filter, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_value_str")); @@ -1236,7 +1236,7 @@ void explicitHint_allIndexesMismatch_noFilter() { Exp.eq(Exp.intBin("value"), Exp.val(19)), Exp.gt(Exp.intBin("age"), Exp.val(25)) ); - parseDslExpressionAndCompare( + parseAelExpressionAndCompare( ExpressionContext.of("$.value == 19 and $.age > 25"), null, exp, IndexContext.of(TestUtils.NAMESPACE, indexes, "idx_value_str")); diff --git a/src/test/java/com/aerospike/dsl/parsedExpression/PlaceholdersTests.java b/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java similarity index 85% rename from src/test/java/com/aerospike/dsl/parsedExpression/PlaceholdersTests.java rename to src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java index bcf33680..c2c52e8a 100644 --- a/src/test/java/com/aerospike/dsl/parsedExpression/PlaceholdersTests.java +++ b/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java @@ -1,24 +1,24 @@ -package com.aerospike.dsl.parsedExpression; - -import com.aerospike.dsl.DslParseException; -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.Index; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.ParseResult; -import com.aerospike.dsl.ParsedExpression; -import com.aerospike.dsl.PlaceholderValues; -import com.aerospike.dsl.client.Value; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.cdt.ListReturnType; -import com.aerospike.dsl.client.cdt.MapReturnType; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.Expression; -import com.aerospike.dsl.client.exp.ListExp; -import com.aerospike.dsl.client.exp.MapExp; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.client.query.IndexType; -import com.aerospike.dsl.client.fluent.AerospikeComparator; -import com.aerospike.dsl.util.TestUtils; +package com.aerospike.ael.parsedExpression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.Index; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.ParseResult; +import com.aerospike.ael.ParsedExpression; +import com.aerospike.ael.PlaceholderValues; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.client.query.IndexType; +import com.aerospike.ael.client.fluent.AerospikeComparator; +import com.aerospike.ael.util.TestUtils; import org.junit.jupiter.api.Test; import java.util.Base64; @@ -27,7 +27,7 @@ import java.util.SortedMap; import java.util.TreeMap; -import static com.aerospike.dsl.util.TestUtils.NAMESPACE; +import static com.aerospike.ael.util.TestUtils.NAMESPACE; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -37,23 +37,23 @@ public class PlaceholdersTests { void intBin_GT_no_indexes() { Filter filter = null; Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100)), filter, exp); Exp expString = Exp.gt(Exp.stringBin("strBin1"), Exp.val("str")); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("str")), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("str")), filter, expString); Exp expString2 = Exp.gt(Exp.stringBin("strBin1"), Exp.val("'str'")); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("'str'")), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("'str'")), filter, expString2); Exp expString3 = Exp.gt(Exp.stringBin("strBin1"), Exp.val("\"str\"")); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("\"str\"")), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.strBin1 > ?0", PlaceholderValues.of("\"str\"")), filter, expString3); byte[] data = new byte[]{1, 2, 3}; String encodedString = Base64.getEncoder().encodeToString(data); Exp expStringBase64 = Exp.gt(Exp.blobBin("blobBin1"), Exp.val(data)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.blobBin1.get(type: BLOB) > ?0", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.blobBin1.get(type: BLOB) > ?0", PlaceholderValues.of(encodedString)), filter, expStringBase64); } @@ -71,25 +71,25 @@ void intBin_GT_no_indexes_reuseExprTree() { @Test void intBin_GT_no_indexes_size_mismatch() { assertThatThrownBy(() -> - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of()), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of()), null, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Missing value for placeholder ?0"); assertThatThrownBy(() -> - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", null), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", null), null, null)) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Operand type not supported: PLACEHOLDER_OPERAND"); assertThatThrownBy(() -> - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0"), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0"), null, null)) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("Operand type not supported: PLACEHOLDER_OPERAND"); assertThatThrownBy(() -> - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", PlaceholderValues.of(100)), null, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Missing value for placeholder ?1"); @@ -97,7 +97,7 @@ void intBin_GT_no_indexes_size_mismatch() { Filter filter = null; Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); // If there are more values than placeholders we only match the required indexes - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100, 200)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100, 200)), filter, exp); } @@ -109,7 +109,7 @@ void intBin_GT_has_index() { ); Filter filter = Filter.range("intBin1", 101, Long.MAX_VALUE); Exp exp = null; - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0", PlaceholderValues.of(100)), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -133,7 +133,7 @@ void intBin_GT_has_index_reuseExprTree() { void intBin_GT_AND_no_indexes() { Filter filter = null; Exp exp = Exp.and(Exp.gt(Exp.intBin("intBin1"), Exp.val(100)), Exp.gt(Exp.intBin("intBin2"), Exp.val(100))); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", PlaceholderValues.of(100, 100)), filter, exp); } @@ -145,7 +145,7 @@ void intBin_GT_AND_all_indexes() { ); Filter filter = Filter.range("intBin2", 101, Long.MAX_VALUE); Exp exp = Exp.gt(Exp.intBin("intBin1"), Exp.val(100)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.intBin1 > ?0 and $.intBin2 > ?1", PlaceholderValues.of(100, 100)), filter, exp, IndexContext.of(NAMESPACE, indexes)); } @@ -155,7 +155,7 @@ void metadataExpression_TTL() { Filter filter = null; Exp exp = Exp.le(Exp.ttl(), Exp.val(24 * 60 * 60)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("$.ttl() <= ?0", PlaceholderValues.of(86400)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("$.ttl() <= ?0", PlaceholderValues.of(86400)), filter, exp); } @@ -163,7 +163,7 @@ void metadataExpression_TTL() { void arithmeticExpression() { Filter filter = null; Exp exp = Exp.gt(Exp.add(Exp.intBin("apples"), Exp.val(5)), Exp.val(10)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("($.apples + ?0) > ?1", PlaceholderValues.of(5, 10)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("($.apples + ?0) > ?1", PlaceholderValues.of(5, 10)), filter, exp); Collection INDEXES = List.of( @@ -173,7 +173,7 @@ void arithmeticExpression() { IndexContext INDEX_FILTER_INPUT = IndexContext.of(NAMESPACE, INDEXES); Filter filter2 = Filter.range("apples", 10 - 5 + 1, Long.MAX_VALUE); Exp exp2 = null; - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("($.apples + ?0) > ?1", PlaceholderValues.of(5, 10)), + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("($.apples + ?0) > ?1", PlaceholderValues.of(5, 10)), filter2, exp2, INDEX_FILTER_INPUT); } @@ -314,14 +314,14 @@ void binLogical_EXCL_no_indexes() { Exp.eq(Exp.stringBin("hand"), Exp.val("stand")), Exp.eq(Exp.stringBin("pun"), Exp.val("done")) ); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("exclusive($.hand == ?0, $.pun == ?1)", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("exclusive($.hand == ?0, $.pun == ?1)", PlaceholderValues.of("stand", "done")), filter, exp); } @Test void bothPlaceholdersEquality() { Exp exp = Exp.eq(Exp.val(42), Exp.val(42)); - TestUtils.parseDslExpressionAndCompare(ExpressionContext.of("?0 == ?1", + TestUtils.parseAelExpressionAndCompare(ExpressionContext.of("?0 == ?1", PlaceholderValues.of(42, 42)), null, exp); } @@ -331,7 +331,7 @@ void bothPlaceholdersEquality() { void blobPlaceholderByteArray() { byte[] data = new byte[]{1, 2, 3}; Exp expected = Exp.eq(Exp.blobBin("b"), Exp.val(data)); - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.b.get(type: BLOB) == ?0", PlaceholderValues.of((Object) data)), null, expected); } @@ -342,7 +342,7 @@ void blobPlaceholderMapWithKey() { SortedMap map = new TreeMap<>(new AerospikeComparator()); map.put(key, 42L); Exp expected = Exp.eq(Exp.mapBin("mb"), Exp.val(map)); - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.mb.get(type: MAP) == ?0", PlaceholderValues.of(map)), null, expected); } @@ -352,7 +352,7 @@ void blobPlaceholderListWithBlob() { byte[] data = new byte[]{1, 2, 3}; List list = List.of(data, "hello"); Exp expected = Exp.eq(Exp.listBin("lb"), Exp.val(list)); - TestUtils.parseDslExpressionAndCompare( + TestUtils.parseAelExpressionAndCompare( ExpressionContext.of("$.lb.get(type: LIST) == ?0", PlaceholderValues.of(list)), null, expected); } diff --git a/src/test/java/com/aerospike/dsl/parts/operand/OperandFactoryTests.java b/src/test/java/com/aerospike/ael/parts/operand/OperandFactoryTests.java similarity index 88% rename from src/test/java/com/aerospike/dsl/parts/operand/OperandFactoryTests.java rename to src/test/java/com/aerospike/ael/parts/operand/OperandFactoryTests.java index aa09edf4..fd75dae1 100644 --- a/src/test/java/com/aerospike/dsl/parts/operand/OperandFactoryTests.java +++ b/src/test/java/com/aerospike/ael/parts/operand/OperandFactoryTests.java @@ -1,6 +1,6 @@ -package com.aerospike.dsl.parts.operand; +package com.aerospike.ael.parts.operand; -import com.aerospike.dsl.DslParseException; +import com.aerospike.ael.AelParseException; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -17,7 +17,7 @@ void negMapWithIncomparableKeys() { unsupportedKeyMap.put(new Object(), "a"); unsupportedKeyMap.put(new Object(), "b"); assertThatThrownBy(() -> OperandFactory.createOperand(unsupportedKeyMap)) - .isInstanceOf(DslParseException.class) + .isInstanceOf(AelParseException.class) .hasMessageContaining("mutually comparable"); } diff --git a/src/test/java/com/aerospike/dsl/util/TestUtils.java b/src/test/java/com/aerospike/ael/util/TestUtils.java similarity index 74% rename from src/test/java/com/aerospike/dsl/util/TestUtils.java rename to src/test/java/com/aerospike/ael/util/TestUtils.java index 73d5296f..9c1e357e 100644 --- a/src/test/java/com/aerospike/dsl/util/TestUtils.java +++ b/src/test/java/com/aerospike/ael/util/TestUtils.java @@ -1,13 +1,13 @@ -package com.aerospike.dsl.util; - -import com.aerospike.dsl.ExpressionContext; -import com.aerospike.dsl.IndexContext; -import com.aerospike.dsl.ParsedExpression; -import com.aerospike.dsl.client.cdt.CTX; -import com.aerospike.dsl.client.exp.Exp; -import com.aerospike.dsl.client.exp.Expression; -import com.aerospike.dsl.client.query.Filter; -import com.aerospike.dsl.impl.DSLParserImpl; +package com.aerospike.ael.util; + +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.IndexContext; +import com.aerospike.ael.ParsedExpression; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.query.Filter; +import com.aerospike.ael.impl.AelParserImpl; import lombok.experimental.UtilityClass; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,12 +16,12 @@ public class TestUtils { public static final String NAMESPACE = "test1"; - private static final DSLParserImpl parser = new DSLParserImpl(); + private static final AelParserImpl parser = new AelParserImpl(); /** - * Parses the given DSL expression and extracts the resulting {@link Exp} object. + * Parses the given AEL expression and extracts the resulting {@link Exp} object. * - * @param expressionContext The input representing DSL expression + * @param expressionContext The input representing AEL expression * @return The {@link Exp} object derived from the parsed filter expression */ public static Exp parseFilterExp(ExpressionContext expressionContext) { @@ -29,9 +29,9 @@ public static Exp parseFilterExp(ExpressionContext expressionContext) { } /** - * Parses the given DSL expression and returns the resulting {@link ParsedExpression} object. + * Parses the given AEL expression and returns the resulting {@link ParsedExpression} object. * - * @param expressionContext The {@link ExpressionContext} representing DSL expression + * @param expressionContext The {@link ExpressionContext} representing AEL expression * @param indexContext The {@link IndexContext} to be used for building secondary index filter * @return The {@link Exp} object derived from the parsed filter expression */ @@ -40,11 +40,11 @@ public static ParsedExpression getParsedExpression(ExpressionContext expressionC } /** - * Parses the given DSL expression, extracts the resulting {@link Exp} object, converts it to an {@link Expression} + * Parses the given AEL expression, extracts the resulting {@link Exp} object, converts it to an {@link Expression} * object, and then asserts that it is equal to the {@code expected} {@link Exp} also built into an * {@link Expression}. * - * @param expressionContext The input representing DSL expression + * @param expressionContext The input representing AEL expression * @param expected The expected {@link Exp} object to compare against the parsed result */ public static void parseFilterExpressionAndCompare(ExpressionContext expressionContext, Exp expected) { @@ -67,7 +67,7 @@ public static Filter parseFilter(ExpressionContext expressionContext) { /** * Parses the given DL expression using the provided {@link IndexContext} and returns the resulting {@link Filter} object. * - * @param expressionContext The input representing DSL expression + * @param expressionContext The input representing AEL expression * @param indexContext The {@link IndexContext} to be used for building secondary index filter * @return A {@link Filter} object derived from the parsed result */ @@ -76,10 +76,10 @@ public static Filter parseFilter(ExpressionContext expressionContext, IndexConte } /** - * Parses the given DSL expression and asserts that the result is equal to the {@code expected} {@link Filter} + * Parses the given AEL expression and asserts that the result is equal to the {@code expected} {@link Filter} * object. * - * @param input The input representing DSL expression + * @param input The input representing AEL expression * @param expected The expected {@link Filter} object to compare against the parsed result */ public static void parseFilterAndCompare(ExpressionContext input, Filter expected) { @@ -88,10 +88,10 @@ public static void parseFilterAndCompare(ExpressionContext input, Filter expecte } /** - * Parses the given DSL expression using the provided {@link IndexContext} and asserts that the result is equal to + * Parses the given AEL expression using the provided {@link IndexContext} and asserts that the result is equal to * the {@code expected} {@link Filter} object. * - * @param input The string input representing DSL expression + * @param input The string input representing AEL expression * @param indexContext The {@link IndexContext} to be used for building secondary index filter * @param expected The expected {@link Filter} object to compare against the parsed result */ @@ -101,14 +101,14 @@ public static void parseFilterAndCompare(ExpressionContext input, IndexContext i } /** - * Parses the given DSL expression and compares the resulting + * Parses the given AEL expression and compares the resulting * {@link Filter} and {@link Exp} components with the expected {@code filter} and {@code exp}. * - * @param expressionContext The input representing DSL expression + * @param expressionContext The input representing AEL expression * @param filter The expected {@link Filter} component of the parsed result * @param exp The expected {@link Exp} component of the parsed result. Can be {@code null} */ - public static void parseDslExpressionAndCompare(ExpressionContext expressionContext, Filter filter, Exp exp) { + public static void parseAelExpressionAndCompare(ExpressionContext expressionContext, Filter filter, Exp exp) { ParsedExpression actualExpression = parser.parseExpression(expressionContext); assertEquals(filter, actualExpression.getResult().getFilter()); Exp actualExp = actualExpression.getResult().getExp(); @@ -116,15 +116,15 @@ public static void parseDslExpressionAndCompare(ExpressionContext expressionCont } /** - * Parses the given DSL expression using the provided {@link IndexContext} + * Parses the given AEL expression using the provided {@link IndexContext} * and compares the resulting {@link Filter} and {@link Exp} components with the expected {@code filter} and {@code exp}. * - * @param expressionContext The input representing DSL expression + * @param expressionContext The input representing AEL expression * @param filter The expected {@link Filter} component of the parsed result * @param exp The expected {@link Exp} component of the parsed result. Can be {@code null} * @param indexContext The {@link IndexContext} to be used for building secondary index filter */ - public static void parseDslExpressionAndCompare(ExpressionContext expressionContext, Filter filter, Exp exp, IndexContext indexContext) { + public static void parseAelExpressionAndCompare(ExpressionContext expressionContext, Filter filter, Exp exp, IndexContext indexContext) { ParsedExpression actualExpression = parser.parseExpression(expressionContext, indexContext); assertEquals(filter, actualExpression.getResult().getFilter()); Exp actualExp = actualExpression.getResult().getExp(); @@ -132,21 +132,21 @@ public static void parseDslExpressionAndCompare(ExpressionContext expressionCont } /** - * Parses two DSL expression strings and asserts that they produce identical packed {@link Expression} bytes. + * Parses two AEL expression strings and asserts that they produce identical packed {@link Expression} bytes. * - * @param dslActual The DSL string whose result is being verified - * @param dslExpected The reference DSL string that defines the expected result + * @param aelActual The AEL string whose result is being verified + * @param aelExpected The reference AEL string that defines the expected result */ - public static void parseDslAndCompare(String dslActual, String dslExpected) { - Expression actual = Exp.build(parser.parseExpression(ExpressionContext.of(dslActual)).getResult().getExp()); - Expression expected = Exp.build(parser.parseExpression(ExpressionContext.of(dslExpected)).getResult().getExp()); + public static void parseAelAndCompare(String aelActual, String aelExpected) { + Expression actual = Exp.build(parser.parseExpression(ExpressionContext.of(aelActual)).getResult().getExp()); + Expression expected = Exp.build(parser.parseExpression(ExpressionContext.of(aelExpected)).getResult().getExp()); assertEquals(expected, actual); } /** - * Parses the given DSL path String into array of {@link CTX}. + * Parses the given AEL path String into array of {@link CTX}. * - * @param pathToCtx String input representing DSL path + * @param pathToCtx String input representing AEL path * @return The array of {@link CTX} or null */ public static CTX[] parseCtx(String pathToCtx) { @@ -154,9 +154,9 @@ public static CTX[] parseCtx(String pathToCtx) { } /** - * Parses the given DSL path String and compares arrays of {@link CTX} using {@link CTX#toBase64(CTX[])} method. + * Parses the given AEL path String and compares arrays of {@link CTX} using {@link CTX#toBase64(CTX[])} method. * - * @param pathToCtx String input representing DSL path + * @param pathToCtx String input representing AEL path * @param expected The array of {@link CTX} to be used for comparing */ public static void parseCtxAndCompareAsBase64(String pathToCtx, CTX[] expected) { From ef98c184c3c23587ddd246da3382186d8d5ed761 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Thu, 23 Apr 2026 20:52:42 +0200 Subject: [PATCH 2/6] Correct name identifiers --- .../antlr4/com/aerospike/ael/Condition.g4 | 39 +- .../parts/cdt/map/MapIndexRangeRelative.java | 11 +- .../aerospike/ael/parts/cdt/map/MapKey.java | 8 +- .../ael/parts/cdt/map/MapKeyList.java | 9 +- .../ael/parts/cdt/map/MapKeyRange.java | 18 +- .../aerospike/ael/parts/cdt/map/MapPart.java | 8 + .../com/aerospike/ael/util/ParsingUtils.java | 32 +- .../visitor/ExpressionConditionVisitor.java | 68 ++- .../java/com/aerospike/ael/ctx/CtxTests.java | 57 ++ .../ael/expression/BinNamingTests.java | 490 ++++++++++++++++++ .../ael/expression/InNegativeTests.java | 8 +- .../ael/expression/ListExpressionsTests.java | 24 + .../ael/expression/MapExpressionsTests.java | 24 + .../ael/expression/MapKeyTypingTests.java | 469 +++++++++++++++++ .../ael/expression/SyntaxErrorTests.java | 80 ++- .../aerospike/ael/filter/BinFiltersTests.java | 12 + .../parsedExpression/PlaceholdersTests.java | 32 ++ 17 files changed, 1342 insertions(+), 47 deletions(-) create mode 100644 src/test/java/com/aerospike/ael/expression/BinNamingTests.java create mode 100644 src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java diff --git a/src/main/antlr4/com/aerospike/ael/Condition.g4 b/src/main/antlr4/com/aerospike/ael/Condition.g4 index 9cffe30c..ff08fa64 100644 --- a/src/main/antlr4/com/aerospike/ael/Condition.g4 +++ b/src/main/antlr4/com/aerospike/ael/Condition.g4 @@ -123,6 +123,8 @@ FLOAT: [0-9]+ '.' [0-9]+; // Precedes LEADING_DOT_FLOAT so the lexer greedily captures .0xff and .0b101 as one token LEADING_DOT_FLOAT_HEX_OR_BINARY: '.' '0' ([xX] [0-9a-fA-F]+ | [bB] [01]+); +LEADING_DOT_SIGNED_INT: '.' [+-] [0-9]+; + // To support .N syntax safely and keep tokenization predictable LEADING_DOT_FLOAT: '.' [0-9]+; @@ -168,7 +170,10 @@ pathOrMetadata: path | metadata; path: basePath ('.' pathFunction)?; -basePath: binPart ('.' (mapPart | listPart))*?; +basePath: binPart (('.' (mapPart | listPart)) | pathIntMapKey | pathStringMapKey)*?; + +pathIntMapKey: LEADING_DOT_FLOAT | LEADING_DOT_SIGNED_INT; +pathStringMapKey: LEADING_DOT_FLOAT_HEX_OR_BINARY; metadata: METADATA_FUNCTION; @@ -228,7 +233,32 @@ PATH_FUNCTION_CDT_RETURN_TYPE | 'REVERSE_RANK' ; -binPart: NAME_IDENTIFIER | IN; +binPart + : BIN_IDENTIFIER + | NAME_IDENTIFIER + | QUOTED_STRING + | IN + | TRUE + | FALSE + | PATH_FUNCTION_GET + | PATH_FUNCTION_PARAM_TYPE + | PATH_FUNCTION_PARAM_RETURN + | 'and' + | 'or' + | 'not' + | 'exclusive' + | 'let' + | 'then' + | 'when' + | 'default' + | 'remove' + | 'insert' + | 'set' + | 'append' + | 'increment' + | 'clear' + | 'sort' + ; mapPart : MAP_TYPE_DESIGNATOR @@ -252,6 +282,7 @@ mapKey : NAME_IDENTIFIER | QUOTED_STRING | IN + | INT ; mapValue: '{=' valueIdentifier '}'; @@ -553,4 +584,8 @@ IN: [iI][nN]; NAME_IDENTIFIER: [a-zA-Z0-9_]+; +// Must be AFTER NAME_IDENTIFIER: only inputs containing '@' match exclusively (longer match); +// for inputs without '@', NAME_IDENTIFIER wins by ANTLR first-match priority. +BIN_IDENTIFIER: [a-zA-Z0-9_@]+; + WS: [ \t\r\n]+ -> skip; diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java index 0f117e4f..c82ab096 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java @@ -17,10 +17,13 @@ public class MapIndexRangeRelative extends MapPart { private final boolean isInverted; private final Integer start; private final Integer count; - private final String relative; + private final Object relative; - public MapIndexRangeRelative(boolean isInverted, Integer start, Integer end, String relative) { + public MapIndexRangeRelative(boolean isInverted, Integer start, Integer end, Object relative) { super(MapPartType.INDEX_RANGE_RELATIVE); + if (relative != null) { + requireStringOrLong(relative, "MapIndexRangeRelative"); + } this.isInverted = isInverted; this.start = start; this.count = subtractNullable(end, start); @@ -43,7 +46,7 @@ public static MapIndexRangeRelative from(ConditionParser.MapIndexRangeRelativeCo end = parseSignedInt(range.relativeKeyEnd().end().signedInt()); } - String relativeKey = null; + Object relativeKey = null; if (range.relativeKeyEnd().mapKey() != null) { relativeKey = ParsingUtils.parseMapKey(range.relativeKeyEnd().mapKey()); } @@ -58,7 +61,7 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp keyExp = Exp.val(relative); + Exp keyExp = ParsingUtils.objectToExp(relative); Exp startExp = Exp.val(start); if (count == null) { return MapExp.getByKeyRelativeIndexRange(cdtReturnType, keyExp, startExp, diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java index adfccb4a..3883140f 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKey.java @@ -9,10 +9,11 @@ import com.aerospike.ael.util.ParsingUtils; public class MapKey extends MapPart { - private final String key; + private final Object key; - public MapKey(String key) { + public MapKey(Object key) { super(MapPartType.KEY); + requireStringOrLong(key, "MapKey"); this.key = key; } @@ -23,7 +24,8 @@ public static MapKey from(ConditionParser.MapKeyContext ctx) { @Override public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType, CTX[] context) { return MapExp.getByKey(cdtReturnType, valueType, - Exp.val(key), Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); + ParsingUtils.objectToExp(key), + Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); } @Override diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java index d95f6dc9..92a479cd 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyList.java @@ -14,10 +14,11 @@ public class MapKeyList extends MapPart { private final boolean isInverted; - private final List keyList; + private final List keyList; - public MapKeyList(boolean isInverted, List keyList) { + public MapKeyList(boolean isInverted, List keyList) { super(MapPartType.KEY_LIST); + keyList.forEach(k -> requireStringOrLong(k, "MapKeyList")); this.isInverted = isInverted; this.keyList = keyList; } @@ -31,11 +32,11 @@ public static MapKeyList from(ConditionParser.MapKeyListContext ctx) { keyList != null ? keyList.keyListIdentifier() : invertedKeyList.keyListIdentifier(); boolean isInverted = keyList == null; - List keyListStrings = list.mapKey().stream() + List keyListValues = list.mapKey().stream() .map(ParsingUtils::parseMapKey) .toList(); - return new MapKeyList(isInverted, keyListStrings); + return new MapKeyList(isInverted, keyListValues); } throw new AelParseException("Could not translate MapKeyList from ctx: %s".formatted(ctx)); } diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java index 57325610..a571fac5 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java @@ -14,11 +14,15 @@ public class MapKeyRange extends MapPart { private final boolean isInverted; - private final String start; - private final String end; + private final Object start; + private final Object end; - public MapKeyRange(boolean isInverted, String start, String end) { + public MapKeyRange(boolean isInverted, Object start, Object end) { super(MapPartType.KEY_RANGE); + requireStringOrLong(start, "MapKeyRange start"); + if (end != null) { + requireStringOrLong(end, "MapKeyRange end"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -33,9 +37,9 @@ public static MapKeyRange from(ConditionParser.MapKeyRangeContext ctx) { keyRange != null ? keyRange.keyRangeIdentifier() : invertedKeyRange.keyRangeIdentifier(); boolean isInverted = keyRange == null; - String startKey = ParsingUtils.parseMapKey(range.mapKey(0)); + Object startKey = ParsingUtils.parseMapKey(range.mapKey(0)); - String endKey = Optional.ofNullable(range.mapKey(1)) + Object endKey = Optional.ofNullable(range.mapKey(1)) .map(ParsingUtils::parseMapKey) .orElse(null); @@ -50,8 +54,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = Exp.val(start); - Exp endExp = end != null ? Exp.val(end) : null; + Exp startExp = ParsingUtils.objectToExp(start); + Exp endExp = end != null ? ParsingUtils.objectToExp(end) : null; return MapExp.getByKeyRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java index 5c67845a..328358a9 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapPart.java @@ -1,5 +1,6 @@ package com.aerospike.ael.parts.cdt.map; +import com.aerospike.ael.AelParseException; import com.aerospike.ael.client.cdt.MapReturnType; import com.aerospike.ael.parts.cdt.CdtPart; import com.aerospike.ael.parts.path.PathFunction; @@ -32,6 +33,13 @@ public int getReturnType(PathFunction.ReturnParam returnParam) { }; } + static void requireStringOrLong(Object key, String context) { + if (!(key instanceof String) && !(key instanceof Long)) { + throw new AelParseException( + "Unsupported map key type in %s: %s".formatted(context, key.getClass().getSimpleName())); + } + } + public enum MapPartType { MAP_TYPE_DESIGNATOR, KEY, diff --git a/src/main/java/com/aerospike/ael/util/ParsingUtils.java b/src/main/java/com/aerospike/ael/util/ParsingUtils.java index e9eec273..968e7c08 100644 --- a/src/main/java/com/aerospike/ael/util/ParsingUtils.java +++ b/src/main/java/com/aerospike/ael/util/ParsingUtils.java @@ -118,20 +118,40 @@ private static String resolveStringToken(ParserRuleContext ctx) { } /** - * Extracts the text content from a {@code mapKey} parser rule context. - * Handles NAME_IDENTIFIER, QUOTED_STRING, and IN keyword (as literal text). + * Extracts a typed value from a {@code mapKey} parser rule context. + * Returns {@link Long} for pure decimal INT tokens, {@link String} for hex/binary INT tokens, + * and {@link String} for NAME_IDENTIFIER, QUOTED_STRING, and IN keyword. * * @param ctx The mapKey context from the parser - * @return The parsed key string + * @return The parsed key as String or Long */ - public static String parseMapKey(ConditionParser.MapKeyContext ctx) { + public static Object parseMapKey(ConditionParser.MapKeyContext ctx) { String result = resolveStringToken(ctx); if (result != null) { return result; } + TerminalNode intToken = ctx.getToken(ConditionParser.INT, 0); + if (intToken != null) { + String intText = intToken.getText(); + if (isHexOrBinaryIntToken(intText)) { + return intText; + } + return parseLongMapKey(intText); + } throw new AelParseException("Could not parse mapKey from ctx: %s".formatted(ctx.getText())); } + /** + * Parses a decimal digit string as a long map key, wrapping overflow in {@link AelParseException}. + */ + public static long parseLongMapKey(String text) { + try { + return Long.parseLong(text); + } catch (NumberFormatException e) { + throw new AelParseException("Integer map key out of range: " + text, e); + } + } + /** * Extracts a typed value from a {@code valueIdentifier} parser rule context. * Handles NAME_IDENTIFIER, QUOTED_STRING, IN keyword (as literal text), and signedInt. @@ -202,8 +222,7 @@ public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierC /** * Converts a parsed value object to an {@link Exp} value expression. - * Supports the types produced by {@link #parseValueIdentifier}: {@link String}, {@link Integer}, - * and {@code byte[]}. + * Supports {@link String}, {@link Long}, {@link Integer}, and {@code byte[]}. * * @param value The parsed value object * @return The corresponding {@link Exp} value expression @@ -211,6 +230,7 @@ public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierC */ public static Exp objectToExp(Object value) { if (value instanceof String s) return Exp.val(s); + if (value instanceof Long l) return Exp.val(l); if (value instanceof Integer i) return Exp.val(i); if (value instanceof byte[] b) return Exp.val(b); throw new AelParseException( diff --git a/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java b/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java index 193c187b..e1ea8246 100644 --- a/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java +++ b/src/main/java/com/aerospike/ael/visitor/ExpressionConditionVisitor.java @@ -35,9 +35,11 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; +import java.util.regex.Pattern; import static com.aerospike.ael.util.ParsingUtils.*; import static com.aerospike.ael.visitor.VisitorUtils.*; @@ -46,16 +48,20 @@ public class ExpressionConditionVisitor extends ConditionBaseVisitor expressions = new ArrayList<>(); - // iterate through each definition for (ConditionParser.VariableDefinitionContext vdc : ctx.variableDefinition()) { + String varName = vdc.NAME_IDENTIFIER().getText(); + validateVariableName(varName); AbstractPart part = visit(vdc.expression()); - LetOperand letOperand = new LetOperand(part, vdc.NAME_IDENTIFIER().getText()); + LetOperand letOperand = new LetOperand(part, varName); expressions.add(letOperand); } // last expression is the action (described after "then") @@ -649,6 +655,7 @@ public AbstractPart visitFunctionCall(ConditionParser.FunctionCallContext ctx) { } String funcName = ctx.NAME_IDENTIFIER().getText(); + validateFunctionName(funcName); List args = new ArrayList<>(); for (ConditionParser.ExpressionContext ec : ctx.expression()) { args.add(visit(ec)); @@ -837,13 +844,46 @@ public AbstractPart visitMetadata(ConditionParser.MetadataContext ctx) { @Override public AbstractPart visitBinPart(ConditionParser.BinPartContext ctx) { - if (ctx.NAME_IDENTIFIER() != null) { - return new BinPart(ctx.NAME_IDENTIFIER().getText()); + if (ctx.BIN_IDENTIFIER() != null) { + String binName = ctx.BIN_IDENTIFIER().getText(); + rejectBinNameContainingNull(binName); + return new BinPart(binName); + } + if (ctx.QUOTED_STRING() != null) { + String quoted = ctx.QUOTED_STRING().getText(); + if (quoted.length() <= 2) { + throw new AelParseException("Bin name must not be empty"); + } + String binName = unquote(quoted); + rejectBinNameContainingNull(binName); + return new BinPart(binName); + } + // Fallthrough: NAME_IDENTIFIER, IN, TRUE, FALSE, and all keyword literals ('and', 'or', + // 'not', etc.). ctx.getText() returns the matched text preserving original case. + String binName = ctx.getText(); + rejectBinNameContainingNull(binName); + return new BinPart(binName); + } + + private static void validateVariableName(String name) { + if (!VARIABLE_NAME_PATTERN.matcher(name).matches()) { + throw new AelParseException( + "Invalid variable name '%s': must start with a letter or underscore".formatted(name)); + } + } + + private static void validateFunctionName(String name) { + if (!FUNCTION_NAME_PATTERN.matcher(name).matches()) { + throw new AelParseException( + "Invalid function name '%s': must contain letters only".formatted(name)); } - if (ctx.IN() != null) { - return new BinPart(ctx.IN().getText()); + } + + private static void rejectBinNameContainingNull(String binName) { + if (binName.toLowerCase(Locale.ROOT).contains("null")) { + throw new AelParseException( + "Bin name must not contain the reserved word 'null': " + binName); } - throw new AelParseException("Could not parse binPart from ctx: %s".formatted(ctx.getText())); } @Override @@ -996,6 +1036,8 @@ public AbstractPart visitPlaceholder(ConditionParser.PlaceholderContext ctx) { public AbstractPart visitBasePath(ConditionParser.BasePathContext ctx) { BinPart binPart = null; List cdtParts = new ArrayList<>(); + // Filter out standalone '.' separator tokens. Embedded-dot tokens (pathIntMapKey, + // pathStringMapKey) have multi-char text (e.g. ".55", ".0xff") and pass through. List ctxChildrenExclDots = ctx.children.stream() .filter(tree -> !tree.getText().equals(".")) .toList(); @@ -1077,6 +1119,18 @@ public AbstractPart visitListPart(ConditionParser.ListPartContext ctx) { throw new AelParseException("Unexpected list part: %s".formatted(ctx.getText())); } + @Override + public AbstractPart visitPathIntMapKey(ConditionParser.PathIntMapKeyContext ctx) { + String keyText = ctx.getText().substring(1); // strip leading dot + return new MapKey(parseLongMapKey(keyText)); + } + + @Override + public AbstractPart visitPathStringMapKey(ConditionParser.PathStringMapKeyContext ctx) { + String tokenText = ctx.LEADING_DOT_FLOAT_HEX_OR_BINARY().getText(); + return new MapKey(tokenText.substring(1)); // strip leading dot, keep as string + } + @Override public AbstractPart visitMapPart(ConditionParser.MapPartContext ctx) { if (ctx.MAP_TYPE_DESIGNATOR() != null) return MapTypeDesignator.from(); diff --git a/src/test/java/com/aerospike/ael/ctx/CtxTests.java b/src/test/java/com/aerospike/ael/ctx/CtxTests.java index 227360f3..60980735 100644 --- a/src/test/java/com/aerospike/ael/ctx/CtxTests.java +++ b/src/test/java/com/aerospike/ael/ctx/CtxTests.java @@ -209,4 +209,61 @@ void parseCTXWithB64BlobValue() { parseCtxAndCompareAsBase64("$.bin.[=b64'AQID']", new CTX[]{CTX.listValue(Value.get(new byte[]{1, 2, 3}))}); } + + // ---- New map key type tests ---- + + @Test + void ctxDigitOnlyMapKey() { + parseCtxAndCompareAsBase64("$.bin.55", + new CTX[]{CTX.mapKey(Value.get(55L))}); + } + + @Test + void ctxNegativeSignedMapKey() { + parseCtxAndCompareAsBase64("$.bin.-100", + new CTX[]{CTX.mapKey(Value.get(-100L))}); + } + + @Test + void ctxPositiveSignedMapKey() { + parseCtxAndCompareAsBase64("$.bin.+100", + new CTX[]{CTX.mapKey(Value.get(100L))}); + } + + @Test + void ctxHexMapKey() { + parseCtxAndCompareAsBase64("$.bin.0xff", + new CTX[]{CTX.mapKey(Value.get("0xff"))}); + } + + @Test + void ctxBinaryMapKey() { + parseCtxAndCompareAsBase64("$.bin.0b1010", + new CTX[]{CTX.mapKey(Value.get("0b1010"))}); + } + + @Test + void ctxMixedMapKeyTypes() { + parseCtxAndCompareAsBase64("$.bin.55.key.-1.0xff", + new CTX[]{CTX.mapKey(Value.get(55L)), CTX.mapKey(Value.get("key")), + CTX.mapKey(Value.get(-1L)), CTX.mapKey(Value.get("0xff"))}); + } + + @Test + void ctxAtBinWithMapKey() { + parseCtxAndCompareAsBase64("$.name@host.key", + new CTX[]{CTX.mapKey(Value.get("key"))}); + } + + @Test + void ctxAtBinWithListIndex() { + parseCtxAndCompareAsBase64("$.@attr.[0]", + new CTX[]{CTX.listIndex(0)}); + } + + @Test + void ctxLeadingZeroMapKey() { + parseCtxAndCompareAsBase64("$.bin.007", + new CTX[]{CTX.mapKey(Value.get(7L))}); + } } diff --git a/src/test/java/com/aerospike/ael/expression/BinNamingTests.java b/src/test/java/com/aerospike/ael/expression/BinNamingTests.java new file mode 100644 index 00000000..b9f4206c --- /dev/null +++ b/src/test/java/com/aerospike/ael/expression/BinNamingTests.java @@ -0,0 +1,490 @@ +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.cdt.ListReturnType; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.exp.ListExp; +import com.aerospike.ael.client.exp.MapExp; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.aerospike.ael.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class BinNamingTests { + + @Nested + class CharsetAndQuoting { + + @Test + void binNameWithAt() { + Exp expected = Exp.eq(Exp.intBin("name@host"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.name@host == 5"), expected); + } + + @Test + void binNameStartingWithAt() { + Exp expected = Exp.eq(Exp.intBin("@attr"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.@attr == 5"), expected); + } + + @Test + void binNameEndingWithAt() { + Exp expected = Exp.eq(Exp.intBin("name@"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.name@ == 5"), expected); + } + + @Test + void binNameSingleAt() { + Exp expected = Exp.eq(Exp.intBin("@"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.@ == 5"), expected); + } + + @Test + void quotedBinNameDouble() { + Exp expected = Exp.eq(Exp.intBin("my-bin"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.\"my-bin\" == 5"), expected); + } + + @Test + void quotedBinNameSingle() { + Exp expected = Exp.eq(Exp.intBin("my-bin"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.'my-bin' == 5"), expected); + } + + @Test + void quotedBinNameDollar() { + Exp expected = Exp.eq(Exp.intBin("$price"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.'$price' == 5"), expected); + } + + @Test + void quotedBinNameSpaces() { + Exp expected = Exp.eq(Exp.intBin("has spaces"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.\"has spaces\" == 5"), expected); + } + + @Test + void quotedUnquotedEquivalence() { + Expression exp1 = Exp.build(parseFilterExp(ExpressionContext.of("$.myBin == 5"))); + Expression exp2 = Exp.build(parseFilterExp(ExpressionContext.of("$.\"myBin\" == 5"))); + Expression exp3 = Exp.build(parseFilterExp(ExpressionContext.of("$.'myBin' == 5"))); + assertEquals(exp1, exp2); + assertEquals(exp1, exp3); + } + + @Test + void quotedUnquotedAtEquiv() { + Expression exp1 = Exp.build(parseFilterExp(ExpressionContext.of("$.name@host == 5"))); + Expression exp2 = Exp.build(parseFilterExp(ExpressionContext.of("$.\"name@host\" == 5"))); + assertEquals(exp1, exp2); + } + + @Test + void quotedUnquotedKeywordEquiv() { + Expression exp1 = Exp.build(parseFilterExp(ExpressionContext.of("$.true == 5"))); + Expression exp2 = Exp.build(parseFilterExp(ExpressionContext.of("$.\"true\" == 5"))); + Expression exp3 = Exp.build(parseFilterExp(ExpressionContext.of("$.'true' == 5"))); + assertEquals(exp1, exp2); + assertEquals(exp1, exp3); + } + + @Test + void quotedUnquotedInEquiv() { + Expression exp1 = Exp.build(parseFilterExp(ExpressionContext.of("$.in == 5"))); + Expression exp2 = Exp.build(parseFilterExp(ExpressionContext.of("$.\"in\" == 5"))); + Expression exp3 = Exp.build(parseFilterExp(ExpressionContext.of("$.'in' == 5"))); + assertEquals(exp1, exp2); + assertEquals(exp1, exp3); + } + + @Test + void negEmptyQuotedBinDouble() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.\"\" == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Bin name must not be empty"); + } + + @Test + void negEmptyQuotedBinSingle() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.'' == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Bin name must not be empty"); + } + + @Test + void negAtInMapKey() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.key@val == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negAtInVariableDef() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("let(x@ = 5) then (${x} + 1)"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negDigitOnlyBinName() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.123 == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negAtInFunctionCall() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("my@func($.bin) == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void binNameDigitStartWithAt() { + Exp expected = Exp.eq(Exp.intBin("123@"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.123@ == 5"), expected); + } + + @Test + void atBinWithMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("key"), Exp.mapBin("name@host")), + Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.name@host.key == 5"), expected); + } + + @Test + void atBinWithListIndex() { + Exp expected = Exp.eq( + ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, + Exp.val(0), Exp.listBin("@attr")), + Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.@attr.[0] == 5"), expected); + } + } + + @Nested + class KeywordCollision { + + @Test + void binNamedTrue() { + Exp expected = Exp.eq(Exp.intBin("true"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.true == 5"), expected); + } + + @Test + void binNamedFalse() { + Exp expected = Exp.eq(Exp.intBin("false"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.false == 5"), expected); + } + + @Test + void binNamedAnd() { + Exp expected = Exp.eq(Exp.intBin("and"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.and == 1"), expected); + } + + @Test + void binNamedOr() { + Exp expected = Exp.eq(Exp.intBin("or"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.or == 1"), expected); + } + + @Test + void binNamedNot() { + Exp expected = Exp.eq(Exp.intBin("not"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.not == 1"), expected); + } + + @Test + void binNamedLet() { + Exp expected = Exp.eq(Exp.intBin("let"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.let == 1"), expected); + } + + @Test + void binNamedThen() { + Exp expected = Exp.eq(Exp.intBin("then"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.then == 1"), expected); + } + + @Test + void binNamedWhen() { + Exp expected = Exp.eq(Exp.intBin("when"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.when == 1"), expected); + } + + @Test + void binNamedDefault() { + Exp expected = Exp.eq(Exp.intBin("default"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.default == 1"), expected); + } + + @Test + void binNamedExclusive() { + Exp expected = Exp.eq(Exp.intBin("exclusive"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.exclusive == 1"), expected); + } + + @Test + void binNamedGet() { + Exp expected = Exp.eq(Exp.intBin("get"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.get == 1"), expected); + } + + @Test + void binNamedType() { + Exp expected = Exp.eq(Exp.intBin("type"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.type == 1"), expected); + } + + @Test + void binNamedReturn() { + Exp expected = Exp.eq(Exp.intBin("return"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.return == 1"), expected); + } + + @Test + void binNamedRemove() { + Exp expected = Exp.eq(Exp.intBin("remove"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.remove == 1"), expected); + } + + @Test + void binNamedInsert() { + Exp expected = Exp.eq(Exp.intBin("insert"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.insert == 1"), expected); + } + + @Test + void binNamedSet() { + Exp expected = Exp.eq(Exp.intBin("set"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.set == 1"), expected); + } + + @Test + void binNamedAppend() { + Exp expected = Exp.eq(Exp.intBin("append"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.append == 1"), expected); + } + + @Test + void binNamedIncrement() { + Exp expected = Exp.eq(Exp.intBin("increment"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.increment == 1"), expected); + } + + @Test + void binNamedClear() { + Exp expected = Exp.eq(Exp.intBin("clear"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.clear == 1"), expected); + } + + @Test + void binNamedSort() { + Exp expected = Exp.eq(Exp.intBin("sort"), Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.sort == 1"), expected); + } + + @Test + void keywordBinWithMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("key"), Exp.mapBin("true")), + Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.true.key == 5"), expected); + } + + @Test + void compoundAndWithKeywordBins() { + Exp expected = Exp.and( + Exp.eq(Exp.intBin("and"), Exp.val(1)), + Exp.eq(Exp.intBin("or"), Exp.val(2))); + parseFilterExpressionAndCompare(ExpressionContext.of("$.and == 1 and $.or == 2"), expected); + } + + @Test + void compoundOrWithKeywordBins() { + Exp expected = Exp.or( + Exp.eq(Exp.intBin("or"), Exp.val(1)), + Exp.eq(Exp.intBin("and"), Exp.val(2))); + parseFilterExpressionAndCompare(ExpressionContext.of("$.or == 1 or $.and == 2"), expected); + } + + @Test + void compoundNotWithKeywordBin() { + Exp expected = Exp.and( + Exp.eq(Exp.intBin("not"), Exp.val(1)), + Exp.not(Exp.eq(Exp.intBin("x"), Exp.val(2)))); + parseFilterExpressionAndCompare(ExpressionContext.of("$.not == 1 and not($.x == 2)"), expected); + } + + @Test + void keywordBinInWithInOp() { + Exp expected = ListExp.getByValue(ListReturnType.EXISTS, + Exp.intBin("in"), Exp.val(List.of(1, 2, 3))); + parseFilterExpressionAndCompare(ExpressionContext.of("$.in in [1, 2, 3]"), expected); + } + + @Test + void binNamedInCasePreserved() { + Exp expected = Exp.eq(Exp.intBin("IN"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.IN == 5"), expected); + } + } + + @Nested + class NullRestriction { + + @Test + void negBinNameNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.null == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameNullUpper() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.NULL == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameNullMixed() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.nUlL == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameNullSubstring() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.nullify == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameEndsWithNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mynull == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameCapitalNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.myNullVar == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameUnderscoredNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.my_null_bin == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negQuotedBinContainsNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.\"my-null-key\" == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negQuotedBinExactNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.\"null\" == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negQuotedBinExactNullSQ() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.'null' == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negQuotedBinNullUpper() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.'NULL_BIN' == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameNullWithAt() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.null@ == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negBinNameAtNull() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.@null == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void negQuotedBinNullAtHost() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.\"null@host\" == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("null") + .hasMessageContaining("Bin name"); + } + + @Test + void binNameNulAllowed() { + Exp expected = Exp.eq(Exp.intBin("nul"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.nul == 5"), expected); + } + + @Test + void binNameNulCapAllowed() { + Exp expected = Exp.eq(Exp.intBin("Nul"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.Nul == 5"), expected); + } + + @Test + void binNameNuLlAllowed() { + Exp expected = Exp.eq(Exp.intBin("nu_ll"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.nu_ll == 5"), expected); + } + + @Test + void binNameLnulAllowed() { + Exp expected = Exp.eq(Exp.intBin("lnul"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.lnul == 5"), expected); + } + + @Test + void binNameNuAtLlAllowed() { + Exp expected = Exp.eq(Exp.intBin("nu@ll"), Exp.val(5)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.nu@ll == 5"), expected); + } + } +} diff --git a/src/test/java/com/aerospike/ael/expression/InNegativeTests.java b/src/test/java/com/aerospike/ael/expression/InNegativeTests.java index 63a8f4d5..3d5f8153 100644 --- a/src/test/java/com/aerospike/ael/expression/InNegativeTests.java +++ b/src/test/java/com/aerospike/ael/expression/InNegativeTests.java @@ -73,7 +73,7 @@ void negMixedBoolAndIntInList() { } @Test - void negMixedFloatAndStringInList() { + void negativeMixedFloatAndStringInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [1.5, \"hello\"]"))) .isInstanceOf(AelParseException.class) @@ -81,7 +81,7 @@ void negMixedFloatAndStringInList() { } @Test - void negMixedIntAndFloatInList() { + void negativeMixedIntAndFloatInList() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.bin in [1, 1.5]"))) .isInstanceOf(AelParseException.class) @@ -89,7 +89,7 @@ void negMixedIntAndFloatInList() { } @Test - void negPlaceholderResolvesToStr() { + void negativePlaceholderResolvesToStr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of("Bob")))) .isInstanceOf(AelParseException.class) @@ -97,7 +97,7 @@ void negPlaceholderResolvesToStr() { } @Test - void negPlaceholderResolvesToInt() { + void negativePlaceholderResolvesToInt() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of("$.name in ?0", PlaceholderValues.of(42)))) .isInstanceOf(AelParseException.class) diff --git a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java index b9c27ba1..defcb058 100644 --- a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java @@ -496,4 +496,28 @@ void listReturnTypes() { // Implicit detect as INT TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[0].get(return: INDEX) == 1"), expected); } + + // ---- List value type contrast ---- + + @Test + void listValueQuotedIntIsString() { + Exp expectedDQ = Exp.eq( + ListExp.getByValue(ListReturnType.VALUE, + Exp.val("1"), Exp.listBin("listBin")), + Exp.val("x")); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.listBin.[=\"1\"].get(type: STRING) == \"x\""), expectedDQ); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.listBin.[='1'].get(type: STRING) == 'x'"), expectedDQ); + } + + @Test + void listValueUnquotedIntIsInt() { + Exp expected = Exp.eq( + ListExp.getByValue(ListReturnType.VALUE, + Exp.val(1), Exp.listBin("listBin")), + Exp.val(10)); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.listBin.[=1] == 10"), expected); + } } diff --git a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java index 9f14544d..ea72ed62 100644 --- a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java @@ -634,4 +634,28 @@ void mapReturnTypes() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.a.get(type: INT, return: RANK) == 5"), expected); } + + // ---- Map value type contrast ---- + + @Test + void mapValueQuotedIntIsString() { + Exp expectedDQ = Exp.eq( + MapExp.getByValue(MapReturnType.VALUE, + Exp.val("1"), Exp.mapBin("mapBin")), + Exp.val("x")); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.mapBin.{=\"1\"}.get(type: STRING) == \"x\""), expectedDQ); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.mapBin.{='1'}.get(type: STRING) == 'x'"), expectedDQ); + } + + @Test + void mapValueUnquotedIntIsInt() { + Exp expected = Exp.eq( + MapExp.getByValue(MapReturnType.VALUE, + Exp.val(1), Exp.mapBin("mapBin")), + Exp.val(10)); + TestUtils.parseFilterExpressionAndCompare( + ExpressionContext.of("$.mapBin.{=1} == 10"), expected); + } } diff --git a/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java b/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java new file mode 100644 index 00000000..0106c757 --- /dev/null +++ b/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java @@ -0,0 +1,469 @@ +package com.aerospike.ael.expression; + +import com.aerospike.ael.AelParseException; +import com.aerospike.ael.ExpressionContext; +import com.aerospike.ael.client.Value; +import com.aerospike.ael.client.cdt.CTX; +import com.aerospike.ael.client.cdt.MapReturnType; +import com.aerospike.ael.client.exp.Exp; +import com.aerospike.ael.client.exp.Expression; +import com.aerospike.ael.client.exp.MapExp; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.aerospike.ael.util.TestUtils.parseFilterExp; +import static com.aerospike.ael.util.TestUtils.parseFilterExpressionAndCompare; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +class MapKeyTypingTests { + + @Nested + class DigitOnlyPathKeys { + + @Test + void digitOnlyMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(55L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.55 == 10"), expected); + } + + @Test + void largeDigitMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(12345678910L), Exp.mapBin("bin")), + Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.12345678910 == 1"), expected); + } + + @Test + void singleDigitMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(1L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.1 == 10"), expected); + } + + @Test + void zeroMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(0L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.0 == 10"), expected); + } + + @Test + void leadingZeroMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(7L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.007 == 10"), expected); + } + + @Test + void quotedDigitMapKeyString() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.STRING, + Exp.val("55"), Exp.mapBin("m")), + Exp.val("val")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.\"55\" == \"val\""), expected); + } + + @Test + void quotedDigitMapKeySQString() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.STRING, + Exp.val("55"), Exp.mapBin("m")), + Exp.val("val")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.'55' == 'val'"), expected); + } + + @Test + void typeContrastDigitMapKey() { + Expression intKey = Exp.build(parseFilterExp(ExpressionContext.of("$.m.55 == 10"))); + Expression strKey = Exp.build(parseFilterExp(ExpressionContext.of("$.m.\"55\" == 10"))); + assertNotEquals(intKey, strKey); + } + + @Test + void mixedDigitAndStringKeys() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("key"), Exp.bin("bin", Exp.Type.MAP), + CTX.mapKey(Value.get(55L))), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.55.key == 10"), expected); + } + + @Test + void digitKeyWithPathFunction() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(55L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.55.get(type: INT) == 10"), expected); + } + + @Test + void negDigitKeyOverflow() { + assertThatThrownBy(() -> parseFilterExp( + ExpressionContext.of("$.bin.99999999999999999999 == 10"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("out of range"); + } + } + + @Nested + class SignedPathKeys { + + @Test + void negativeSignedMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(-100L), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.-100 == 10"), expected); + } + + @Test + void positiveSignedMapKey() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(100L), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.+100 == 10"), expected); + } + + @Test + void combinedSignedMapKeys() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(100L), Exp.bin("bin", Exp.Type.MAP), + CTX.mapKey(Value.get(100L)), CTX.mapKey(Value.get(-100L))), + Exp.val(1)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.100.-100.+100 == 1"), expected); + } + + @Test + void signedZeroMinus() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(0L), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.-0 == 10"), expected); + } + + @Test + void signedZeroPlus() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(0L), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.+0 == 10"), expected); + } + + @Test + void negSignedMapKeySpaceMinus() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.- 100 == 10"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negSignedMapKeySpacePlus() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.+ 100 == 10"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void quotedSignedDigitIsString() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("-100"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.\"-100\" == 10"), expected); + } + + @Test + void signedKeyWithPathFunction() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(-100L), Exp.mapBin("m")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.m.-100.get(type: INT) == 10"), expected); + } + + @Test + void negDoubleMinusSign() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.--100 == 10"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negPlusMinusMixedSign() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.+-100 == 10"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + } + + @Nested + class HexBinaryPathKeys { + + @Test + void hexMapKeyIsString() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0xff"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.0xff == 10"), expected); + } + + @Test + void hexMapKeyCasePreserved() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0xFF"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.0xFF == 10"), expected); + } + + @Test + void hexMapKeyUpperPrefix() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0Xff"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.0Xff == 10"), expected); + } + + @Test + void binaryMapKeyIsString() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0b1010"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.0b1010 == 10"), expected); + } + + @Test + void binaryMapKeyUpperPrefix() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0B1010"), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.0B1010 == 10"), expected); + } + + @Test + void fullMixedPath() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val("0b1010"), Exp.bin("bin", Exp.Type.MAP), + CTX.mapKey(Value.get(100L)), CTX.mapKey(Value.get(-100L)), + CTX.mapKey(Value.get(100L)), CTX.mapKey(Value.get("0xff"))), + Exp.val(1)); + parseFilterExpressionAndCompare( + ExpressionContext.of("$.bin.100.-100.+100.0xff.0b1010 == 1"), expected); + } + + @Test + void quotedHexEquivalent() { + Expression unquoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.0xff == 10"))); + Expression quoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.\"0xff\" == 10"))); + assertEquals(unquoted, quoted); + } + + @Test + void quotedBinaryEquivalent() { + Expression unquoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.0b1010 == 10"))); + Expression quoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.\"0b1010\" == 10"))); + assertEquals(unquoted, quoted); + } + + @Test + void hexKeyWithPathFunction() { + Exp expected = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.STRING, + Exp.val("0xff"), Exp.mapBin("m")), + Exp.val("x")); + parseFilterExpressionAndCompare( + ExpressionContext.of("$.m.0xff.get(type: STRING) == \"x\""), expected); + } + } + + @Nested + class BraceContextKeys { + + @Test + void intKeyInKeyRange() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + Exp.val(55L), Exp.val("z"), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{55-z}"), expected); + } + + @Test + void intKeyInKeyList() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of(55L, "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{55,abc}"), expected); + } + + @Test + void quotedDigitKeyInKeyList() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of("55", "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{\"55\",abc}"), expected); + } + + @Test + void intKeyRangeBothEndpoints() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + Exp.val(10L), Exp.val(200L), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{10-200}"), expected); + } + + @Test + void quotedDigitKeyInKeyRange() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + Exp.val("55"), Exp.val("z"), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{\"55\"-z}"), expected); + } + + @Test + void hexIntInKeyRange() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + Exp.val("0xff"), Exp.val("z"), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0xff-z}"), expected); + } + + @Test + void hexIntInKeyList() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of("0xff", "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0xff,abc}"), expected); + } + + @Test + void binaryIntInKeyList() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of("0b1010", "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0b1010,abc}"), expected); + } + + @Test + void binaryIntInKeyRange() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + Exp.val("0b1010"), Exp.val("z"), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0b1010-z}"), expected); + } + + @Test + void intKeyInRelativeIndex() { + Exp expected = MapExp.getByKeyRelativeIndexRange(MapReturnType.VALUE, + Exp.val(55L), Exp.val(0), Exp.val(1), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0:1~55}"), expected); + } + + @Test + void singleIntBracesIsMapIndex() { + Exp expected = Exp.eq( + MapExp.getByIndex(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(55), Exp.mapBin("bin")), + Exp.val(10)); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{55} == 10"), expected); + } + + @Test + void disambiguationIndexVsKeyList() { + Expression mapIndex = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.{55} == 10"))); + Expression keyList = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.{55,abc}"))); + assertNotEquals(mapIndex, keyList); + } + + @Test + void singleAbcKeyListRegression() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of("abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{abc}"), expected); + } + + @Test + void intKeyInvertedRange() { + Exp expected = MapExp.getByKeyRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + Exp.val(55L), Exp.val("z"), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{!55-z}"), expected); + } + + @Test + void intKeyInvertedList() { + Exp expected = MapExp.getByKeyList( + MapReturnType.VALUE | MapReturnType.INVERTED, + Exp.val(List.of(55L, "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{!55,abc}"), expected); + } + + @Test + void negNegativeIntInBraces() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.{-55,abc}"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negNegativeIntInBraceRange() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.bin.{-55-z}"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void quotedNegIntInBraces() { + Exp expected = MapExp.getByKeyList(MapReturnType.VALUE, + Exp.val(List.of("-55", "abc")), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{\"-55\",abc}"), expected); + } + + @Test + void negIntKeyOverflowInBraces() { + assertThatThrownBy(() -> parseFilterExp( + ExpressionContext.of("$.bin.{99999999999999999999-z}"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("out of range"); + } + } + + @Nested + class MapKeyEquivalence { + + @Test + void quotedUnquotedMapKeyEquiv() { + Expression unquoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.key == 10"))); + Expression doubleQuoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.\"key\" == 10"))); + Expression singleQuoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.'key' == 10"))); + assertEquals(unquoted, doubleQuoted); + assertEquals(unquoted, singleQuoted); + } + + @Test + void mapKeyInQuotedEquiv() { + Expression unquoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.in == 10"))); + Expression doubleQuoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.\"in\" == 10"))); + Expression singleQuoted = Exp.build(parseFilterExp(ExpressionContext.of("$.bin.'in' == 10"))); + assertEquals(unquoted, doubleQuoted); + assertEquals(unquoted, singleQuoted); + } + } +} diff --git a/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java b/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java index c20f010a..5195c54e 100644 --- a/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java +++ b/src/test/java/com/aerospike/ael/expression/SyntaxErrorTests.java @@ -14,7 +14,7 @@ class SyntaxErrorTests { // --- General syntax errors --- @Test - void negNonsensePathFunction() { + void negativeNonsensePathFunction() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("1.0 == $.f1.nonsense()"))) .isInstanceOf(AelParseException.class) .hasMessageContaining("Could not parse given AEL expression input") @@ -23,7 +23,7 @@ void negNonsensePathFunction() { } @Test - void negNonsensePathFunctionOnLeft() { + void negativeNonsensePathFunctionOnLeft() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.f1.nonsense() == 1.0"))) .isInstanceOf(AelParseException.class) .hasMessageContaining("Could not parse given AEL expression input") @@ -32,7 +32,7 @@ void negNonsensePathFunctionOnLeft() { } @Test - void negTrailingGarbageTokens() { + void negativeTrailingGarbageTokens() { assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.intBin1 > 100 garbage"))) .isInstanceOf(AelParseException.class) .hasMessageContaining("Could not parse given AEL expression input") @@ -55,7 +55,7 @@ void letWithAlphanumericVarName() { // --- Malformed variable references --- @Test - void negVarBareNameInThenBody() { + void negativeVarBareNameInThenBody() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x})) then (y == true)"))) @@ -66,7 +66,7 @@ void negVarBareNameInThenBody() { } @Test - void negVarDollarNoInThenBody() { + void negativeVarDollarNoInThenBody() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x})) then ($y == true)"))) @@ -79,7 +79,7 @@ void negVarDollarNoInThenBody() { } @Test - void negVarMissingCloseBrace() { + void negativeVarMissingCloseBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x)) then (${y} == true)"))) @@ -92,7 +92,7 @@ void negVarMissingCloseBrace() { } @Test - void negVarMissingDollarAndOpen() { + void negativeVarMissingDollarAndOpen() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in x})) then (${y} == true)"))) @@ -103,7 +103,7 @@ void negVarMissingDollarAndOpen() { } @Test - void negVarBareNameInLetExpr() { + void negativeVarBareNameInLetExpr() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in x)) then (${y} == true)"))) @@ -114,7 +114,7 @@ void negVarBareNameInLetExpr() { } @Test - void negVarDoubleOpenBrace() { + void negativeVarDoubleOpenBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${{x})) then (${y} == true)"))) @@ -127,7 +127,7 @@ void negVarDoubleOpenBrace() { } @Test - void negVarDoubleCloseBrace() { + void negativeVarDoubleCloseBrace() { assertThatThrownBy(() -> parseFilterExp( ExpressionContext.of( "let(x = 5, y = ($.bin.get(type: INT) in ${x}})) then (${y} == true)"))) @@ -225,4 +225,64 @@ void negWhenMissingArrow() { .hasMessageContaining("[Parser] no viable alternative at input") .hasMessageContaining("at character 14"); } + + // ---- Let variable name validation ---- + + @Test + void letVarStartsWithUnderscore() { + Exp expected = Exp.let( + Exp.def("_x", Exp.val(5)), + Exp.add(Exp.var("_x"), Exp.val(1))); + parseFilterExpressionAndCompare( + ExpressionContext.of("let(_x = 5) then (${_x} + 1)"), expected); + } + + @Test + void letVarAllUnderscores() { + Exp expected = Exp.let( + Exp.def("__", Exp.val(5)), + Exp.add(Exp.var("__"), Exp.val(1))); + parseFilterExpressionAndCompare( + ExpressionContext.of("let(__ = 5) then (${__} + 1)"), expected); + } + + @Test + void negLetVarStartsWithDigit() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("let(1abc = 5) then (1)"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("variable") + .hasMessageContaining("start with a letter or underscore"); + } + + @Test + void negLetVarOnlyDigits() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("let(123 = 5) then (${123} + 1)"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + @Test + void negLetVarKeyword() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("let(true = 5) then (${true} + 1)"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("at character"); + } + + // ---- Function name validation ---- + + @Test + void negFuncNameWithUnderscore() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("my_func($.bin) == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("function name") + .hasMessageContaining("letters only"); + } + + @Test + void negFuncNameWithDigit() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("func1($.bin) == 5"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("function name") + .hasMessageContaining("letters only"); + } } diff --git a/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java b/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java index 98b3522a..a2fd47cc 100644 --- a/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java +++ b/src/test/java/com/aerospike/ael/filter/BinFiltersTests.java @@ -106,4 +106,16 @@ void binNOTEQ() { assertThat(parseFilter(ExpressionContext.of("100 != 'text'"), INDEX_FILTER_INPUT)).isNull(); assertThat(parseFilter(ExpressionContext.of("100 != \"text\""), INDEX_FILTER_INPUT)).isNull(); } + + // ---- SI filter with keyword bin name ---- + + @Test + void keywordBinNameWithSIFilter() { + List indexes = List.of( + Index.builder().namespace(NAMESPACE).bin("and").indexType(IndexType.NUMERIC).binValuesRatio(1).build() + ); + IndexContext indexCtx = IndexContext.of(NAMESPACE, indexes); + parseFilterAndCompare(ExpressionContext.of("$.and == 1"), indexCtx, + Filter.equal("and", 1)); + } } diff --git a/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java b/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java index c2c52e8a..f1030859 100644 --- a/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java +++ b/src/test/java/com/aerospike/ael/parsedExpression/PlaceholdersTests.java @@ -366,4 +366,36 @@ void blobPlaceholderInBlobList() { ExpressionContext.of("$.b.get(type: BLOB) IN ?0", PlaceholderValues.of(list)))); assertThat(actual).isNotNull(); } + + // ---- Placeholder integration with naming features ---- + + @Test + void intMapKeyWithPlaceholder() { + Exp exp = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, + Exp.val(55L), Exp.mapBin("bin")), + Exp.val(10)); + TestUtils.parseAelExpressionAndCompare( + ExpressionContext.of("$.bin.55 == ?0", PlaceholderValues.of(10)), + null, exp); + } + + @Test + void atBinWithPlaceholder() { + Exp exp = Exp.eq(Exp.intBin("name@host"), Exp.val(42)); + TestUtils.parseAelExpressionAndCompare( + ExpressionContext.of("$.name@host == ?0", PlaceholderValues.of(42)), + null, exp); + } + + @Test + void signedMapKeyWithPlaceholder() { + Exp exp = Exp.eq( + MapExp.getByKey(MapReturnType.VALUE, Exp.Type.STRING, + Exp.val(-100L), Exp.mapBin("bin")), + Exp.val("test")); + TestUtils.parseAelExpressionAndCompare( + ExpressionContext.of("$.bin.-100 == ?0", PlaceholderValues.of("test")), + null, exp); + } } From 50708393cbf33c9c0eb0c20f1e258147563b68dd Mon Sep 17 00:00:00 2001 From: Andrey G Date: Fri, 24 Apr 2026 16:38:46 +0200 Subject: [PATCH 3/6] Add support for Strings and BLOB in value range --- .../ael/parts/cdt/list/ListValueRange.java | 24 +++-- .../ael/parts/cdt/map/MapValueRange.java | 24 +++-- .../com/aerospike/ael/util/ParsingUtils.java | 35 +++---- .../ael/expression/ListExpressionsTests.java | 92 +++++++++++++++++++ .../ael/expression/MapExpressionsTests.java | 92 +++++++++++++++++++ 5 files changed, 232 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java index 461536c7..426afba6 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java @@ -8,15 +8,21 @@ import com.aerospike.ael.client.exp.ListExp; import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class ListValueRange extends ListPart { private final boolean isInverted; - private final Integer start; - private final Integer end; + private final Object start; + private final Object end; - public ListValueRange(boolean isInverted, Integer start, Integer end) { + public ListValueRange(boolean isInverted, Object start, Object end) { super(ListPartType.VALUE_RANGE); + requireSupportedExpValue(start, "ListValueRange start"); + if (end != null) { + requireSupportedExpValue(end, "ListValueRange end"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -31,11 +37,11 @@ public static ListValueRange from(ConditionParser.ListValueRangeContext ctx) { valueRange != null ? valueRange.valueRangeIdentifier() : invertedValueRange.valueRangeIdentifier(); boolean isInverted = valueRange == null; - Integer startValue = requireIntValueIdentifier(range.valueIdentifier(0)); + Object startValue = parseValueIdentifier(range.valueIdentifier(0)); - Integer endValue = null; + Object endValue = null; if (range.valueIdentifier(1) != null) { - endValue = requireIntValueIdentifier(range.valueIdentifier(1)); + endValue = parseValueIdentifier(range.valueIdentifier(1)); } return new ListValueRange(isInverted, startValue, endValue); @@ -49,8 +55,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | ListReturnType.INVERTED; } - Exp startExp = Exp.val(start); - Exp endExp = end != null ? Exp.val(end) : null; + Exp startExp = objectToExp(start); + Exp endExp = end != null ? objectToExp(end) : null; return ListExp.getByValueRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java index b6230238..0989e1b1 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java @@ -8,15 +8,21 @@ import com.aerospike.ael.client.exp.MapExp; import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class MapValueRange extends MapPart { private final boolean isInverted; - private final Integer start; - private final Integer end; + private final Object start; + private final Object end; - public MapValueRange(boolean isInverted, Integer start, Integer end) { + public MapValueRange(boolean isInverted, Object start, Object end) { super(MapPartType.VALUE_RANGE); + requireSupportedExpValue(start, "MapValueRange start"); + if (end != null) { + requireSupportedExpValue(end, "MapValueRange end"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -31,11 +37,11 @@ public static MapValueRange from(ConditionParser.MapValueRangeContext ctx) { valueRange != null ? valueRange.valueRangeIdentifier() : invertedValueRange.valueRangeIdentifier(); boolean isInverted = valueRange == null; - Integer startValue = requireIntValueIdentifier(range.valueIdentifier(0)); + Object startValue = parseValueIdentifier(range.valueIdentifier(0)); - Integer endValue = null; + Object endValue = null; if (range.valueIdentifier(1) != null) { - endValue = requireIntValueIdentifier(range.valueIdentifier(1)); + endValue = parseValueIdentifier(range.valueIdentifier(1)); } return new MapValueRange(isInverted, startValue, endValue); @@ -49,8 +55,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = Exp.val(start); - Exp endExp = end != null ? Exp.val(end) : null; + Exp startExp = objectToExp(start); + Exp endExp = end != null ? objectToExp(end) : null; return MapExp.getByValueRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/util/ParsingUtils.java b/src/main/java/com/aerospike/ael/util/ParsingUtils.java index 968e7c08..de99ccd8 100644 --- a/src/main/java/com/aerospike/ael/util/ParsingUtils.java +++ b/src/main/java/com/aerospike/ael/util/ParsingUtils.java @@ -203,23 +203,6 @@ public static byte[] parseB64ToBytes(String text) { } } - /** - * Parses a {@code valueIdentifier} context and requires the result to be an {@link Integer}. - * Used by value-range elements where only integer operands are valid. - * - * @param ctx The valueIdentifier context from the parser - * @return The parsed integer value - * @throws AelParseException if the parsed value is not an integer - */ - public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierContext ctx) { - Object result = parseValueIdentifier(ctx); - if (result instanceof Integer intValue) { - return intValue; - } - throw new AelParseException( - "Value range requires integer operands, got: %s".formatted(ctx.getText())); - } - /** * Converts a parsed value object to an {@link Exp} value expression. * Supports {@link String}, {@link Long}, {@link Integer}, and {@code byte[]}. @@ -237,6 +220,24 @@ public static Exp objectToExp(Object value) { "Unsupported value type for Exp conversion: " + value.getClass().getSimpleName()); } + /** + * Validates that a value is a supported type for {@link #objectToExp}: String, Integer, Long, or byte[]. + * + * @param value The value to check + * @param context Description for the error message (e.g. "MapValueRange start") + * @throws AelParseException if value is null or not a supported type + */ + public static void requireSupportedExpValue(Object value, String context) { + if (value == null) { + throw new AelParseException("Null value in %s".formatted(context)); + } + if (!(value instanceof String) && !(value instanceof Integer) + && !(value instanceof Long) && !(value instanceof byte[])) { + throw new AelParseException( + "Unsupported value type in %s: %s".formatted(context, value.getClass().getSimpleName())); + } + } + /** * Get the string inside the quotes. * diff --git a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java index defcb058..ca599fc1 100644 --- a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java @@ -401,6 +401,98 @@ void listValueRange() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=111:]"), expected); } + @Test + void listValueRangeStrUnquoted() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("aaa"), + Exp.val("zzz"), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=aaa:zzz]"), expected); + } + + @Test + void listValueRangeStrSingleQuoted() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("hello"), + Exp.val("world"), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[='hello':'world']"), expected); + } + + @Test + void listValueRangeStrDoubleQuoted() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("hello"), + Exp.val("world"), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=\"hello\":\"world\"]"), expected); + } + + @Test + void listValueRangeStrOpenEnded() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("hello"), + null, + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[='hello':]"), expected); + } + + @Test + void listValueRangeStrInverted() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE | ListReturnType.INVERTED, + Exp.val("hello"), + Exp.val("world"), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[!='hello':'world']"), expected); + } + + @Test + void listValueRangeMixedTypes() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("abc"), + Exp.val(999), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=abc:999]"), expected); + } + + @Test + void listValueRangeBlob() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val(new byte[]{0x0A}), + Exp.val(new byte[]{(byte) 0xFF}), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=X'0A':X'FF']"), expected); + } + + @Test + void listValueRangeBlobB64() { + byte[] start = java.util.Base64.getDecoder().decode("AAAA"); + byte[] end = java.util.Base64.getDecoder().decode("////"); + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val(start), + Exp.val(end), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=b64'AAAA':b64'////']"), expected); + } + + @Test + void listValueRangeInKeyword() { + Exp expected = ListExp.getByValueRange( + ListReturnType.VALUE, + Exp.val("in"), + Exp.val("out"), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=in:out]"), expected); + } + @Test void listRankRange() { Exp expected = ListExp.getByRankRange( diff --git a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java index ea72ed62..c6c2c196 100644 --- a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java @@ -510,6 +510,98 @@ void mapValueRange() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=111:}"), expected); } + @Test + void mapValueRangeStrUnquoted() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("aaa"), + Exp.val("zzz"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=aaa:zzz}"), expected); + } + + @Test + void mapValueRangeStrSingleQuoted() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("hello"), + Exp.val("world"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{='hello':'world'}"), expected); + } + + @Test + void mapValueRangeStrDoubleQuoted() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("hello"), + Exp.val("world"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=\"hello\":\"world\"}"), expected); + } + + @Test + void mapValueRangeStrOpenEnded() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("hello"), + null, + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{='hello':}"), expected); + } + + @Test + void mapValueRangeStrInverted() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + Exp.val("hello"), + Exp.val("world"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{!='hello':'world'}"), expected); + } + + @Test + void mapValueRangeMixedTypes() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("abc"), + Exp.val(999), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=abc:999}"), expected); + } + + @Test + void mapValueRangeBlob() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val(new byte[]{0x0A}), + Exp.val(new byte[]{(byte) 0xFF}), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=X'0A':X'FF'}"), expected); + } + + @Test + void mapValueRangeBlobB64() { + byte[] start = java.util.Base64.getDecoder().decode("AAAA"); + byte[] end = java.util.Base64.getDecoder().decode("////"); + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val(start), + Exp.val(end), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=b64'AAAA':b64'////'}"), expected); + } + + @Test + void mapValueRangeInKeyword() { + Exp expected = MapExp.getByValueRange( + MapReturnType.VALUE, + Exp.val("in"), + Exp.val("out"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=in:out}"), expected); + } + @Test void mapRankRange() { Exp expected = MapExp.getByRankRange( From dd7c1d027597814fa804af7a50de748a24b2a0a1 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Tue, 28 Apr 2026 00:52:10 +0200 Subject: [PATCH 4/6] Modify supporting Strings and BLOB for value range based on updated main branch --- src/main/antlr4/com/aerospike/ael/Condition.g4 | 6 +++--- .../com/aerospike/ael/parts/cdt/list/ListValueRange.java | 4 +++- .../java/com/aerospike/ael/parts/cdt/map/MapValueRange.java | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/antlr4/com/aerospike/ael/Condition.g4 b/src/main/antlr4/com/aerospike/ael/Condition.g4 index 3457b3eb..fdfaa711 100644 --- a/src/main/antlr4/com/aerospike/ael/Condition.g4 +++ b/src/main/antlr4/com/aerospike/ael/Condition.g4 @@ -1,7 +1,7 @@ grammar Condition; @header { - package com.aerospike.dsl; + package com.aerospike.ael; } parse: expression EOF; @@ -170,10 +170,10 @@ pathOrMetadata: path | metadata; path: basePath ('.' pathFunction)?; -basePath: binPart (('.' (mapPart | listPart)) | pathIntMapKey | pathStringMapKey)*?; +basePath: binPart (('.' (mapPart | listPart)) | pathIntMapKey | pathHexBinaryMapKey)*?; pathIntMapKey: LEADING_DOT_FLOAT | LEADING_DOT_SIGNED_INT; -pathStringMapKey: LEADING_DOT_FLOAT_HEX_OR_BINARY; +pathHexBinaryMapKey: LEADING_DOT_FLOAT_HEX_OR_BINARY; metadata: METADATA_FUNCTION; diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java index a5a36f09..426afba6 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java @@ -8,7 +8,9 @@ import com.aerospike.ael.client.exp.ListExp; import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class ListValueRange extends ListPart { private final boolean isInverted; diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java index bbdc18eb..0989e1b1 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java @@ -8,7 +8,9 @@ import com.aerospike.ael.client.exp.MapExp; import com.aerospike.ael.parts.path.BasePath; -import static com.aerospike.ael.util.ParsingUtils.requireIntValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; +import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class MapValueRange extends MapPart { private final boolean isInverted; From 54b946dc072edc4b574d00198d7a798dd32e4f82 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Tue, 28 Apr 2026 01:18:27 +0200 Subject: [PATCH 5/6] Widen value identifiers from int to long --- .../com/aerospike/ael/util/ParsingUtils.java | 68 +++++++++++--- .../ael/expression/ListExpressionsTests.java | 28 +++++- .../ael/expression/MapExpressionsTests.java | 28 +++++- .../aerospike/ael/util/ParsingUtilsTests.java | 94 +++++++++++++++++++ 4 files changed, 203 insertions(+), 15 deletions(-) create mode 100644 src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java diff --git a/src/main/java/com/aerospike/ael/util/ParsingUtils.java b/src/main/java/com/aerospike/ael/util/ParsingUtils.java index 75afb79a..47a65b3c 100644 --- a/src/main/java/com/aerospike/ael/util/ParsingUtils.java +++ b/src/main/java/com/aerospike/ael/util/ParsingUtils.java @@ -16,6 +16,8 @@ public class ParsingUtils { private static final BigInteger LONG_MIN_ABS = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE); private static final BigInteger INT_MIN_VALUE = BigInteger.valueOf(Integer.MIN_VALUE); private static final BigInteger INT_MAX_VALUE = BigInteger.valueOf(Integer.MAX_VALUE); + private static final BigInteger LONG_MIN_VALUE = BigInteger.valueOf(Long.MIN_VALUE); + private static final BigInteger LONG_MAX_VALUE = BigInteger.valueOf(Long.MAX_VALUE); /** * Extracts a signed integer value from a {@code signedInt} parser rule context. @@ -37,6 +39,25 @@ public static int parseSignedInt(ConditionParser.SignedIntContext ctx) { return signedValue.intValue(); } + /** + * Extracts a signed long value from a {@code signedInt} parser rule context. + * Same grammar rule as {@link #parseSignedInt} ({@code signedInt: '-'? INT;}), + * but validates against the full 64-bit signed range. + * + * @param ctx The signedInt context from the parser + * @return The parsed long value, negated if a '-' prefix is present + */ + public static long parseSignedLong(ConditionParser.SignedIntContext ctx) { + String intText = ctx.INT().getText(); + boolean isNegative = ctx.getText().startsWith("-"); + BigInteger value = parseUnsignedIntegerLiteral(intText); + BigInteger signedValue = isNegative ? value.negate() : value; + if (signedValue.compareTo(LONG_MIN_VALUE) < 0 || signedValue.compareTo(LONG_MAX_VALUE) > 0) { + throw new AelParseException("Signed integer literal out of range for LONG: " + ctx.getText()); + } + return signedValue.longValue(); + } + /** * Parses an unsigned INT token (decimal, hex or binary) into a long value. * The value range is [0, 2^63], where 2^63 is represented as {@link Long#MIN_VALUE}. @@ -136,10 +157,11 @@ public static long parseLongMapKey(String text) { /** * Extracts a typed value from a {@code valueIdentifier} parser rule context. - * Handles NAME_IDENTIFIER, QUOTED_STRING, IN keyword (as literal text), and signedInt. + * Handles NAME_IDENTIFIER, QUOTED_STRING, IN keyword (as literal text), signedInt, + * BLOB_LITERAL, and B64_LITERAL. * * @param ctx The valueIdentifier context from the parser - * @return The parsed value as String or Integer + * @return The parsed value as String, Long, or byte[] */ public static Object parseValueIdentifier(ConditionParser.ValueIdentifierContext ctx) { String result = resolveStringToken(ctx); @@ -147,7 +169,7 @@ public static Object parseValueIdentifier(ConditionParser.ValueIdentifierContext return result; } if (ctx.signedInt() != null) { - return parseSignedInt(ctx.signedInt()); + return parseSignedLong(ctx.signedInt()); } TerminalNode blobLiteral = ctx.getToken(ConditionParser.BLOB_LITERAL, 0); if (blobLiteral != null) { @@ -186,17 +208,20 @@ public static byte[] parseB64ToBytes(String text) { } /** - * Parses a {@code valueIdentifier} context and requires the result to be an {@link Integer}. - * Used by value-range elements where only integer operands are valid. + * Parses a {@code valueIdentifier} context and requires the result to be an integer ({@link Long}). + *

    + * Note: currently unused — value-range elements now accept any type supported by + * {@link #objectToExp}. Retained for potential future use. * * @param ctx The valueIdentifier context from the parser - * @return The parsed integer value + * @return The parsed long value * @throws AelParseException if the parsed value is not an integer */ - public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierContext ctx) { + @SuppressWarnings("unused") + public static long requireIntValueIdentifier(ConditionParser.ValueIdentifierContext ctx) { Object result = parseValueIdentifier(ctx); - if (result instanceof Integer intValue) { - return intValue; + if (result instanceof Long longValue) { + return longValue; } throw new AelParseException( "Value range requires integer operands, got: %s".formatted(ctx.getText())); @@ -208,9 +233,13 @@ public static Integer requireIntValueIdentifier(ConditionParser.ValueIdentifierC * * @param value The parsed value object * @return The corresponding {@link Exp} value expression - * @throws AelParseException if the value type is not supported + * @throws AelParseException if the value is null or its type is not supported + * @see #isSupportedExpType(Object) */ public static Exp objectToExp(Object value) { + if (value == null) { + throw new AelParseException("Cannot convert null to Exp"); + } if (value instanceof String s) return Exp.val(s); if (value instanceof Long l) return Exp.val(l); if (value instanceof Integer i) return Exp.val(i); @@ -220,18 +249,31 @@ public static Exp objectToExp(Object value) { } /** - * Validates that a value is a supported type for {@link #objectToExp}: String, Integer, Long, or byte[]. + * Checks whether a value is one of the types supported by {@link #objectToExp}: + * {@link String}, {@link Integer}, {@link Long}, or {@code byte[]}. + */ + private static boolean isSupportedExpType(Object value) { + return value instanceof String || value instanceof Integer + || value instanceof Long || value instanceof byte[]; + } + + /** + * Validates that a value is a supported type for {@link #objectToExp}. + *

    + * Accepts {@link String}, {@link Integer}, {@link Long}, and {@code byte[]}. + * Both {@link #parseValueIdentifier} and {@link #parseMapKey} return {@link Long} for + * numeric values; {@link Integer} is kept for robustness when values are constructed directly. * * @param value The value to check * @param context Description for the error message (e.g. "MapValueRange start") * @throws AelParseException if value is null or not a supported type + * @see #isSupportedExpType(Object) */ public static void requireSupportedExpValue(Object value, String context) { if (value == null) { throw new AelParseException("Null value in %s".formatted(context)); } - if (!(value instanceof String) && !(value instanceof Integer) - && !(value instanceof Long) && !(value instanceof byte[])) { + if (!isSupportedExpType(value)) { throw new AelParseException( "Unsupported value type in %s: %s".formatted(context, value.getClass().getSimpleName())); } diff --git a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java index 8d247520..80dbbb9c 100644 --- a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java @@ -526,7 +526,7 @@ void listValueRangeBlob() { } @Test - void listValueRangeBlobB64() { + void listValueRangeBase64Blob() { byte[] start = java.util.Base64.getDecoder().decode("AAAA"); byte[] end = java.util.Base64.getDecoder().decode("////"); Exp expected = ListExp.getByValueRange( @@ -547,6 +547,32 @@ void listValueRangeInKeyword() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=in:out]"), expected); } + @Test + void negListValueRangeFloat() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=1.5:2.5]"))) + .isInstanceOf(AelParseException.class); + } + + @Test + void negListValueRangeBoolean() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=true:false]"))) + .isInstanceOf(AelParseException.class); + } + + @Test + void negListValueRangeOddHexBlob() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=X'f':X'ff']"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("even number of hex characters"); + } + + @Test + void negListValueRangeInvalidB64() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.listBin1.[=b64'A':b64'AQID']"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Base64 BLOB literal contains invalid Base64 content"); + } + @Test void listRankRange() { Exp expected = ListExp.getByRankRange( diff --git a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java index d7929c44..6de4bfea 100644 --- a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java @@ -635,7 +635,7 @@ void mapValueRangeBlob() { } @Test - void mapValueRangeBlobB64() { + void mapValueRangeBase64Blob() { byte[] start = java.util.Base64.getDecoder().decode("AAAA"); byte[] end = java.util.Base64.getDecoder().decode("////"); Exp expected = MapExp.getByValueRange( @@ -656,6 +656,32 @@ void mapValueRangeInKeyword() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=in:out}"), expected); } + @Test + void negMapValueRangeFloat() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=1.5:2.5}"))) + .isInstanceOf(AelParseException.class); + } + + @Test + void negMapValueRangeBoolean() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=true:false}"))) + .isInstanceOf(AelParseException.class); + } + + @Test + void negMapValueRangeOddHexBlob() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=X'f':X'ff'}"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("even number of hex characters"); + } + + @Test + void negMapValueRangeInvalidB64() { + assertThatThrownBy(() -> parseFilterExp(ExpressionContext.of("$.mapBin1.{=b64'A':b64'AQID'}"))) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Base64 BLOB literal contains invalid Base64 content"); + } + @Test void mapRankRange() { Exp expected = MapExp.getByRankRange( diff --git a/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java b/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java new file mode 100644 index 00000000..eb533f23 --- /dev/null +++ b/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java @@ -0,0 +1,94 @@ +package com.aerospike.ael.util; + +import com.aerospike.ael.AelParseException; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.aerospike.ael.util.ParsingUtils.objectToExp; +import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +class ParsingUtilsTests { + + @Nested + class RequireSupportedExpValue { + + @Test + void acceptsString() { + assertThatNoException() + .isThrownBy(() -> requireSupportedExpValue("hello", "test")); + } + + @Test + void acceptsInteger() { + assertThatNoException() + .isThrownBy(() -> requireSupportedExpValue(42, "test")); + } + + @Test + void acceptsLong() { + assertThatNoException() + .isThrownBy(() -> requireSupportedExpValue(42L, "test")); + } + + @Test + void acceptsByteArray() { + assertThatNoException() + .isThrownBy(() -> requireSupportedExpValue(new byte[]{1, 2}, "test")); + } + + @Test + @SuppressWarnings("DataFlowIssue") + void rejectsNull() { + assertThatThrownBy(() -> requireSupportedExpValue(null, "ctx")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Null value in ctx"); + } + + @Test + void rejectsDouble() { + assertThatThrownBy(() -> requireSupportedExpValue(3.14, "ctx")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Unsupported value type in ctx") + .hasMessageContaining("Double"); + } + + @Test + void rejectsBoolean() { + assertThatThrownBy(() -> requireSupportedExpValue(true, "ctx")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Unsupported value type in ctx") + .hasMessageContaining("Boolean"); + } + + @Test + void rejectsList() { + assertThatThrownBy(() -> requireSupportedExpValue(List.of(1), "ctx")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Unsupported value type in ctx"); + } + } + + @Nested + class ObjectToExp { + + @Test + @SuppressWarnings("DataFlowIssue") + void rejectsNull() { + assertThatThrownBy(() -> objectToExp(null)) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Cannot convert null to Exp"); + } + + @Test + void rejectsUnsupportedType() { + assertThatThrownBy(() -> objectToExp(3.14)) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Unsupported value type for Exp conversion") + .hasMessageContaining("Double"); + } + } +} From 2bacc84fd85877190eb2b3c909319e62dde72732 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Wed, 29 Apr 2026 19:07:58 +0200 Subject: [PATCH 6/6] Support half-open CDT ranges, map keys range and map indexes range collision to be resolved --- README.md | 6 ++ docs/api-reference.md | 10 +++ docs/guides/02-working-with-lists-and-maps.md | 10 +++ .../antlr4/com/aerospike/ael/Condition.g4 | 8 +- .../ael/parts/cdt/list/ListIndexRange.java | 14 ++-- .../ael/parts/cdt/list/ListRankRange.java | 14 ++-- .../parts/cdt/list/ListRankRangeRelative.java | 12 +-- .../ael/parts/cdt/list/ListValueRange.java | 22 ++--- .../ael/parts/cdt/map/MapIndexRange.java | 14 ++-- .../parts/cdt/map/MapIndexRangeRelative.java | 9 +- .../ael/parts/cdt/map/MapKeyRange.java | 20 ++--- .../ael/parts/cdt/map/MapRankRange.java | 14 ++-- .../parts/cdt/map/MapRankRangeRelative.java | 12 +-- .../ael/parts/cdt/map/MapValueRange.java | 22 ++--- .../com/aerospike/ael/util/ParsingUtils.java | 68 +++++++++++++-- .../java/com/aerospike/ael/ctx/CtxTests.java | 16 ++++ .../ael/expression/ListExpressionsTests.java | 53 ++++++++++++ .../ael/expression/MapExpressionsTests.java | 82 ++++++++++++++++++- .../ael/expression/MapKeyTypingTests.java | 7 ++ .../aerospike/ael/util/ParsingUtilsTests.java | 55 +++++++++++++ 20 files changed, 379 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index f6e5ffaf..1e4d1a09 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ When modifying the grammar file you will need to re-generate the ANTLR sources b `mvn clean generate-sources compile` +## CDT ranges + +Map and list path segments support closed-boundaries and half-open ranges. +Semantics follow Aerospike CDT conventions (inclusive lower / exclusive upper for keys and values where applicable). +See [Guide: Working with Lists and Maps — CDT ranges](docs/guides/02-working-with-lists-and-maps.md#cdt-ranges). + ## Usage examples ### Parsing AEL expression diff --git a/docs/api-reference.md b/docs/api-reference.md index b590b562..004b88d9 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -78,6 +78,16 @@ Represents an available secondary index for optimization. * Must be non-negative (`>= 0`). * Providing a realistic, non-negative cardinality value is recommended for better automatic index selection (indexes with higher `binValuesRatio` are preferred). +## CDT path segments and ranges + +Expressions may use **closed-boundaries** and **half-open CDT ranges** on maps and lists. Details in the +[Guide: Working with Lists and Maps — CDT ranges](guides/02-working-with-lists-and-maps.md#cdt-ranges). + +The **`parseCTX`** API accepts the same surface syntax as paths embedded in expressions, +but **only simple selectors** produce `CTX[]` (single key, index, value, rank, etc.). +**Range segments** (index/value/key intervals) are not converted to context entries and will fail with an error +indicating that context is not supported for that part type. + ## Example API Flow Here is a recap of how the classes work together in a typical use case: diff --git a/docs/guides/02-working-with-lists-and-maps.md b/docs/guides/02-working-with-lists-and-maps.md index 6878a188..441fd078 100644 --- a/docs/guides/02-working-with-lists-and-maps.md +++ b/docs/guides/02-working-with-lists-and-maps.md @@ -83,6 +83,16 @@ Or use the full form of such AEL string if needed: "$.user.{0}.get(type: STRING, return: VALUE) == 'Alice'" ``` +#### CDT ranges + +Beyond a single index, you can express **intervals** on CDT keys, values, indexes, and ranks using closed-boundaries +or half-open ranges: + +- **Map key range** — `{a-c}` selects keys from `a` up to but not including `c`; `{a-}` is open on the upper side; `{-c}` is open on the lower side (all keys strictly below `c`). +- **Map index / rank range** — `{s:e}` selects index/rank span `[s, e)`; `{s:}` is open on the upper side; `{:e}` is open on the lower side (same span as `{0:e}`). +- **Map value range** — `{=v:w}`, `{=v:}`, `{=:w}` follow inclusive/exclusive value endpoints per `getByValueRange`. +- **Lists** — the same shapes use square brackets (`[…]`) instead of braces. + ### Filtering by Map Value **AEL String:** diff --git a/src/main/antlr4/com/aerospike/ael/Condition.g4 b/src/main/antlr4/com/aerospike/ael/Condition.g4 index fdfaa711..4403d4d6 100644 --- a/src/main/antlr4/com/aerospike/ael/Condition.g4 +++ b/src/main/antlr4/com/aerospike/ael/Condition.g4 @@ -265,8 +265,8 @@ mapPart | mapKey | mapValue | mapRank - | mapIndex | mapKeyRange + | mapIndex | mapKeyList | mapIndexRange | mapValueList @@ -309,6 +309,7 @@ invertedMapKeyRange keyRangeIdentifier : mapKey '-' mapKey | mapKey '-' + | '-' mapKey ; mapKeyList @@ -344,6 +345,7 @@ invertedMapIndexRange indexRangeIdentifier : start ':' end | start ':' + | ':' end ; signedInt: '-'? INT; @@ -380,6 +382,7 @@ invertedMapValueRange valueRangeIdentifier : valueIdentifier ':' valueIdentifier | valueIdentifier ':' + | ':' valueIdentifier ; mapRankRange @@ -398,6 +401,7 @@ invertedMapRankRange rankRangeIdentifier : start ':' end | start ':' + | ':' end ; mapRankRangeRelative @@ -415,6 +419,7 @@ invertedMapRankRangeRelative rankRangeRelativeIdentifier : start ':' relativeRankEnd + | ':' relativeRankEnd ; relativeRankEnd @@ -441,6 +446,7 @@ invertedMapIndexRangeRelative indexRangeRelativeIdentifier : start ':' relativeKeyEnd + | ':' relativeKeyEnd ; relativeKeyEnd diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java index 3de9d5e5..fafe530f 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListIndexRange.java @@ -8,8 +8,8 @@ import com.aerospike.ael.client.exp.ListExp; import com.aerospike.ael.parts.path.BasePath; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListIndexRange extends ListPart { private final boolean isInverted; @@ -20,7 +20,7 @@ public ListIndexRange(boolean isInverted, Integer start, Integer end) { super(ListPartType.INDEX_RANGE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); } public static ListIndexRange from(ConditionParser.ListIndexRangeContext ctx) { @@ -32,11 +32,8 @@ public static ListIndexRange from(ConditionParser.ListIndexRangeContext ctx) { indexRange != null ? indexRange.indexRangeIdentifier() : invertedIndexRange.indexRangeIdentifier(); boolean isInverted = indexRange == null; - Integer start = parseSignedInt(range.start().signedInt()); - Integer end = null; - if (range.end() != null) { - end = parseSignedInt(range.end().signedInt()); - } + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; + Integer end = range.end() != null ? parseSignedInt(range.end().signedInt()) : null; return new ListIndexRange(isInverted, start, end); } @@ -49,7 +46,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | ListReturnType.INVERTED; } - Exp startExp = Exp.val(start); + int startIndex = start != null ? start : 0; + Exp startExp = Exp.val(startIndex); if (count == null) { return ListExp.getByIndexRange(cdtReturnType, startExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java index 56d7d983..e193fa99 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRange.java @@ -8,8 +8,8 @@ import com.aerospike.ael.client.exp.ListExp; import com.aerospike.ael.parts.path.BasePath; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListRankRange extends ListPart { private final boolean isInverted; @@ -20,7 +20,7 @@ public ListRankRange(boolean isInverted, Integer start, Integer end) { super(ListPartType.RANK_RANGE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); } public static ListRankRange from(ConditionParser.ListRankRangeContext ctx) { @@ -32,11 +32,8 @@ public static ListRankRange from(ConditionParser.ListRankRangeContext ctx) { rankRange != null ? rankRange.rankRangeIdentifier() : invertedRankRange.rankRangeIdentifier(); boolean isInverted = rankRange == null; - Integer start = parseSignedInt(range.start().signedInt()); - Integer end = null; - if (range.end() != null) { - end = parseSignedInt(range.end().signedInt()); - } + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; + Integer end = range.end() != null ? parseSignedInt(range.end().signedInt()) : null; return new ListRankRange(isInverted, start, end); } @@ -49,7 +46,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | ListReturnType.INVERTED; } - Exp startExp = Exp.val(start); + int startRank = start != null ? start : 0; + Exp startExp = Exp.val(startRank); if (count == null) { return ListExp.getByRankRange(cdtReturnType, startExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java index e850137c..d98f2c5d 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListRankRangeRelative.java @@ -9,9 +9,9 @@ import com.aerospike.ael.parts.path.BasePath; import com.aerospike.ael.util.ParsingUtils; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.objectToExp; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class ListRankRangeRelative extends ListPart { private final boolean isInverted; @@ -23,7 +23,7 @@ public ListRankRangeRelative(boolean isInverted, Integer start, Integer end, Obj super(ListPartType.RANK_RANGE_RELATIVE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); this.relative = relative; } @@ -37,7 +37,7 @@ public static ListRankRangeRelative from(ConditionParser.ListRankRangeRelativeCo : invertedRankRangeRelative.rankRangeRelativeIdentifier(); boolean isInverted = rankRangeRelative == null; - Integer start = parseSignedInt(range.start().signedInt()); + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; Integer end = null; if (range.relativeRankEnd().end() != null) { end = parseSignedInt(range.relativeRankEnd().end().signedInt()); @@ -62,14 +62,14 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType Exp relativeExp = objectToExp(relative); - Exp startExp = Exp.val(start); + Exp valueExp = Exp.val(start != null ? start : 0); if (count == null) { - return ListExp.getByValueRelativeRankRange(cdtReturnType, startExp, relativeExp, + return ListExp.getByValueRelativeRankRange(cdtReturnType, valueExp, relativeExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); } - return ListExp.getByValueRelativeRankRange(cdtReturnType, startExp, relativeExp, Exp.val(count), + return ListExp.getByValueRelativeRankRange(cdtReturnType, valueExp, relativeExp, Exp.val(count), Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); } diff --git a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java index 426afba6..298b7d1e 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/list/ListValueRange.java @@ -8,8 +8,9 @@ import com.aerospike.ael.client.exp.ListExp; import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.util.ParsingUtils; + import static com.aerospike.ael.util.ParsingUtils.objectToExp; -import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class ListValueRange extends ListPart { @@ -19,10 +20,15 @@ public class ListValueRange extends ListPart { public ListValueRange(boolean isInverted, Object start, Object end) { super(ListPartType.VALUE_RANGE); - requireSupportedExpValue(start, "ListValueRange start"); + if (start != null) { + requireSupportedExpValue(start, "ListValueRange start"); + } if (end != null) { requireSupportedExpValue(end, "ListValueRange end"); } + if (start == null && end == null) { + throw new AelParseException("ListValueRange requires at least one bound"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -37,14 +43,8 @@ public static ListValueRange from(ConditionParser.ListValueRangeContext ctx) { valueRange != null ? valueRange.valueRangeIdentifier() : invertedValueRange.valueRangeIdentifier(); boolean isInverted = valueRange == null; - Object startValue = parseValueIdentifier(range.valueIdentifier(0)); - - Object endValue = null; - if (range.valueIdentifier(1) != null) { - endValue = parseValueIdentifier(range.valueIdentifier(1)); - } - - return new ListValueRange(isInverted, startValue, endValue); + ParsingUtils.NullableEndpoints bounds = ParsingUtils.parseValueRangeEndpoints(range); + return new ListValueRange(isInverted, bounds.start(), bounds.end()); } throw new AelParseException("Could not translate ListValueRange from ctx: %s".formatted(ctx)); } @@ -55,7 +55,7 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | ListReturnType.INVERTED; } - Exp startExp = objectToExp(start); + Exp startExp = start != null ? objectToExp(start) : null; Exp endExp = end != null ? objectToExp(end) : null; return ListExp.getByValueRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java index b56ce548..4f540ca1 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRange.java @@ -8,8 +8,8 @@ import com.aerospike.ael.client.exp.MapExp; import com.aerospike.ael.parts.path.BasePath; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapIndexRange extends MapPart { private final boolean isInverted; @@ -20,7 +20,7 @@ public MapIndexRange(boolean isInverted, Integer start, Integer end) { super(MapPartType.INDEX_RANGE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); } public static MapIndexRange from(ConditionParser.MapIndexRangeContext ctx) { @@ -32,11 +32,8 @@ public static MapIndexRange from(ConditionParser.MapIndexRangeContext ctx) { indexRange != null ? indexRange.indexRangeIdentifier() : invertedIndexRange.indexRangeIdentifier(); boolean isInverted = indexRange == null; - Integer start = parseSignedInt(range.start().signedInt()); - Integer end = null; - if (range.end() != null) { - end = parseSignedInt(range.end().signedInt()); - } + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; + Integer end = range.end() != null ? parseSignedInt(range.end().signedInt()) : null; return new MapIndexRange(isInverted, start, end); } @@ -49,7 +46,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = Exp.val(start); + int startIndex = start != null ? start : 0; + Exp startExp = Exp.val(startIndex); if (count == null) { return MapExp.getByIndexRange(cdtReturnType, startExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java index c47c631c..7c5525ea 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapIndexRangeRelative.java @@ -10,8 +10,8 @@ import com.aerospike.ael.util.ParsingUtils; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapIndexRangeRelative extends MapPart { private final boolean isInverted; @@ -26,7 +26,7 @@ public MapIndexRangeRelative(boolean isInverted, Integer start, Integer end, Obj } this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); this.relative = relative; } @@ -40,7 +40,7 @@ public static MapIndexRangeRelative from(ConditionParser.MapIndexRangeRelativeCo : invertedIndexRangeRelative.indexRangeRelativeIdentifier(); boolean isInverted = indexRangeRelative == null; - Integer start = parseSignedInt(range.start().signedInt()); + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; Integer end = null; if (range.relativeKeyEnd().end() != null) { end = parseSignedInt(range.relativeKeyEnd().end().signedInt()); @@ -62,7 +62,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType } Exp keyExp = ParsingUtils.objectToExp(relative); - Exp startExp = Exp.val(start); + int startIndex = start != null ? start : 0; + Exp startExp = Exp.val(startIndex); if (count == null) { return MapExp.getByKeyRelativeIndexRange(cdtReturnType, keyExp, startExp, Exp.bin(basePath.getBinPart().getBinName(), diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java index 87024480..decd14a5 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapKeyRange.java @@ -10,8 +10,6 @@ import com.aerospike.ael.util.ParsingUtils; -import java.util.Optional; - public class MapKeyRange extends MapPart { private final boolean isInverted; private final Object start; @@ -19,10 +17,15 @@ public class MapKeyRange extends MapPart { public MapKeyRange(boolean isInverted, Object start, Object end) { super(MapPartType.KEY_RANGE); - requireSupportedKeyType(start, "MapKeyRange start"); + if (start != null) { + requireSupportedKeyType(start, "MapKeyRange start"); + } if (end != null) { requireSupportedKeyType(end, "MapKeyRange end"); } + if (start == null && end == null) { + throw new AelParseException("MapKeyRange requires at least one bound"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -37,13 +40,8 @@ public static MapKeyRange from(ConditionParser.MapKeyRangeContext ctx) { keyRange != null ? keyRange.keyRangeIdentifier() : invertedKeyRange.keyRangeIdentifier(); boolean isInverted = keyRange == null; - Object startKey = ParsingUtils.parseMapKey(range.mapKey(0)); - - Object endKey = Optional.ofNullable(range.mapKey(1)) - .map(ParsingUtils::parseMapKey) - .orElse(null); - - return new MapKeyRange(isInverted, startKey, endKey); + ParsingUtils.NullableEndpoints bounds = ParsingUtils.parseMapKeyRangeEndpoints(range); + return new MapKeyRange(isInverted, bounds.start(), bounds.end()); } throw new AelParseException("Could not translate MapKeyRange from ctx: %s".formatted(ctx)); } @@ -54,7 +52,7 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = ParsingUtils.objectToExp(start); + Exp startExp = start != null ? ParsingUtils.objectToExp(start) : null; Exp endExp = end != null ? ParsingUtils.objectToExp(end) : null; return MapExp.getByKeyRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java index df27f4c5..69a94ec9 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRange.java @@ -8,8 +8,8 @@ import com.aerospike.ael.client.exp.MapExp; import com.aerospike.ael.parts.path.BasePath; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapRankRange extends MapPart { private final boolean isInverted; @@ -20,7 +20,7 @@ public MapRankRange(boolean isInverted, Integer start, Integer end) { super(MapPartType.RANK_RANGE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); } public static MapRankRange from(ConditionParser.MapRankRangeContext ctx) { @@ -32,11 +32,8 @@ public static MapRankRange from(ConditionParser.MapRankRangeContext ctx) { rankRange != null ? rankRange.rankRangeIdentifier() : invertedRankRange.rankRangeIdentifier(); boolean isInverted = rankRange == null; - Integer start = parseSignedInt(range.start().signedInt()); - Integer end = null; - if (range.end() != null) { - end = parseSignedInt(range.end().signedInt()); - } + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; + Integer end = range.end() != null ? parseSignedInt(range.end().signedInt()) : null; return new MapRankRange(isInverted, start, end); } @@ -49,7 +46,8 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = Exp.val(start); + int startRank = start != null ? start : 0; + Exp startExp = Exp.val(startRank); if (count == null) { return MapExp.getByRankRange(cdtReturnType, startExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java index 36db2b66..f7ad9f58 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapRankRangeRelative.java @@ -9,9 +9,9 @@ import com.aerospike.ael.parts.path.BasePath; import com.aerospike.ael.util.ParsingUtils; +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.objectToExp; import static com.aerospike.ael.util.ParsingUtils.parseSignedInt; -import static com.aerospike.ael.util.ParsingUtils.subtractNullable; public class MapRankRangeRelative extends MapPart { private final boolean isInverted; @@ -23,7 +23,7 @@ public MapRankRangeRelative(boolean isInverted, Integer start, Integer end, Obje super(MapPartType.RANK_RANGE_RELATIVE); this.isInverted = isInverted; this.start = start; - this.count = subtractNullable(end, start); + this.count = halfOpenRangeCount(start, end); this.relative = relative; } @@ -37,7 +37,7 @@ public static MapRankRangeRelative from(ConditionParser.MapRankRangeRelativeCont : invertedRankRangeRelative.rankRangeRelativeIdentifier(); boolean isInverted = rankRangeRelative == null; - Integer start = parseSignedInt(range.start().signedInt()); + Integer start = range.start() != null ? parseSignedInt(range.start().signedInt()) : null; Integer end = null; if (range.relativeRankEnd().end() != null) { end = parseSignedInt(range.relativeRankEnd().end().signedInt()); @@ -62,13 +62,13 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType Exp relativeExp = objectToExp(relative); - Exp startExp = Exp.val(start); + Exp valueExp = Exp.val(start != null ? start : 0); if (count == null) { - return MapExp.getByValueRelativeRankRange(cdtReturnType, startExp, relativeExp, + return MapExp.getByValueRelativeRankRange(cdtReturnType, valueExp, relativeExp, Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); } - return MapExp.getByValueRelativeRankRange(cdtReturnType, startExp, relativeExp, Exp.val(count), + return MapExp.getByValueRelativeRankRange(cdtReturnType, valueExp, relativeExp, Exp.val(count), Exp.bin(basePath.getBinPart().getBinName(), basePath.getBinType()), context); } } diff --git a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java index 0989e1b1..0eeed134 100644 --- a/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java +++ b/src/main/java/com/aerospike/ael/parts/cdt/map/MapValueRange.java @@ -8,8 +8,9 @@ import com.aerospike.ael.client.exp.MapExp; import com.aerospike.ael.parts.path.BasePath; +import com.aerospike.ael.util.ParsingUtils; + import static com.aerospike.ael.util.ParsingUtils.objectToExp; -import static com.aerospike.ael.util.ParsingUtils.parseValueIdentifier; import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; public class MapValueRange extends MapPart { @@ -19,10 +20,15 @@ public class MapValueRange extends MapPart { public MapValueRange(boolean isInverted, Object start, Object end) { super(MapPartType.VALUE_RANGE); - requireSupportedExpValue(start, "MapValueRange start"); + if (start != null) { + requireSupportedExpValue(start, "MapValueRange start"); + } if (end != null) { requireSupportedExpValue(end, "MapValueRange end"); } + if (start == null && end == null) { + throw new AelParseException("MapValueRange requires at least one bound"); + } this.isInverted = isInverted; this.start = start; this.end = end; @@ -37,14 +43,8 @@ public static MapValueRange from(ConditionParser.MapValueRangeContext ctx) { valueRange != null ? valueRange.valueRangeIdentifier() : invertedValueRange.valueRangeIdentifier(); boolean isInverted = valueRange == null; - Object startValue = parseValueIdentifier(range.valueIdentifier(0)); - - Object endValue = null; - if (range.valueIdentifier(1) != null) { - endValue = parseValueIdentifier(range.valueIdentifier(1)); - } - - return new MapValueRange(isInverted, startValue, endValue); + ParsingUtils.NullableEndpoints bounds = ParsingUtils.parseValueRangeEndpoints(range); + return new MapValueRange(isInverted, bounds.start(), bounds.end()); } throw new AelParseException("Could not translate MapValueRange from ctx: %s".formatted(ctx)); } @@ -55,7 +55,7 @@ public Exp constructExp(BasePath basePath, Exp.Type valueType, int cdtReturnType cdtReturnType = cdtReturnType | MapReturnType.INVERTED; } - Exp startExp = objectToExp(start); + Exp startExp = start != null ? objectToExp(start) : null; Exp endExp = end != null ? objectToExp(end) : null; return MapExp.getByValueRange(cdtReturnType, startExp, endExp, Exp.bin(basePath.getBinPart().getBinName(), diff --git a/src/main/java/com/aerospike/ael/util/ParsingUtils.java b/src/main/java/com/aerospike/ael/util/ParsingUtils.java index 47a65b3c..1a73612a 100644 --- a/src/main/java/com/aerospike/ael/util/ParsingUtils.java +++ b/src/main/java/com/aerospike/ael/util/ParsingUtils.java @@ -3,7 +3,6 @@ import com.aerospike.ael.ConditionParser; import com.aerospike.ael.AelParseException; import com.aerospike.ael.client.exp.Exp; -import lombok.NonNull; import lombok.experimental.UtilityClass; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.TerminalNode; @@ -294,12 +293,69 @@ public static String unquote(String str) { } /** - * @param a Integer, can be null - * @param b Integer, non-null - * @return a - b if a != null, otherwise null + * Length of half-open interval {@code [start, end)} for CDT index/rank {@code count} arguments, + * consistent with closed {@code {s:e}} parsing ({@code end} exclusive). + * + * @param start inclusive lower bound; {@code null} means absolute index/rank {@code 0} for span purposes + * @param end exclusive upper bound; {@code null} means upper-unbounded (tail selection) + * @return {@code end - start} when both finite; {@code end} when {@code start} is null; {@code null} when {@code end} is null + * @implNote When both {@code start} and {@code end} are non-null but {@code start > end}, the result is negative. + * The grammar does not validate ordering; callers {@link com.aerospike.ael.parts.cdt.map.MapIndexRange} forward this + * to Aerospike CDT APIs as with closed ranges. + */ + public static Integer halfOpenRangeCount(Integer start, Integer end) { + if (end == null) { + return null; + } + if (start == null) { + return end; + } + return end - start; + } + + /** + * Parses {@link ConditionParser.KeyRangeIdentifierContext}: two keys, open upper ({@code key-}), or open lower ({@code -key}). + */ + public static NullableEndpoints parseMapKeyRangeEndpoints(ConditionParser.KeyRangeIdentifierContext range) { + int keyCount = range.mapKey().size(); + if (keyCount == 2) { + return new NullableEndpoints<>(parseMapKey(range.mapKey(0)), parseMapKey(range.mapKey(1))); + } + if (keyCount == 1) { + if (range.getChild(0) instanceof ConditionParser.MapKeyContext) { + return new NullableEndpoints<>(parseMapKey(range.mapKey(0)), null); + } + return new NullableEndpoints<>(null, parseMapKey(range.mapKey(0))); + } + throw new AelParseException("Could not parse map key range identifier: %s".formatted(range.getText())); + } + + /** + * Parses {@link ConditionParser.ValueRangeIdentifierContext}: two values, open upper ({@code v:}), or open lower ({@code :v}). + */ + public static NullableEndpoints parseValueRangeEndpoints(ConditionParser.ValueRangeIdentifierContext range) { + int n = range.valueIdentifier().size(); + if (n == 2) { + return new NullableEndpoints<>( + parseValueIdentifier(range.valueIdentifier(0)), + parseValueIdentifier(range.valueIdentifier(1))); + } + if (n == 1) { + if (range.getChild(0) instanceof ConditionParser.ValueIdentifierContext) { + return new NullableEndpoints<>(parseValueIdentifier(range.valueIdentifier(0)), null); + } + return new NullableEndpoints<>(null, parseValueIdentifier(range.valueIdentifier(0))); + } + throw new AelParseException("Could not parse value range identifier: %s".formatted(range.getText())); + } + + /** + * Nullable inclusive/exclusive endpoints for map key or value interval parsing. + * + * @param start inclusive lower bound for keys/values (CDT wire: null begin allowed) + * @param end exclusive upper bound (null end allowed) */ - public static Integer subtractNullable(Integer a, @NonNull Integer b) { - return a == null ? null : a - b; + public record NullableEndpoints(T start, T end) { } /** diff --git a/src/test/java/com/aerospike/ael/ctx/CtxTests.java b/src/test/java/com/aerospike/ael/ctx/CtxTests.java index ced6b18d..d0121932 100644 --- a/src/test/java/com/aerospike/ael/ctx/CtxTests.java +++ b/src/test/java/com/aerospike/ael/ctx/CtxTests.java @@ -122,6 +122,22 @@ void mapExpression_oneLevel() { new CTX[]{CTX.mapValue(Value.get(100))}); } + @Test + void mapExpression_halfOpenIndexRangeUnsupportedForCtx() { + assertThatThrownBy(() -> parseCtx("$.mapBin1.{:3}")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") + .hasStackTraceContaining("Context is not supported"); + } + + @Test + void listExpression_halfOpenIndexRangeUnsupportedForCtx() { + assertThatThrownBy(() -> parseCtx("$.listBin1.[:3]")) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("Could not parse the given AEL path input") + .hasStackTraceContaining("Context is not supported"); + } + @Test void mapExpression_oneLevel_withPathFunction() { assertThatThrownBy(() -> parseCtx("$.mapBin1.a.get(type: INT)")) diff --git a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java index 80dbbb9c..3cbbbc6f 100644 --- a/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/ListExpressionsTests.java @@ -401,6 +401,22 @@ void listIndexRange() { Exp.val(1), Exp.listBin("listBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[1:]"), expected); + + // Lower-open [0, n) same as [0:n] + expected = ListExp.getByIndexRange( + ListReturnType.VALUE, + Exp.val(0), + Exp.val(3), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[:3]"), expected); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[0:3]"), expected); + + expected = ListExp.getByIndexRange( + ListReturnType.VALUE | ListReturnType.INVERTED, + Exp.val(0), + Exp.val(3), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[!:3]"), expected); } @Test @@ -453,6 +469,20 @@ void listValueRange() { null, Exp.listBin("listBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=111:]"), expected); + + expected = ListExp.getByValueRange( + ListReturnType.VALUE, + null, + Exp.val(334), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[=:334]"), expected); + + expected = ListExp.getByValueRange( + ListReturnType.VALUE | ListReturnType.INVERTED, + null, + Exp.val(334), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[!=:334]"), expected); } @Test @@ -582,6 +612,20 @@ void listRankRange() { Exp.listBin("listBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[#0:3]"), expected); + expected = ListExp.getByRankRange( + ListReturnType.VALUE, + Exp.val(0), + Exp.val(3), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[#:3]"), expected); + + expected = ListExp.getByRankRange( + ListReturnType.VALUE | ListReturnType.INVERTED, + Exp.val(0), + Exp.val(3), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[!#:3]"), expected); + // Inverted expected = ListExp.getByRankRange( ListReturnType.VALUE | ListReturnType.INVERTED, @@ -616,6 +660,15 @@ void listRankRangeRelative() { Exp.listBin("listBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[#-3:-1~b]"), expected); + expected = ListExp.getByValueRelativeRankRange( + ListReturnType.VALUE, + Exp.val(0), + Exp.val("b"), + Exp.val(2), + Exp.listBin("listBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[#:2~b]"), expected); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.listBin1.[#0:2~b]"), expected); + // Inverted expected = ListExp.getByValueRelativeRankRange( ListReturnType.VALUE | ListReturnType.INVERTED, diff --git a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java index 6de4bfea..c0387f21 100644 --- a/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapExpressionsTests.java @@ -320,8 +320,9 @@ void mapIndexHexAndBinary() { TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{0xff} == 100"), Exp.eq(MapExp.getByIndex(MapReturnType.VALUE, Exp.Type.INT, Exp.val(255), Exp.mapBin("mapBin1")), Exp.val(100))); + // {-0b10}: open upper bound at key 0b10 (=2); mapKeyRange is tried before mapIndex (see keyRangeIdentifier). TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{-0b10} == 100"), - Exp.eq(MapExp.getByIndex(MapReturnType.VALUE, Exp.Type.INT, Exp.val(-2), + Exp.eq(MapExp.getByKeyRange(MapReturnType.VALUE, null, Exp.val(2L), Exp.mapBin("mapBin1")), Exp.val(100))); } @@ -460,6 +461,27 @@ void mapKeyRange() { Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{a-}"), expected); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{\"a\"-}"), expected); + + // Open lower bound (exclusive upper key) + expected = MapExp.getByKeyRange( + MapReturnType.VALUE, + null, + Exp.val("z"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{-z}"), expected); + expected = MapExp.getByKeyRange( + MapReturnType.VALUE, + null, + Exp.val(55L), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{-55}"), expected); + + expected = MapExp.getByKeyRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + null, + Exp.val("z"), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{!-z}"), expected); } @Test @@ -511,6 +533,23 @@ void mapIndexRange() { Exp.val(1), Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{1:}"), expected); + + // Lower-open [0, n) same as {0:n} + expected = MapExp.getByIndexRange( + MapReturnType.VALUE, + Exp.val(0), + Exp.val(3), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{:3}"), expected); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{0:3}"), expected); + + // Inverted lower-open + expected = MapExp.getByIndexRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + Exp.val(0), + Exp.val(3), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{!:3}"), expected); } @Test @@ -562,6 +601,21 @@ void mapValueRange() { null, Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=111:}"), expected); + + // Open lower bound (values strictly below end) + expected = MapExp.getByValueRange( + MapReturnType.VALUE, + null, + Exp.val(334), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{=:334}"), expected); + + expected = MapExp.getByValueRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + null, + Exp.val(334), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{!=:334}"), expected); } @Test @@ -691,6 +745,21 @@ void mapRankRange() { Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{#0:3}"), expected); + // Lower-open same as {#0:n} + expected = MapExp.getByRankRange( + MapReturnType.VALUE, + Exp.val(0), + Exp.val(3), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{#:3}"), expected); + + expected = MapExp.getByRankRange( + MapReturnType.VALUE | MapReturnType.INVERTED, + Exp.val(0), + Exp.val(3), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{!#:3}"), expected); + // Inverted expected = MapExp.getByRankRange( MapReturnType.VALUE | MapReturnType.INVERTED, @@ -725,6 +794,16 @@ void mapRankRangeRelative() { Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{#-1:1~10}"), expected); + // Lower-open same as {#0:1~10} + expected = MapExp.getByValueRelativeRankRange( + MapReturnType.VALUE, + Exp.val(0), + Exp.val(10), + Exp.val(1), + Exp.mapBin("mapBin1")); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{#:1~10}"), expected); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{#0:1~10}"), expected); + // Inverted expected = MapExp.getByValueRelativeRankRange( MapReturnType.VALUE | MapReturnType.INVERTED, @@ -752,6 +831,7 @@ void mapIndexRangeRelative() { Exp.val(1), Exp.mapBin("mapBin1")); TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{0:1~a}"), expected); + TestUtils.parseFilterExpressionAndCompare(ExpressionContext.of("$.mapBin1.{:1~a}"), expected); // Inverted expected = MapExp.getByKeyRelativeIndexRange( diff --git a/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java b/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java index 9a1e5858..5703f020 100644 --- a/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java +++ b/src/test/java/com/aerospike/ael/expression/MapKeyTypingTests.java @@ -397,6 +397,13 @@ void binaryIntInKeyRange() { parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{0b1010-z}"), expected); } + @Test + void openLowerIntKeyExclusiveUpper() { + Exp expected = MapExp.getByKeyRange(MapReturnType.VALUE, + null, Exp.val(55L), Exp.mapBin("bin")); + parseFilterExpressionAndCompare(ExpressionContext.of("$.bin.{-55}"), expected); + } + @Test void intKeyInRelativeIndex() { Exp expected = MapExp.getByKeyRelativeIndexRange(MapReturnType.VALUE, diff --git a/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java b/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java index eb533f23..eb0726e8 100644 --- a/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java +++ b/src/test/java/com/aerospike/ael/util/ParsingUtilsTests.java @@ -6,8 +6,14 @@ import java.util.List; +import com.aerospike.ael.parts.cdt.list.ListValueRange; +import com.aerospike.ael.parts.cdt.map.MapKeyRange; +import com.aerospike.ael.parts.cdt.map.MapValueRange; + +import static com.aerospike.ael.util.ParsingUtils.halfOpenRangeCount; import static com.aerospike.ael.util.ParsingUtils.objectToExp; import static com.aerospike.ael.util.ParsingUtils.requireSupportedExpValue; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -91,4 +97,53 @@ void rejectsUnsupportedType() { .hasMessageContaining("Double"); } } + + @Nested + class HalfOpenRangeCount { + + @Test + void endNullYieldsNullForTailSemantics() { + assertThat(halfOpenRangeCount(1, null)).isNull(); + } + + @Test + void startNullYieldsEndForOpenLower() { + assertThat(halfOpenRangeCount(null, 3)).isEqualTo(3); + } + + @Test + void bothSetYieldsDifference() { + assertThat(halfOpenRangeCount(1, 3)).isEqualTo(2); + } + + @Test + void invertedSpanIsNegative() { + assertThat(halfOpenRangeCount(5, 2)).isEqualTo(-3); + } + } + + @Nested + class OpenRangePartConstructors { + + @Test + void mapKeyRange_rejectsBothBoundsNull() { + assertThatThrownBy(() -> new MapKeyRange(false, null, null)) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("MapKeyRange requires at least one bound"); + } + + @Test + void mapValueRange_rejectsBothBoundsNull() { + assertThatThrownBy(() -> new MapValueRange(false, null, null)) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("MapValueRange requires at least one bound"); + } + + @Test + void listValueRange_rejectsBothBoundsNull() { + assertThatThrownBy(() -> new ListValueRange(false, null, null)) + .isInstanceOf(AelParseException.class) + .hasMessageContaining("ListValueRange requires at least one bound"); + } + } }