Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged Cypher refactoring into master

Conflicts:
	cypher/CHANGES.txt
	cypher/src/main/scala/org/neo4j/cypher/internal/commands/ComparablePredicate.scala
	cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
	cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilder.scala
	cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Expressions.scala
	cypher/src/test/scala/org/neo4j/cypher/ErrorMessagesTest.scala
	cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/SortBuilderTest.scala
	cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/CollectFunctionTest.scala
	server/src/functionaltest/java/org/neo4j/server/rest/BatchOperationFunctionalTest.java
	server/src/main/java/org/neo4j/server/rest/repr/OutputFormat.java
	server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java
  • Loading branch information...
commit a1108c05c84ccfc5e5da9d513f4caddf7cc494f5 2 parents eb2e102 + 07f0f47
@systay authored
Showing with 5,029 additions and 3,007 deletions.
  1. +7 −0 cypher/CHANGES.txt
  2. +6 −0 cypher/pom.xml
  3. +2 −1  cypher/src/main/java/org/neo4j/cypher/javacompat/CypherParser.java
  4. +2 −2 cypher/src/main/scala/org/neo4j/cypher/CypherException.scala
  5. +4 −4 cypher/src/main/scala/org/neo4j/cypher/CypherParser.scala
  6. +2 −5 cypher/src/main/scala/org/neo4j/cypher/EagerPipeExecutionResult.scala
  7. +1 −1  cypher/src/main/scala/org/neo4j/cypher/ExecutionEngine.scala
  8. +0 −3  cypher/src/main/scala/org/neo4j/cypher/ExecutionResult.scala
  9. +4 −5 cypher/src/main/scala/org/neo4j/cypher/PipeExecutionResult.scala
  10. +4 −3 cypher/src/main/scala/org/neo4j/cypher/internal/ReattachAliasedExpressions.scala
  11. +0 −165 cypher/src/main/scala/org/neo4j/cypher/internal/commands/AggregationExpression.scala
  12. +21 −8 cypher/src/main/scala/org/neo4j/cypher/internal/commands/ComparablePredicate.scala
  13. +0 −278 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
  14. +0 −245 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Functions.scala
  15. +29 −23 cypher/src/main/scala/org/neo4j/cypher/internal/commands/{InIterable.scala → InCollection.scala}
  16. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/commands/NamedPath.scala
  17. +27 −11 cypher/src/main/scala/org/neo4j/cypher/internal/commands/PathExpression.scala
  18. +57 −19 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Pattern.scala
  19. +97 −52 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Predicate.scala
  20. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/commands/Query.scala
  21. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/commands/QueryBuilder.scala
  22. +12 −21 cypher/src/main/scala/org/neo4j/cypher/internal/commands/ReturnItem.scala
  23. +6 −3 cypher/src/main/scala/org/neo4j/cypher/internal/commands/SortItem.scala
  24. +43 −26 cypher/src/main/scala/org/neo4j/cypher/internal/commands/StartItem.scala
  25. +67 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Add.scala
  26. +47 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/AggregationExpression.scala
  27. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Avg.scala
  28. +7 −13 ...mmands/ExpressionTest.scala → main/scala/org/neo4j/cypher/internal/commands/expressions/Closure.scala}
  29. +52 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/CoalesceFunction.scala
  30. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Collect.scala
  31. +48 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Collection.scala
  32. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Count.scala
  33. +38 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/CountStar.scala
  34. +38 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Distinct.scala
  35. +32 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Divide.scala
  36. +108 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Expression.scala
  37. +48 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/ExtractFunction.scala
  38. +48 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/FilterFunction.scala
  39. +40 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/HeadFunction.scala
  40. +44 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/IdFunction.scala
  41. +45 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Identifier.scala
  42. +38 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/LastFunction.scala
  43. +48 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/LengthFunction.scala
  44. +40 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Literal.scala
  45. +22 −31 cypher/src/main/scala/org/neo4j/cypher/internal/commands/{ → expressions}/MathFunction.scala
  46. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Max.scala
  47. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Min.scala
  48. +7 −2 ...rc/main/scala/org/neo4j/cypher/internal/{symbols/Identifier.scala → commands/expressions/Modulo.scala}
  49. +28 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Multiply.scala
  50. +48 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/NodesFunction.scala
  51. +35 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Null.scala
  52. +7 −7 ...tTest.scala → main/scala/org/neo4j/cypher/internal/commands/expressions/NullInNullOutExpression.scala}
  53. +43 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Nullable.scala
  54. +52 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/ParameterExpression.scala
  55. +28 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Pow.scala
  56. +56 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Property.scala
  57. +46 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/RelationshipFunction.scala
  58. +42 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/RelationshipTypeFunction.scala
  59. +13 −12 cypher/src/main/scala/org/neo4j/cypher/internal/commands/{ → expressions}/ShortestPathExpression.scala
  60. +28 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Subtract.scala
  61. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/Sum.scala
  62. +38 −0 cypher/src/main/scala/org/neo4j/cypher/internal/commands/expressions/TailFunction.scala
  63. +4 −7 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/ExecutionPlanImpl.scala
  64. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/PartiallySolvedQuery.scala
  65. +58 −44 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/AggregationBuilder.scala
  66. +13 −7 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ColumnFilterBuilder.scala
  67. +17 −15 ...er/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/CreateNodesAndRelationshipsBuilder.scala
  68. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/EmptyResultBuilder.scala
  69. +15 −7 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ExtractBuilder.scala
  70. +3 −15 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilder.scala
  71. +12 −7 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/MatchBuilder.scala
  72. +5 −5 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/NamedPathBuilder.scala
  73. +2 −5 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ShortestPathBuilder.scala
  74. +13 −3 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/SortBuilder.scala
  75. +11 −7 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/UpdateActionBuilder.scala
  76. +48 −15 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/CreateUniqueAction.scala
  77. +20 −5 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/DeleteEntityAction.scala
  78. +9 −5 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/DeletePropertyAction.scala
  79. +25 −21 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/ForeachAction.scala
  80. +55 −0 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/NamedExpectation.scala
  81. +9 −5 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/PropertySetAction.scala
  82. +77 −34 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/UniqueLink.scala
  83. +10 −5 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/UpdateAction.scala
  84. +0 −73 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/CypherParserImpl.scala
  85. +0 −82 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/Expressions.scala
  86. +0 −168 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/MatchClause.scala
  87. +0 −124 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/Predicates.scala
  88. +0 −66 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/ReturnItems.scala
  89. +0 −93 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_6/StartClause.scala
  90. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/Base.scala
  91. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/ConsoleCypherParser.scala
  92. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/CypherParserImpl.scala
  93. +7 −7 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/Expressions.scala
  94. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/ReturnClause.scala
  95. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/SkipLimitClause.scala
  96. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_7/StartClause.scala
  97. +4 −3 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/AbstractPattern.scala
  98. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Base.scala
  99. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/ConsoleCypherParser.scala
  100. +4 −3 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/CreateUnique.scala
  101. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/CypherParserImpl.scala
  102. +6 −5 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Expressions.scala
  103. +5 −4 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/MatchClause.scala
  104. +5 −4 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/ParserPattern.scala
  105. +7 −6 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Predicates.scala
  106. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/ReturnClause.scala
  107. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/SkipLimitClause.scala
  108. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/StartClause.scala
  109. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/StringLiteral.scala
  110. +2 −3 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Updates.scala
  111. +127 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/AbstractPattern.scala
  112. +34 −7 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/Base.scala
  113. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/ConsoleCypherParser.scala
  114. +70 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/CreateUnique.scala
  115. +203 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/CypherParserImpl.scala
  116. +210 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/Expressions.scala
  117. +72 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/MatchClause.scala
  118. +4 −4 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/OrderByClause.scala
  119. +247 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/ParserPattern.scala
  120. +92 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/Predicates.scala
  121. +34 −19 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/ReturnClause.scala
  122. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/SkipLimitClause.scala
  123. +176 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/StartClause.scala
  124. +94 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/StringLiteral.scala
  125. +54 −0 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_9/Updates.scala
  126. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/parser/{v1_6 → v1_9}/WhereClause.scala
  127. +24 −17 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ColumnFilterPipe.scala
  128. +6 −0 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/CommitPipe.scala
  129. +38 −25 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/EagerAggregationPipe.scala
  130. +7 −1 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/EmptyResultPipe.scala
  131. +10 −6 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ExecuteUpdateCommandsPipe.scala
  132. +20 −17 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ExtractPipe.scala
  133. +4 −1 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/FilterPipe.scala
  134. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/MatchPipe.scala
  135. +10 −6 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/NamedPathPipe.scala
  136. +0 −96 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/OrderedAggregationPipe.scala
  137. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ParameterPipe.scala
  138. +4 −9 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/PipeWithSource.scala
  139. +19 −27 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ShortestPathPipe.scala
  140. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/SlicePipe.scala
  141. +9 −8 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/SortPipe.scala
  142. +4 −5 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/StartPipe.scala
  143. +8 −1 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/TransactionStartPipe.scala
  144. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/AvgFunction.scala
  145. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/CollectFunction.scala
  146. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/CountFunction.scala
  147. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/DistinctFunction.scala
  148. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/MaxFunction.scala
  149. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/NumericExpressionOnly.scala
  150. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/aggregation/SumFunction.scala
  151. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/JoinerBuilder.scala
  152. +5 −7 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/MatchingContext.scala
  153. +5 −0 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/PatternGraph.scala
  154. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/PatternMatcher.scala
  155. +5 −7 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/PatternRelationship.scala
  156. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/SimplePatternMatcherBuilder.scala
  157. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/{AnyIterableType.scala → AnyCollectionType.scala}
  158. +7 −26 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/AnyType.scala
  159. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/BooleanType.scala
  160. +11 −29 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/CollectionType.scala
  161. +97 −0 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/CypherType.scala
  162. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/DoubleType.scala
  163. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/IntegerType.scala
  164. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/LongType.scala
  165. +2 −1  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/MapType.scala
  166. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/NodeType.scala
  167. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/NumberType.scala
  168. +1 −1  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/RelationshipType.scala
  169. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/ScalarType.scala
  170. +1 −0  cypher/src/main/scala/org/neo4j/cypher/internal/symbols/StringType.scala
  171. +23 −96 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/SymbolTable.scala
  172. +33 −0 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/type_system.txt
  173. +33 −0 cypher/src/test/scala/org/neo4j/cypher/CreateUniqueAcceptanceTests.scala
  174. +225 −366 cypher/src/test/scala/org/neo4j/cypher/CypherParserTest.scala
  175. +16 −1 cypher/src/test/scala/org/neo4j/cypher/ErrorMessagesTest.scala
  176. +63 −66 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
  177. +0 −3  cypher/src/test/scala/org/neo4j/cypher/MutatingIntegrationTests.scala
  178. +2 −2 cypher/src/test/scala/org/neo4j/cypher/SemanticErrorTest.scala
  179. +0 −1  cypher/src/test/scala/org/neo4j/cypher/docgen/FunctionsTest.scala
  180. +14 −14 cypher/src/test/scala/org/neo4j/cypher/docgen/cookbook/PeopleSimilarityFavoritesTest.scala
  181. +3 −2 cypher/src/test/scala/org/neo4j/cypher/docgen/cookbook/PeopleSimilarityTagsTest.scala
  182. +3 −2 cypher/src/test/scala/org/neo4j/cypher/internal/ReattachAliasedExpressionsTest.scala
  183. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/commands/AddTest.scala
  184. +11 −6 cypher/src/test/scala/org/neo4j/cypher/internal/commands/AllIdentifiersTest.scala
  185. +9 −7 cypher/src/test/scala/org/neo4j/cypher/internal/commands/CoalesceTest.scala
  186. +3 −5 cypher/src/test/scala/org/neo4j/cypher/internal/commands/ExtractTest.scala
  187. +4 −3 cypher/src/test/scala/org/neo4j/cypher/internal/commands/HasRelationshipTest.scala
  188. +5 −0 cypher/src/test/scala/org/neo4j/cypher/internal/commands/MathFunctionsTest.scala
  189. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/commands/PathExpressionTest.scala
  190. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/commands/PropertyValueTests.scala
  191. +3 −2 cypher/src/test/scala/org/neo4j/cypher/internal/commands/SeqPredicateTests.scala
  192. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/commands/SplittingPredicateTest.scala
  193. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/commands/SubtractTest.scala
  194. +120 −0 cypher/src/test/scala/org/neo4j/cypher/internal/commands/expressions/ExpressionTest.scala
  195. +3 −2 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/ExecutionPlanImplTest.scala
  196. +10 −4 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/AggregationBuilderTest.scala
  197. +6 −6 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/BuilderTest.scala
  198. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/ColumnFilterBuilderTest.scala
  199. +5 −4 ...rc/test/scala/org/neo4j/cypher/internal/executionplan/builders/CreateNodesAndRelationshipsBuilderTest.scala
  200. +4 −4 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/DeleteAndPropertySetBuilderTest.scala
  201. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/ExtractBuilderTest.scala
  202. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilderTest.scala
  203. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/GraphGlobalStartBuilderTest.scala
  204. +1 −0  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/IndexQueryBuilderTest.scala
  205. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/NodeByIdBuilderTest.scala
  206. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/ShortestPathBuilderTest.scala
  207. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/SliceBuilderTest.scala
  208. +11 −6 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/SortBuilderTest.scala
  209. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/mutation/CreateNodeActionTest.scala
  210. +0 −1  cypher/src/test/scala/org/neo4j/cypher/internal/mutation/PropertySetActionTest.scala
  211. +2 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/AllShortestPathsPipeTest.scala
  212. +6 −6 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/ColumnFilterPipeTest.scala
  213. +27 −14 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/EagerAggregationPipeTest.scala
  214. +34 −0 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/FakePipe.scala
  215. +12 −9 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/MutationTest.scala
  216. +0 −102 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/OrderedAggregationPipeTest.scala
  217. +5 −3 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/SingleShortestPathPipeTest.scala
  218. +35 −45 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/SortPipeTest.scala
  219. +2 −2 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/AggregateTest.scala
  220. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/AvgFunctionTest.scala
  221. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/CollectFunctionTest.scala
  222. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/CountTest.scala
  223. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/MaxFunctionTest.scala
  224. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/MinFunctionTest.scala
  225. +1 −1  cypher/src/test/scala/org/neo4j/cypher/internal/pipes/aggregation/SumFunctionTest.scala
  226. +17 −21 cypher/src/test/scala/org/neo4j/cypher/internal/pipes/matching/MatchingContextTest.scala
  227. +78 −29 cypher/src/test/scala/org/neo4j/cypher/internal/symbols/SymbolTableTest.scala
  228. +10 −10 kernel/src/main/java/org/neo4j/graphdb/index/UniqueFactory.java
  229. +147 −0 kernel/src/test/java/org/neo4j/graphdb/index/UniqueFactoryTest.java
  230. +0 −1  server/src/functionaltest/java/org/neo4j/server/rest/BatchOperationFunctionalTest.java
View
7 cypher/CHANGES.txt
@@ -1,3 +1,10 @@
+1.9
+--------------------
+o Refactored the type system from the bottom up
+o Predicates can now be returned and used to set properties
+o Fixes #797: CREATE UNIQUE now makes sure used identifiers have the same properties even if
+ they are re-used without the properties
+
1.8.RC1 (2012-09-05)
--------------------
o Removed the /../ literal for regular expressions. Now a normal string literal is used instead
View
6 cypher/pom.xml
@@ -125,6 +125,12 @@
<phase>process-test-resources</phase>
</execution>
</executions>
+ <configuration>
+ <jvmArgs>
+ <jvmArg>-Xms64m</jvmArg>
+ <jvmArg>-Xmx1024m</jvmArg>
+ </jvmArgs>
+ </configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
View
3  cypher/src/main/java/org/neo4j/cypher/javacompat/CypherParser.java
@@ -45,7 +45,8 @@ public static Query parseStrict(String query) throws SyntaxException {
return new org.neo4j.cypher.CypherParser().parse( query );
}
+ @Deprecated
public static Query parseConsole(String query) throws SyntaxException {
- return new org.neo4j.cypher.internal.parser.v1_6.ConsoleCypherParser().parse( query );
+ return new org.neo4j.cypher.CypherParser().parse( query );
}
}
View
4 cypher/src/main/scala/org/neo4j/cypher/CypherException.scala
@@ -19,7 +19,7 @@
*/
package org.neo4j.cypher
-import internal.commands.Expression
+import internal.commands.expressions.Expression
abstract class CypherException(message: String, cause: Throwable) extends RuntimeException(message, cause) {
def this(message:String) = this(message, null)
@@ -33,7 +33,7 @@ class CypherTypeException(message: String, cause: Throwable = null) extends Cyph
class IterableRequiredException(message:String, cause:Throwable) extends CypherException(message, cause) {
def this(message:String) = this(message, null)
- def this(expression:Expression) = this("Expected " + expression.identifier.name + " to be a collection, but it is not.", null)
+ def this(expression:Expression) = this("Expected " + expression + " to be an collection, but it is not.", null)
}
class ParameterNotFoundException(message:String, cause:Throwable) extends CypherException(message, cause) {
View
8 cypher/src/main/scala/org/neo4j/cypher/CypherParser.scala
@@ -22,13 +22,13 @@ package org.neo4j.cypher
import internal.commands.Query
class CypherParser(version: String) {
- def this() = this ("1.8")
+ def this() = this("1.9")
val hasVersionDefined = """(?si)^\s*cypher\s*([^\s]+)\s*(.*)""".r
- val v16 = new internal.parser.v1_6.CypherParserImpl
val v17 = new internal.parser.v1_7.CypherParserImpl
val v18 = new internal.parser.v1_8.CypherParserImpl
+ val v19 = new internal.parser.v1_9.CypherParserImpl
@throws(classOf[SyntaxException])
def parse(queryText: String): Query = {
@@ -39,10 +39,10 @@ class CypherParser(version: String) {
}
v match {
- case "1.6" => v16.parse(q)
case "1.7" => v17.parse(q)
case "1.8" => v18.parse(q)
- case _ => throw new SyntaxException("Versions supported are 1.6, 1.7 and 1.8")
+ case "1.9" => v19.parse(q)
+ case _ => throw new SyntaxException("Versions supported are 1.7, 1.8 and 1.9")
}
}
}
View
7 cypher/src/main/scala/org/neo4j/cypher/EagerPipeExecutionResult.scala
@@ -20,17 +20,14 @@
package org.neo4j.cypher
import internal.pipes.QueryState
-import internal.symbols.SymbolTable
-import org.neo4j.graphdb.{Transaction, GraphDatabaseService}
-import org.neo4j.kernel.GraphDatabaseAPI
+import org.neo4j.graphdb.GraphDatabaseService
import collection.Map
class EagerPipeExecutionResult(r: => Traversable[Map[String, Any]],
- symbols: SymbolTable,
columns: List[String],
state: QueryState,
db: GraphDatabaseService)
- extends PipeExecutionResult(r, symbols, columns) {
+ extends PipeExecutionResult(r, columns) {
override lazy val queryStatistics = QueryStatistics(
nodesCreated = state.createdNodes.count,
View
2  cypher/src/main/scala/org/neo4j/cypher/ExecutionEngine.scala
@@ -40,7 +40,7 @@ class ExecutionEngine(graph: GraphDatabaseService) {
val database = graph.asInstanceOf[InternalAbstractGraphDatabase]
database.getConfig.getParams.asScala.get("cypher_parser_version") match {
case None => new CypherParser()
- case Some(v) => new CypherParser(v.toString)
+ case Some(v) => new CypherParser(v)
}
}
else {
View
3  cypher/src/main/scala/org/neo4j/cypher/ExecutionResult.scala
@@ -21,12 +21,9 @@ package org.neo4j.cypher
import java.io.PrintWriter
import java.lang.String
-import internal.symbols.SymbolTable
-
trait ExecutionResult extends Iterator[Map[String, Any]] {
def columns: List[String]
- def symbols: SymbolTable
def javaColumns: java.util.List[String]
def javaColumnAs[T](column: String): java.util.Iterator[T]
def columnAs[T](column: String): Iterator[T]
View
9 cypher/src/main/scala/org/neo4j/cypher/PipeExecutionResult.scala
@@ -19,20 +19,19 @@
*/
package org.neo4j.cypher
-import internal.commands.{IterableSupport, IsIterable}
+import internal.commands.{CollectionSupport, IsCollection}
import internal.StringExtras
import scala.collection.JavaConverters._
import org.neo4j.graphdb.{PropertyContainer, Relationship, Node}
import java.io.{StringWriter, PrintWriter}
import java.lang.String
-import internal.symbols.SymbolTable
import collection.Map
import collection.immutable.{Map => ImmutableMap}
-class PipeExecutionResult(r: => Traversable[Map[String, Any]], val symbols: SymbolTable, val columns: List[String])
+class PipeExecutionResult(r: => Traversable[Map[String, Any]], val columns: List[String])
extends ExecutionResult
with StringExtras
- with IterableSupport {
+ with CollectionSupport {
lazy val immutableResult = r.map(m => m.toMap)
@@ -134,7 +133,7 @@ class PipeExecutionResult(r: => Traversable[Map[String, Any]], val symbols: Symb
private def text(obj: Any): String = obj match {
case x: Node => x.toString + props(x)
case x: Relationship => ":" + x.getType.toString + "[" + x.getId + "] " + props(x)
- case IsIterable(coll) => coll.map(text).mkString("[", ",", "]")
+ case IsCollection(coll) => coll.map(text).mkString("[", ",", "]")
case x: String => "\"" + x + "\""
case Some(x) => x.toString
case null => "<null>"
View
7 cypher/src/main/scala/org/neo4j/cypher/internal/ReattachAliasedExpressions.scala
@@ -20,6 +20,7 @@
package org.neo4j.cypher.internal
import commands._
+import expressions.{Identifier, Expression}
/*
@@ -38,15 +39,15 @@ object ReattachAliasedExpressions {
}
private def expressionRewriter(returnColumns: Seq[ReturnColumn])(expression: Expression): Expression = expression match {
- case e: Entity => {
+ case e@Identifier(entityName) =>
val returnItems = keepReturnItems(returnColumns)
val found = returnItems.find(_.name == e.entityName)
found match {
- case None => e
+ case None => e
case Some(returnItem) => returnItem.expression
}
- }
+
case somethingElse => somethingElse
}
View
165 cypher/src/main/scala/org/neo4j/cypher/internal/commands/AggregationExpression.scala
@@ -1,165 +0,0 @@
-/**
- * Copyright (c) 2002-2012 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.neo4j.cypher.internal.commands
-
-import collection.Seq
-import org.neo4j.cypher.internal.pipes.aggregation._
-import org.neo4j.cypher.internal.symbols._
-import org.neo4j.cypher.SyntaxException
-import collection.Map
-abstract class AggregationExpression extends Expression {
- def compute(m: Map[String, Any]) = m.get(name) match {
- case None => null
- case Some(x) => x
- }
-
- override val identifier = Identifier(name, typ)
-
- def name: String
-
- def typ: AnyType
-
- def createAggregationFunction: AggregationFunction
-}
-
-case class CountStar() extends AggregationExpression {
- def name = "count(*)"
-
- def typ = LongType()
-
- def declareDependencies(extectedType: AnyType) = Seq()
-
- def rewrite(f: (Expression) => Expression) = f(CountStar())
-
- def createAggregationFunction = new CountStarFunction
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this)
- else
- Seq()
-
- override def toString() = "count(*)"
-}
-
-abstract class AggregationWithInnerExpression(inner:Expression) extends AggregationExpression {
- if(inner.containsAggregate)
- throw new SyntaxException("Can't use aggregate functions inside of aggregate functions.")
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = inner.dependencies(expectedInnerType)
- def expectedInnerType: AnyType
-
- override val identifier = Identifier("%s(%s)".format(name, inner.identifier.name), typ)
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ inner.filter(f)
- else
- inner.filter(f)
-}
-
-case class Distinct(innerAggregator: AggregationExpression, expression: Expression) extends AggregationWithInnerExpression(expression) {
- def typ = innerAggregator.identifier.typ
-
- override val identifier = Identifier("%s(distinct %s)".format(innerAggregator.name, expression.identifier.name), innerAggregator.identifier.typ)
-
- def expectedInnerType: AnyType = AnyType()
-
- def name = "distinct"
-
- def createAggregationFunction = new DistinctFunction(expression, innerAggregator.createAggregationFunction)
-
- override def declareDependencies(extectedType: AnyType): Seq[Identifier] = innerAggregator.dependencies(extectedType) ++ expression.dependencies(AnyType())
-
- def rewrite(f: (Expression) => Expression) = innerAggregator.rewrite(f) match {
- case inner: AggregationExpression => f(Distinct(inner, expression.rewrite(f)))
- case _ => f(Distinct(innerAggregator, expression.rewrite(f)))
- }
-}
-
-case class Count(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = IntegerType()
-
- def name = "count"
-
- def createAggregationFunction = new CountFunction(anInner)
-
- def expectedInnerType: AnyType = AnyType()
-
- def rewrite(f: (Expression) => Expression) = f(Count(anInner.rewrite(f)))
-}
-
-case class Sum(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = NumberType()
-
- def name = "sum"
-
- def createAggregationFunction = new SumFunction(anInner)
-
- def expectedInnerType: AnyType = NumberType()
-
- def rewrite(f: (Expression) => Expression) = f(Sum(anInner.rewrite(f)))
-}
-
-case class Min(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = NumberType()
-
- def name = "min"
-
- def createAggregationFunction = new MinFunction(anInner)
-
- def expectedInnerType: AnyType = NumberType()
-
- def rewrite(f: (Expression) => Expression) = f(Min(anInner.rewrite(f)))
-}
-
-case class Max(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = NumberType()
-
- def name = "max"
-
- def createAggregationFunction = new MaxFunction(anInner)
-
- def expectedInnerType: AnyType = NumberType()
-
- def rewrite(f: (Expression) => Expression) = f(Max(anInner.rewrite(f)))
-}
-
-case class Avg(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = NumberType()
-
- def name = "avg"
-
- def createAggregationFunction = new AvgFunction(anInner)
-
- def expectedInnerType: AnyType = NumberType()
-
- def rewrite(f: (Expression) => Expression) = f(Avg(anInner.rewrite(f)))
-}
-
-case class Collect(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
- def typ = new CollectionType(anInner.identifier.typ)
-
- def name = "collect"
-
- def createAggregationFunction = new CollectFunction(anInner)
-
- def expectedInnerType: AnyType = AnyType()
-
- def rewrite(f: (Expression) => Expression) = f(Collect(anInner.rewrite(f)))
-}
View
29 cypher/src/main/scala/org/neo4j/cypher/internal/commands/ComparablePredicate.scala
@@ -20,9 +20,10 @@
package org.neo4j.cypher.internal.commands
import collection.Seq
+import expressions.Expression
import org.neo4j.cypher.internal.Comparer
import java.lang.String
-import org.neo4j.cypher.internal.symbols.{AnyType, ScalarType, Identifier}
+import org.neo4j.cypher.internal.symbols._
import collection.Map
abstract sealed class ComparablePredicate(left: Expression, right: Expression) extends Predicate with Comparer {
@@ -37,32 +38,44 @@ abstract sealed class ComparablePredicate(left: Expression, right: Expression) e
compare(comparisonResult)
}
- def dependencies: Seq[Identifier] = left.dependencies(ScalarType()) ++ right.dependencies(ScalarType())
def sign: String
def atoms: Seq[Predicate] = Seq(this)
- override def toString = left.toString() + " " + sign + " " + right.toString()
- def exists(f: (Expression) => Boolean) = left.exists(f) || right.exists(f)
+ override def toString() = left.toString() + " " + sign + " " + right.toString()
def containsIsNull = false
def filter(f: (Expression) => Boolean): Seq[Expression] = left.filter(f) ++ right.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ left.assertTypes(symbols)
+ right.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = left.symbolTableDependencies ++ right.symbolTableDependencies
}
case class Equals(a: Expression, b: Expression) extends Predicate with Comparer {
+
def isMatch(m: Map[String, Any]): Boolean = {
val a1 = a(m)
val b1 = b(m)
(a1, b1) match {
- case (IsIterable(l), IsIterable(r)) => l == r
+ case (IsCollection(l), IsCollection(r)) => l == r
case _ => a1 == b1
}
}
+
def atoms = Seq(this)
- def exists(f: (Expression) => Boolean) = a.exists(f) || b.exists(f)
- def dependencies = a.dependencies(AnyType()) ++ b.dependencies(AnyType())
- override def toString = a.toString() + " == " + b.toString()
+ override def toString() = a.toString() + " == " + b.toString()
def containsIsNull = false
def rewrite(f: (Expression) => Expression) = Equals(a.rewrite(f), b.rewrite(f))
def filter(f: (Expression) => Boolean): Seq[Expression] = a.filter(f) ++ b.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.assertTypes(symbols)
+ b.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = a.symbolTableDependencies ++ b.symbolTableDependencies
}
case class LessThan(a: Expression, b: Expression) extends ComparablePredicate(a, b) {
View
278 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
@@ -1,278 +0,0 @@
-/**
- * Copyright (c) 2002-2012 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.neo4j.cypher.internal.commands
-
-import java.lang.String
-import org.neo4j.cypher._
-import internal.symbols._
-import org.neo4j.graphdb.{NotFoundException, PropertyContainer}
-import collection.Map
-
-abstract class Expression extends (Map[String, Any] => Any) {
- protected def compute(v1: Map[String, Any]) : Any
- def apply(m: Map[String, Any]) = m.getOrElse(identifier.name, compute(m))
-
- val identifier: Identifier
- def declareDependencies(expectedType: AnyType): Seq[Identifier]
- def dependencies(expectedType: AnyType): Seq[Identifier] = {
- val myType = identifier.typ
- if (!expectedType.isAssignableFrom(myType) &&
- !myType.isAssignableFrom(expectedType))
- throw new SyntaxException("`%s` expected to be a %s but it is a %s".format(identifier.name, expectedType, identifier.typ))
- declareDependencies(expectedType)
- }
-
- def rewrite(f: Expression => Expression): Expression
- def exists(f: Expression => Boolean) = filter(f).nonEmpty
- def filter(f: Expression => Boolean): Seq[Expression]
- def subExpressions = filter( _ != this)
- def containsAggregate = exists(_.isInstanceOf[AggregationExpression])
- override def toString() = identifier.name
-}
-
-case class CachedExpression(key:String, identifier:Identifier) extends CastableExpression {
- override def apply(m: Map[String, Any]) = m(key)
- protected def compute(v1: Map[String, Any]) = null
- def declareDependencies(extectedType: AnyType) = Seq()
- def rewrite(f: (Expression) => Expression) = f(this)
- def filter(f: (Expression) => Boolean) = if(f(this)) Seq(this) else Seq()
- override def toString() = "Cached(" + super.toString() + ")"
-}
-
-case class Null() extends Expression {
- protected def compute(v1: Map[String, Any]) = null
- val identifier: Identifier = Identifier("null", ScalarType())
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
- def rewrite(f: (Expression) => Expression): Expression = f(this)
- def filter(f: (Expression) => Boolean): Seq[Expression] = if(f(this)) Seq(this) else Seq()
-}
-
-case class Add(a: Expression, b: Expression) extends Expression {
- val identifier = Identifier("%s + %s".format(a.identifier.name, b.identifier.name), myType)
-
- private def myType = if(a.identifier.typ.isAssignableFrom(b.identifier.typ))
- a.identifier.typ
- else if(b.identifier.typ.isAssignableFrom(a.identifier.typ))
- b.identifier.typ
- else ScalarType()
-
-
- def compute(m: Map[String, Any]) = {
- val aVal = a(m)
- val bVal = b(m)
-
- (aVal, bVal) match {
- case (x: Number, y: Number) => x.doubleValue() + y.doubleValue()
- case (x: String, y: String) => x + y
- case (IsIterable(x), IsIterable(y)) => x ++ y
- case (IsIterable(x), y) => x ++ Seq(y)
- case (x, IsIterable(y)) => Seq(x) ++ y
- case _ => throw new CypherTypeException("Don't know how to add `" + aVal.toString + "` and `" + bVal.toString + "`")
- }
- }
-
- def declareDependencies(extectedType: AnyType) = a.declareDependencies(extectedType) ++ b.declareDependencies(extectedType)
- def rewrite(f: (Expression) => Expression) = f(Add(a.rewrite(f), b.rewrite(f)))
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this) ++ a.filter(f) ++ b.filter(f)
- else
- a.filter(f) ++ b.filter(f)
-}
-
-case class Subtract(a: Expression, b: Expression) extends Arithmetics(a, b) {
- def operand = "-"
- def verb = "subtract"
- def stringWithString(a: String, b: String) = throwTypeError(a, b)
- def numberWithNumber(a: Number, b: Number) = a.doubleValue() - b.doubleValue()
- def rewrite(f: (Expression) => Expression) = f(Subtract(a.rewrite(f), b.rewrite(f)))
-}
-
-case class Modulo(a: Expression, b: Expression) extends Arithmetics(a, b) {
- def operand = "%"
- def verb = "modulo"
- def stringWithString(a: String, b: String) = throwTypeError(a, b)
- def numberWithNumber(a: Number, b: Number) = a.doubleValue() % b.doubleValue()
- def rewrite(f: (Expression) => Expression) = f(Modulo(a.rewrite(f), b.rewrite(f)))
-}
-
-case class Pow(a: Expression, b: Expression) extends Arithmetics(a, b) {
- def operand = "^"
- def verb = "power"
- def stringWithString(a: String, b: String) = throwTypeError(a, b)
- def numberWithNumber(a: Number, b: Number) = math.pow(a.doubleValue(), b.doubleValue())
- def rewrite(f: (Expression) => Expression) = f(Pow(a.rewrite(f), b.rewrite(f)))
-}
-
-case class Multiply(a: Expression, b: Expression) extends Arithmetics(a, b) {
- def operand = "*"
- def verb = "multiply"
- def stringWithString(a: String, b: String) = throwTypeError(a, b)
- def numberWithNumber(a: Number, b: Number) = a.doubleValue() * b.doubleValue()
- def rewrite(f: (Expression) => Expression) = f(Multiply(a.rewrite(f), b.rewrite(f)))
-}
-
-case class Divide(a: Expression, b: Expression) extends Arithmetics(a, b) {
- def operand = "/"
- def verb = "divide"
- def stringWithString(a: String, b: String) = throwTypeError(a, b)
- def numberWithNumber(a: Number, b: Number) = a.doubleValue() / b.doubleValue()
- def rewrite(f: (Expression) => Expression) = f(Divide(a.rewrite(f), b.rewrite(f)))
-}
-
-abstract class Arithmetics(left: Expression, right: Expression) extends Expression {
- val identifier = Identifier("%s %s %s".format(left.identifier.name, operand, right.identifier.name), NumberType())
- def operand: String
- def throwTypeError(bVal: Any, aVal: Any): Nothing = {
- throw new CypherTypeException("Don't know how to " + verb + " `" + name(bVal) + "` with `" + name(aVal) + "`")
- }
-
- private def name(x:Any)=x match {
- case null => "null"
- case _ => x.toString
- }
-
- def compute(m: Map[String, Any]) = {
- val aVal = left(m)
- val bVal = right(m)
-
- (aVal, bVal) match {
- case (x: Number, y: Number) => numberWithNumber(x, y)
- case (x: String, y: String) => stringWithString(x, y)
- case _ => throwTypeError(bVal, aVal)
- }
-
- }
-
- def verb: String
- def stringWithString(a: String, b: String): String
- def numberWithNumber(a: Number, b: Number): Number
- def declareDependencies(extectedType: AnyType) = left.declareDependencies(extectedType) ++ right.declareDependencies(extectedType)
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this) ++ left.filter(f) ++ right.filter(f)
- else
- left.filter(f) ++ right.filter(f)
-}
-
-case class Literal(v: Any) extends Expression {
- def compute(m: Map[String, Any]) = v
-
- override def apply(m: Map[String, Any]): Any = compute(m)
-
- val identifier = Identifier(name, AnyType.fromJava(v))
- private def name = v match {
- case null => "null"
- case x => x.toString
- }
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
- def rewrite(f: (Expression) => Expression) = f(this)
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this)
- else
- Seq()
-}
-
-abstract class CastableExpression extends Expression {
- override def dependencies(extectedType: AnyType): Seq[Identifier] = declareDependencies(extectedType)
-}
-
-case class Nullable(expression: Expression) extends Expression {
- val identifier = Identifier(expression.identifier.name + "?", expression.identifier.typ)
-
- def compute(m: Map[String, Any]) = try {
- expression.apply(m)
- } catch {
- case x: EntityNotFoundException => null
- }
-
- def declareDependencies(extectedType: AnyType) = expression.dependencies(extectedType)
- override def dependencies(extectedType: AnyType) = expression.dependencies(extectedType)
- def rewrite(f: (Expression) => Expression) = f(Nullable(expression.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this) ++ expression.filter(f)
- else
- expression.filter(f)
-}
-
-case class Property(entity: String, property: String) extends CastableExpression {
- def compute(m: Map[String, Any]): Any = {
- m(entity).asInstanceOf[PropertyContainer] match {
- case null => null
- case propertyContainer => try {
- propertyContainer.getProperty(property)
- } catch {
- case x: NotFoundException => throw new EntityNotFoundException("The property '%s' does not exist on %s".format(property, propertyContainer), x)
- }
- }
- }
-
- val identifier: Identifier = Identifier(entity + "." + property, AnyType())
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entity, MapType()))
- def rewrite(f: (Expression) => Expression) = f(this)
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this)
- else
- Seq()
-}
-
-case class Entity(entityName: String) extends CastableExpression {
- def compute(m: Map[String, Any]): Any = m.getOrElse(entityName, throw new NotFoundException("Failed to find `" + entityName + "`"))
- val identifier: Identifier = Identifier(entityName, AnyType())
- override def toString(): String = entityName
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entityName, extectedType))
- def rewrite(f: (Expression) => Expression) = f(this)
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this)
- else
- Seq()
-}
-
-case class Collection(expressions:Expression*) extends CastableExpression {
- def compute(m: Map[String, Any]): Any = expressions.map(e=>e(m))
-
- val identifier: Identifier = Identifier(name, AnyIterableType())
-
- private def name = expressions.map(_.identifier.name).mkString("[", ", ", "]")
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.declareDependencies(AnyType()))
- def rewrite(f: (Expression) => Expression): Expression = f(Collection(expressions.map(f):_*))
- def filter(f: (Expression) => Boolean): Seq[Expression] = if(f(this))
- Seq(this) ++ expressions.flatMap(_.filter(f))
- else
- expressions.flatMap(_.filter(f))
-}
-
-case class ParameterExpression(parameterName: String) extends CastableExpression {
- def compute(m: Map[String, Any]): Any = m.getOrElse("-=PARAMETER=-" + parameterName + "-=PARAMETER=-", throw new ParameterNotFoundException("Expected a parameter named " + parameterName)) match {
- case ParameterValue(x) => x
- case _ => throw new ParameterNotFoundException("Expected a parameter named " + parameterName)
- }
-
- override def apply(m: Map[String, Any]) = compute(m)
- val identifier: Identifier = Identifier(parameterName, AnyType())
- override def toString(): String = "{" + parameterName + "}"
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
- def rewrite(f: (Expression) => Expression) = f(this)
- def filter(f: (Expression) => Boolean) = if(f(this))
- Seq(this)
- else
- Seq()
-}
-
-case class ParameterValue(value: Any)
View
245 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Functions.scala
@@ -1,245 +0,0 @@
-/**
- * Copyright (c) 2002-2012 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.neo4j.cypher.internal.commands
-
-import org.neo4j.cypher.{SyntaxException, IterableRequiredException}
-import scala.collection.JavaConverters._
-import org.neo4j.cypher.internal.symbols._
-import org.neo4j.graphdb.{Node, Relationship, Path}
-import collection.Map
-
-trait Functions
-
-abstract class NullInNullOutExpression(argument: Expression) extends Expression {
- def compute(value: Any, m: Map[String, Any]): Any
-
- def compute(m: Map[String, Any]): Any = argument(m) match {
- case null => null
- case x => compute(x, m)
- }
-}
-
-case class ExtractFunction(collection: Expression, id: String, expression: Expression)
- extends NullInNullOutExpression(collection)
- with IterableSupport
-{
- def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).map(iterValue => {
- val innerMap = m + (id -> iterValue)
- expression(innerMap)
- }).toList
-
- val identifier = Identifier("extract(" + id + " in " + collection.identifier.name + " : " + expression.identifier.name + ")", new CollectionType(expression.identifier.typ))
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] =
- // Extract depends on everything that the iterable and the expression depends on, except
- // the new identifier inserted into the expression context, named with id
- collection.dependencies(AnyIterableType()) ++ expression.dependencies(AnyType()).filterNot(_.name == id)
-
- def rewrite(f: (Expression) => Expression) = f(ExtractFunction(collection.rewrite(f), id, expression.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ collection.filter(f) ++ expression.filter(f)
- else
- collection.filter(f) ++ expression.filter(f)
-}
-
-case class RelationshipFunction(path: Expression) extends NullInNullOutExpression(path) {
- def compute(value: Any, m: Map[String, Any]) = value match {
- case p: Path => p.relationships().asScala.toSeq
- case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.")
- }
-
- val identifier = Identifier("RELATIONSHIPS(" + path.identifier.name + ")", new CollectionType(RelationshipType()))
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType())
-
- def rewrite(f: (Expression) => Expression) = f(RelationshipFunction(path.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ path.filter(f)
- else
- path.filter(f)
-}
-
-case class CoalesceFunction(expressions: Expression*) extends Expression {
- def compute(m: Map[String, Any]): Any = expressions.toStream.map(expression => expression(m)).find(value => value != null) match {
- case None => null
- case Some(x) => x
- }
-
- def innerExpectedType: Option[AnyType] = None
-
- val argumentsString: String = expressions.map(_.identifier.name).mkString(",")
-
- //TODO: Find out the closest matching return type
- val identifier = Identifier("COALESCE(" + argumentsString + ")", AnyType())
-
- override def toString() = "coalesce(" + argumentsString + ")"
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.dependencies(AnyType()))
-
- def rewrite(f: (Expression) => Expression) = f(CoalesceFunction(expressions.map(e => e.rewrite(f)): _*))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ expressions.flatMap(_.filter(f))
- else
- expressions.flatMap(_.filter(f))
-}
-
-case class RelationshipTypeFunction(relationship: Expression) extends NullInNullOutExpression(relationship) {
- def compute(value: Any, m: Map[String, Any]) = value.asInstanceOf[Relationship].getType.name()
-
- lazy val identifier = Identifier("TYPE(" + relationship.identifier.name + ")", StringType())
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = relationship.dependencies(RelationshipType())
-
- def rewrite(f: (Expression) => Expression) = f(RelationshipTypeFunction(relationship.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ relationship.filter(f)
- else
- relationship.filter(f)
-}
-
-case class LengthFunction(inner: Expression) extends NullInNullOutExpression(inner) with IterableSupport {
- def compute(value: Any, m: Map[String, Any]) = value match {
- case path: Path => path.length()
- case s: String => s.length()
- case x => makeTraversable(x).toSeq.length
- }
-
- val identifier = Identifier("LENGTH(" + inner.identifier.name + ")", IntegerType())
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = inner.dependencies(AnyIterableType()).toList
-
- def rewrite(f: (Expression) => Expression) = f(LengthFunction(inner.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ inner.filter(f)
- else
- inner.filter(f)
-}
-
-case class IdFunction(inner: Expression) extends NullInNullOutExpression(inner) {
-
- def compute(value: Any, m: Map[String, Any]) = value match {
- case node: Node => node.getId
- case rel: Relationship => rel.getId
- }
-
- val identifier = Identifier("ID(" + inner.identifier.name + ")", LongType())
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = inner.dependencies(MapType())
-
- def rewrite(f: (Expression) => Expression) = f(IdFunction(inner.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ inner.filter(f)
- else
- inner.filter(f)
-}
-
-case class HeadFunction(collection: Expression) extends NullInNullOutExpression(collection) with IterableSupport {
- def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).head
-
- private def myType = collection.identifier.typ match {
- case x: CollectionType => x.iteratedType
- case _ => ScalarType()
- }
-
- override def dependencies(extectedType: AnyType): Seq[Identifier] = declareDependencies(extectedType)
-
- val identifier = Identifier("head(" + collection.identifier.name + ")", myType)
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = collection.dependencies(AnyIterableType())
-
- def rewrite(f: (Expression) => Expression) = f(HeadFunction(collection.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ collection.filter(f)
- else
- collection.filter(f)
-}
-
-case class LastFunction(collection: Expression) extends NullInNullOutExpression(collection) with IterableSupport {
- def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).last
-
- val identifier = Identifier("last(" + collection.identifier.name + ")", ScalarType())
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = collection.dependencies(AnyIterableType())
-
- def rewrite(f: (Expression) => Expression) = f(LastFunction(collection.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ collection.filter(f)
- else
- collection.filter(f)
-}
-
-case class TailFunction(collection: Expression) extends NullInNullOutExpression(collection) with IterableSupport {
- def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).tail
-
- val identifier = Identifier("tail(" + collection.identifier.name + ")", collection.identifier.typ)
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = collection.dependencies(AnyIterableType())
-
- def rewrite(f: (Expression) => Expression) = f(TailFunction(collection.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ collection.filter(f)
- else
- collection.filter(f)
-}
-
-case class NodesFunction(path: Expression) extends NullInNullOutExpression(path) {
- def compute(value: Any, m: Map[String, Any]) = value match {
- case p: Path => p.nodes().asScala.toSeq
- case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.")
- }
-
- val identifier = Identifier("NODES(" + path.identifier.name + ")", new CollectionType(NodeType()))
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType())
-
- def rewrite(f: (Expression) => Expression) = f(NodesFunction(path.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ path.filter(f)
- else
- path.filter(f)
-}
-
-case class FilterFunction(collection: Expression, symbol: String, predicate: Predicate)
- extends NullInNullOutExpression(collection)
- with IterableSupport
-{
- def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).filter(element => predicate.isMatch(m + (symbol -> element)))
-
- val identifier = Identifier("filter(%s in %s : %s)".format(symbol, collection.identifier.name, predicate), collection.identifier.typ)
-
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = (collection.dependencies(AnyIterableType()) ++ predicate.dependencies).filterNot(_.name == symbol)
-
- def rewrite(f: (Expression) => Expression) = f(FilterFunction(collection.rewrite(f), symbol, predicate.rewrite(f)))
-
- def filter(f: (Expression) => Boolean) = if (f(this))
- Seq(this) ++ collection.filter(f)
- else
- collection.filter(f)
-}
View
52 ...g/neo4j/cypher/internal/commands/InIterable.scala → ...neo4j/cypher/internal/commands/InCollection.scala
@@ -20,73 +20,79 @@
package org.neo4j.cypher.internal.commands
import collection.Seq
-import org.neo4j.cypher.internal.symbols.{Identifier, AnyIterableType}
+import expressions.{Closure, Expression}
+import org.neo4j.cypher.internal.symbols._
import collection.Map
import java.lang.{Iterable => JavaIterable}
import java.util.{Map => JavaMap}
-
import collection.JavaConverters._
-abstract class InIterable(expression: Expression, symbol: String, closure: Predicate) extends Predicate with IterableSupport {
+abstract class InCollection(collection: Expression, id: String, predicate: Predicate)
+ extends Predicate
+ with CollectionSupport
+ with Closure {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean
def isMatch(m: Map[String, Any]): Boolean = {
- val seq = makeTraversable(expression(m)).toSeq
+ val seq = makeTraversable(collection(m)).toSeq
seqMethod(seq)(item => {
- val innerMap = m ++ Map(symbol -> item)
- closure.isMatch(innerMap)
+ val innerMap = m ++ Map(id -> item)
+ predicate.isMatch(innerMap)
})
}
- def dependencies: Seq[Identifier] = expression.dependencies(AnyIterableType()) ++ closure.dependencies.filterNot(_.name == symbol)
-
def atoms: Seq[Predicate] = Seq(this)
- def exists(f: (Expression) => Boolean) = expression.exists(f) || closure.exists(f)
-
def name: String
- override def toString = name + "(" + symbol + " in " + expression + " where " + closure + ")"
+ override def toString() = name + "(" + id + " in " + collection + " where " + predicate + ")"
- def containsIsNull = closure.containsIsNull
+ def containsIsNull = predicate.containsIsNull
+
+ def filter(f: (Expression) => Boolean): Seq[Expression] = collection.filter(f) ++ predicate.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ val innerType = collection.evaluateType(AnyCollectionType(), symbols).iteratedType
+ predicate.assertTypes(symbols.add(id, innerType))
+ }
- def filter(f: (Expression) => Boolean): Seq[Expression] = expression.filter(f) ++ closure.filter(f)
+ def symbolTableDependencies = symbolTableDependencies(collection, predicate, id)
}
-case class AllInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
+case class AllInCollection(collection: Expression, symbolName: String, inner: Predicate) extends InCollection(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.forall _
def name = "all"
- def rewrite(f: (Expression) => Expression) = AllInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
+ def rewrite(f: (Expression) => Expression) = AllInCollection(collection.rewrite(f), symbolName, inner.rewrite(f))
}
-case class AnyInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
+case class AnyInCollection(collection: Expression, symbolName: String, inner: Predicate) extends InCollection(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.exists _
def name = "any"
- def rewrite(f: (Expression) => Expression) = AnyInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
+ def rewrite(f: (Expression) => Expression) = AnyInCollection(collection.rewrite(f), symbolName, inner.rewrite(f))
}
-case class NoneInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
+case class NoneInCollection(collection: Expression, symbolName: String, inner: Predicate) extends InCollection(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => !f.exists(x)
def name = "none"
- def rewrite(f: (Expression) => Expression) = NoneInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
+ def rewrite(f: (Expression) => Expression) = NoneInCollection(collection.rewrite(f), symbolName, inner.rewrite(f))
}
-case class SingleInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
+case class SingleInCollection(collection: Expression, symbolName: String, inner: Predicate) extends InCollection(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => f.filter(x).length == 1
def name = "single"
- def rewrite(f: (Expression) => Expression) = SingleInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
+ def rewrite(f: (Expression) => Expression) = SingleInCollection(collection.rewrite(f), symbolName, inner.rewrite(f))
}
-object IsIterable extends IterableSupport {
+object IsCollection extends CollectionSupport {
def unapply(x: Any):Option[Traversable[Any]] = if (isCollection(x)) {
Some(castToTraversable(x))
} else {
@@ -94,7 +100,7 @@ object IsIterable extends IterableSupport {
}
}
-trait IterableSupport {
+trait CollectionSupport {
def isCollection(x: Any) = castToTraversable.isDefinedAt(x)
def makeTraversable(z: Any): Traversable[Any] = if (castToTraversable.isDefinedAt(z)) {
View
1  cypher/src/main/scala/org/neo4j/cypher/internal/commands/NamedPath.scala
@@ -19,6 +19,7 @@
*/
package org.neo4j.cypher.internal.commands
+import expressions.Expression
import org.neo4j.graphdb.{Path, PropertyContainer}
import org.neo4j.cypher.PathImpl
import scala.collection.JavaConverters._
View
38 cypher/src/main/scala/org/neo4j/cypher/internal/commands/PathExpression.scala
@@ -19,20 +19,29 @@
*/
package org.neo4j.cypher.internal.commands
-import org.neo4j.cypher.internal.symbols.{SymbolTable, PathType, AnyType, Identifier}
+import expressions.Expression
+import org.neo4j.cypher.internal.symbols._
import org.neo4j.cypher.internal.pipes.matching.MatchingContext
import collection.Map
import org.neo4j.helpers.ThisShouldNotHappenError
import org.neo4j.graphdb.Path
import org.neo4j.cypher.internal.executionplan.builders.PatternGraphBuilder
-case class PathExpression(pathPattern: Seq[Pattern]) extends Expression with PathExtractor with PatternGraphBuilder {
- val symbols = new SymbolTable(declareDependencies(AnyType()).distinct: _*)
- val matchingContext = new MatchingContext(symbols, Seq(), buildPatternGraph(symbols, pathPattern))
- val interestingPoints = pathPattern.flatMap(_.possibleStartPoints.map(_.name)).distinct
+case class PathExpression(pathPattern: Seq[Pattern])
+ extends Expression
+ with PathExtractor
+ with PatternGraphBuilder {
+ val identifiers: Seq[(String, CypherType)] = pathPattern.flatMap(pattern => pattern.possibleStartPoints.filterNot(p => p._1.startsWith(" UNNAMED")))
- def compute(m: Map[String, Any]): Any = {
- val returnNull = declareDependencies(AnyType()).map(_.name).exists(key => m.get(key) match {
+ val symbols2 = new SymbolTable(identifiers.toMap)
+ val matchingContext = new MatchingContext(symbols2, Seq(), buildPatternGraph(symbols2, pathPattern))
+ val interestingPoints: Seq[String] = pathPattern.
+ flatMap(_.possibleStartPoints.map(_._1)).
+ filterNot(_.startsWith(" UNNAMED")).
+ distinct
+
+ def apply(m: Map[String, Any]): Any = {
+ val returnNull = interestingPoints.exists(key => m.get(key) match {
case None => throw new ThisShouldNotHappenError("Andres", "This execution plan should not exist.")
case Some(null) => true
case Some(x) => false
@@ -50,11 +59,18 @@ case class PathExpression(pathPattern: Seq[Pattern]) extends Expression with Pat
matches.map(getPath)
}
- def declareDependencies(extectedType: AnyType): Seq[Identifier] = pathPattern.flatMap(pattern => pattern.possibleStartPoints.filterNot(_.name.startsWith(" UNNAMED")))
-
def filter(f: (Expression) => Boolean): Seq[Expression] = Seq()
- val identifier: Identifier = Identifier(pathPattern.mkString(","), PathType())
-
def rewrite(f: (Expression) => Expression): Expression = f(PathExpression(pathPattern.map(_.rewrite(f))))
+
+ def calculateType(symbols: SymbolTable): CypherType = {
+ pathPattern.foreach(_.assertTypes(symbols))
+ new CollectionType(PathType())
+ }
+
+ def symbolTableDependencies = {
+ val patternDependencies = pathPattern.flatMap(_.symbolTableDependencies).toSet
+ val startPointDependencies = pathPattern.flatMap(_.possibleStartPoints).map(_._1).filterNot(_.startsWith(" UNNAMED")).toSet
+ patternDependencies ++ startPointDependencies
+ }
}
View
76 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Pattern.scala
@@ -19,24 +19,27 @@
*/
package org.neo4j.cypher.internal.commands
+import expressions.Expression
import org.neo4j.graphdb.Direction
-import java.lang.String
import collection.Seq
-import org.neo4j.cypher.internal.symbols.{PathType, RelationshipType, NodeType, Identifier}
+import org.neo4j.cypher.internal.symbols._
-
-abstract class Pattern {
+trait Pattern extends TypeSafe {
def optional: Boolean
def predicate: Predicate
- def possibleStartPoints: Seq[Identifier]
+ def possibleStartPoints: Seq[(String,CypherType)]
def relTypes:Seq[String]
protected def node(name: String) = if (name.startsWith(" UNNAMED")) "()" else name
- protected def left(dir: Direction) = if (dir == Direction.INCOMING) "<-" else "-"
- protected def right(dir: Direction) = if (dir == Direction.OUTGOING) "->" else "-"
+ protected def leftArrow(dir: Direction) = if (dir == Direction.INCOMING) "<-" else "-"
+ protected def rightArrow(dir: Direction) = if (dir == Direction.OUTGOING) "->" else "-"
def rewrite( f : Expression => Expression) : Pattern
def equalOrUnnamed(name1: String, name2: String) = name1 == name2 || (name1.startsWith(" UNNAMED") && name2.startsWith(" UNNAMED"))
+ protected def filtered(x:Seq[String]): Seq[String] =x.filter(!_.startsWith(" UNNAMED"))
+
+ def nodes:Seq[String]
+ def rels:Seq[String]
}
object RelatedTo {
@@ -44,8 +47,14 @@ object RelatedTo {
new RelatedTo(left, right, relName, Seq(relType), direction, optional, predicate)
}
-case class RelatedTo(left: String, right: String, relName: String, relTypes: Seq[String], direction: Direction, optional: Boolean, predicate: Predicate) extends Pattern {
- override def toString = node(left) + left(direction) + relInfo + right(direction) + node(right)
+case class RelatedTo(left: String,
+ right: String,
+ relName: String,
+ relTypes: Seq[String],
+ direction: Direction,
+ optional: Boolean,
+ predicate: Predicate) extends Pattern {
+ override def toString = node(left) + leftArrow(direction) + relInfo + rightArrow(direction) + node(right)
private def relInfo: String = {
var info = relName
@@ -54,9 +63,10 @@ case class RelatedTo(left: String, right: String, relName: String, relTypes: Seq
if (info == "") "" else "[" + info + "]"
}
- val possibleStartPoints: Seq[Identifier] = Seq(Identifier(left, NodeType()), Identifier(right, NodeType()), Identifier(relName, RelationshipType()))
+ val possibleStartPoints: Seq[(String, MapType)] = Seq(left-> NodeType(), right-> NodeType(), relName->RelationshipType())
- def rewrite(f: (Expression) => Expression) = new RelatedTo(left,right,relName,relTypes,direction,optional,predicate.rewrite(f))
+ def rewrite(f: (Expression) => Expression) =
+ new RelatedTo(left, right, relName, relTypes, direction, optional, predicate.rewrite(f))
override def equals(p1: Any): Boolean = p1 match {
case null => false
case other: RelatedTo =>
@@ -69,6 +79,16 @@ case class RelatedTo(left: String, right: String, relName: String, relTypes: Seq
other.predicate == predicate
case _ => false
}
+
+ def nodes = Seq(left,right)
+
+ def rels = Seq(relName)
+
+ def assertTypes(symbols: SymbolTable) {
+ predicate.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = predicate.symbolTableDependencies
}
abstract class PathPattern extends Pattern {
@@ -99,10 +119,11 @@ case class VarLengthRelatedTo(pathName: String,
optional: Boolean,
predicate: Predicate) extends PathPattern {
- override def toString: String = pathName + "=" + node(start) + left(direction) + relInfo + right(direction) + node(end)
+ override def toString: String = pathName + "=" + node(start) + leftArrow(direction) + relInfo + rightArrow(direction) + node(end)
+ def symbolTableDependencies = predicate.symbolTableDependencies
- def cloneWithOtherName(newName: String) = VarLengthRelatedTo(newName, start, end, minHops, maxHops, relTypes, direction, relIterator, optional, predicate)
+ def cloneWithOtherName(newName: String) = copy(pathName = newName)
private def relInfo: String = {
var info = if (optional) "?" else ""
@@ -120,7 +141,7 @@ case class VarLengthRelatedTo(pathName: String,
}
def rewrite(f: (Expression) => Expression) = new VarLengthRelatedTo(pathName,start,end, minHops,maxHops,relTypes,direction,relIterator,optional,predicate.rewrite(f))
- lazy val possibleStartPoints: Seq[Identifier] = Seq(Identifier(start, NodeType()), Identifier(end, NodeType()), Identifier(pathName, PathType()))
+ lazy val possibleStartPoints: Seq[(String, AnyType)] = Seq(start -> NodeType(), end -> NodeType(), pathName -> PathType())
override def equals(p1: Any): Boolean = p1 match {
case null => false
@@ -137,6 +158,14 @@ case class VarLengthRelatedTo(pathName: String,
other.predicate == predicate
case _ => false
}
+
+ def nodes = Seq(start,end)
+
+ def rels = Seq()
+
+ def assertTypes(symbols: SymbolTable) {
+ predicate.assertTypes(symbols)
+ }
}
case class ShortestPath(pathName: String,
@@ -150,13 +179,13 @@ case class ShortestPath(pathName: String,
relIterator: Option[String],
predicate: Predicate = True())
extends PathPattern {
- override def toString: String = pathName + "=" + algo + "(" + start + left(dir) + relInfo + right(dir) + end + ")"
+ override def toString: String = pathName + "=" + algo + "(" + start + leftArrow(dir) + relInfo + rightArrow(dir) + end + ")"
private def algo = if (single) "singleShortestPath" else "allShortestPath"
- def dependencies: Seq[Identifier] = Seq(Identifier(start, NodeType()), Identifier(end, NodeType())) ++ predicate.dependencies
+ def cloneWithOtherName(newName: String) = copy(pathName = newName)
- def cloneWithOtherName(newName: String) = ShortestPath(newName, start, end, relTypes, dir, maxDepth, optional, single, None)
+ def symbolTableDependencies = predicate.symbolTableDependencies ++ Set(start, end)
private def relInfo: String = {
var info = "["
@@ -167,7 +196,16 @@ case class ShortestPath(pathName: String,
info + "]"
}
- lazy val possibleStartPoints: Seq[Identifier] = Seq(Identifier(start, NodeType()), Identifier(end, NodeType()))
+ lazy val possibleStartPoints: Seq[(String, NodeType)] = Seq(start-> NodeType(), end-> NodeType())
+
+ def rewrite(f: Expression => Expression) = new ShortestPath(pathName,start,end,relTypes,dir,maxDepth,optional,single,relIterator,predicate.rewrite(f))
- def rewrite(f: (Expression) => Expression) = new ShortestPath(pathName,start,end,relTypes,dir,maxDepth,optional,single,relIterator,predicate.rewrite(f))
+ def rels = Seq()
+
+ def nodes = Seq(start,end)
+
+ def assertTypes(symbols: SymbolTable) {
+ possibleStartPoints.foreach(p => symbols.evaluateType(p._1, p._2))
+ predicate.assertTypes(symbols)
+ }
}
View
149 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Predicate.scala
@@ -19,28 +19,32 @@
*/
package org.neo4j.cypher.internal.commands
+import expressions.{Literal, Property, Expression}
import java.lang.String
import collection.Seq
import scala.collection.JavaConverters._
import org.neo4j.graphdb.{DynamicRelationshipType, Node, Direction, PropertyContainer}
-import org.neo4j.cypher.internal.pipes.Dependant
import org.neo4j.cypher.internal.symbols._
import org.neo4j.helpers.ThisShouldNotHappenError
import collection.Map
-import org.neo4j.cypher.SyntaxException
+import org.neo4j.cypher.CypherTypeException
-abstract class Predicate extends Dependant {
+abstract class Predicate extends Expression {
+ def apply(m: Map[String, Any]) = isMatch(m)
def ++(other: Predicate): Predicate = And(this, other)
-
def isMatch(m: Map[String, Any]): Boolean
// This is the un-dividable list of predicates. They can all be ANDed
// together
def atoms: Seq[Predicate]
- def exists(f:Expression=>Boolean):Boolean
- def rewrite(f:Expression=>Expression):Predicate
- def containsIsNull:Boolean
+ def rewrite(f: Expression => Expression): Predicate
+ def containsIsNull: Boolean
def filter(f: Expression => Boolean): Seq[Expression]
+ def assertInnerTypes(symbols: SymbolTable)
+ protected def calculateType(symbols: SymbolTable) = {
+ assertInnerTypes(symbols)
+ BooleanType()
+ }
}
case class NullablePredicate(inner: Predicate, exp: Seq[(Expression, Boolean)]) extends Predicate {
@@ -56,9 +60,7 @@ case class NullablePredicate(inner: Predicate, exp: Seq[(Expression, Boolean)])
}
def atoms = Seq(this)
- def dependencies = inner.dependencies
- override def toString = "nullable([" + exp.mkString(",") +"],[" +inner.toString+"])"
- def exists(f: (Expression) => Boolean) = inner.exists(f)
+ override def toString() = "nullable([" + exp.mkString(",") +"],[" +inner.toString+"])"
def containsIsNull = inner.containsIsNull
def rewrite(f: (Expression) => Expression) = NullablePredicate(inner.rewrite(f), exp.map {
@@ -66,40 +68,59 @@ case class NullablePredicate(inner: Predicate, exp: Seq[(Expression, Boolean)])
})
def filter(f: (Expression) => Boolean) = exp.flatMap { case (e,_) => e.filter(f) }
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ inner.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = inner.symbolTableDependencies ++ exp.flatMap(_._1.symbolTableDependencies).toSet
}
case class And(a: Predicate, b: Predicate) extends Predicate {
def isMatch(m: Map[String, Any]): Boolean = a.isMatch(m) && b.isMatch(m)
def atoms: Seq[Predicate] = a.atoms ++ b.atoms
- def dependencies: Seq[Identifier] = a.dependencies ++ b.dependencies
- override def toString: String = "(" + a + " AND " + b + ")"
- def exists(f: (Expression) => Boolean) = a.exists(f) || b.exists(f)
+ override def toString(): String = "(" + a + " AND " + b + ")"
def containsIsNull = a.containsIsNull||b.containsIsNull
def rewrite(f: (Expression) => Expression) = And(a.rewrite(f), b.rewrite(f))
def filter(f: (Expression) => Boolean) = a.filter(f) ++ b.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.assertTypes(symbols)
+ b.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = a.symbolTableDependencies ++ b.symbolTableDependencies
}
case class Or(a: Predicate, b: Predicate) extends Predicate {
def isMatch(m: Map[String, Any]): Boolean = a.isMatch(m) || b.isMatch(m)
def atoms: Seq[Predicate] = Seq(this)
- def dependencies: Seq[Identifier] = a.dependencies ++ b.dependencies
- override def toString: String = "(" + a + " OR " + b + ")"
- def exists(f: (Expression) => Boolean) = a.exists(f) || b.exists(f)
+ override def toString(): String = "(" + a + " OR " + b + ")"
def containsIsNull = a.containsIsNull||b.containsIsNull
def rewrite(f: (Expression) => Expression) = Or(a.rewrite(f), b.rewrite(f))
def filter(f: (Expression) => Boolean) = a.filter(f) ++ b.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.assertTypes(symbols)
+ b.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = a.symbolTableDependencies ++ b.symbolTableDependencies
}
case class Not(a: Predicate) extends Predicate {
def isMatch(m: Map[String, Any]): Boolean = !a.isMatch(m)
def atoms: Seq[Predicate] = a.atoms.map(Not(_))
- def dependencies: Seq[Identifier] = a.dependencies
- override def toString: String = "NOT(" + a + ")"
- def exists(f: (Expression) => Boolean) = a.exists(f)
+ override def toString(): String = "NOT(" + a + ")"
def containsIsNull = a.containsIsNull
def rewrite(f: (Expression) => Expression) = Not(a.rewrite(f))
def filter(f: (Expression) => Boolean) = a.filter(f)
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = a.symbolTableDependencies
}
case class HasRelationshipTo(from: Expression, to: Expression, dir: Direction, relType: Seq[String]) extends Predicate {
@@ -121,11 +142,15 @@ case class HasRelationshipTo(from: Expression, to: Expression, dir: Direction, r
}
def atoms: Seq[Predicate] = Seq(this)
- def exists(f: (Expression) => Boolean) = from.exists(f) || to.exists(f)
- def dependencies: Seq[Identifier] = from.dependencies(NodeType()) ++ to.dependencies(NodeType())
def containsIsNull = false
def rewrite(f: (Expression) => Expression) = HasRelationshipTo(from.rewrite(f), to.rewrite(f), dir, relType)
def filter(f: (Expression) => Boolean) = from.filter(f) ++ to.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ from.assertTypes(symbols)
+ to.assertTypes(symbols)
+ }
+ def symbolTableDependencies = from.symbolTableDependencies ++ to.symbolTableDependencies
}
case class HasRelationship(from: Expression, dir: Direction, relType: Seq[String]) extends Predicate {
@@ -144,33 +169,41 @@ case class HasRelationship(from: Expression, dir: Direction, relType: Seq[String
}
def atoms: Seq[Predicate] = Seq(this)
- def exists(f: (Expression) => Boolean) = from.exists(f)
- def dependencies: Seq[Identifier] = from.dependencies(NodeType())
def containsIsNull = false
def filter(f: (Expression) => Boolean) = from.filter(f)
def rewrite(f: (Expression) => Expression) = HasRelationship(from.rewrite(f), dir, relType)
+ def assertInnerTypes(symbols: SymbolTable) {
+ from.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = from.symbolTableDependencies
}
case class IsNull(expression: Expression) extends Predicate {
def isMatch(m: Map[String, Any]): Boolean = expression(m) == null
- def dependencies: Seq[Identifier] = expression.dependencies(AnyType())
def atoms: Seq[Predicate] = Seq(this)
- override def toString: String = expression + " IS NULL"
- def exists(f: (Expression) => Boolean) = expression.exists(f)
+ override def toString(): String = expression + " IS NULL"
def containsIsNull = true
def rewrite(f: (Expression) => Expression) = IsNull(expression.rewrite(f))
def filter(f: (Expression) => Boolean) = expression.filter(f)
+ def assertInnerTypes(symbols: SymbolTable) {
+ expression.assertTypes(symbols)
+ }
+ def symbolTableDependencies = expression.symbolTableDependencies
}
case class True() extends Predicate {
def isMatch(m: Map[String, Any]): Boolean = true
- def dependencies: Seq[Identifier] = Seq()
def atoms: Seq[Predicate] = Seq(this)
- override def toString: String = "true"
- def exists(f: (Expression) => Boolean) = false
+ override def toString(): String = "true"
def containsIsNull = false
def rewrite(f: (Expression) => Expression) = True()
- def filter(f: (Expression) => Boolean) = Seq()
+ def filter(f: (Expression) => Boolean) = if (f(this))
+ Seq(this)
+ else
+ Seq()
+ def assertInnerTypes(symbols: SymbolTable) {}
+ def symbolTableDependencies = Set()
}
case class Has(property: Property) extends Predicate {
@@ -181,16 +214,19 @@ case class Has(property: Property) extends Predicate {
}
}
- def dependencies: Seq[Identifier] = property.dependencies(MapType())
def atoms: Seq[Predicate] = Seq(this)
- override def toString: String = "hasProp(" + property + ")"
+ override def toString(): String = "hasProp(" + property + ")"
def containsIsNull = false
- def exists(f: (Expression) => Boolean) = false
def rewrite(f: (Expression) => Expression) = property.rewrite(f) match {
case prop:Property => Has(prop)
case _ => throw new ThisShouldNotHappenError("Andres", "Something went wrong rewriting a Has(Property)")
}
def filter(f: (Expression) => Boolean) = property.filter(f)
+ def assertInnerTypes(symbols: SymbolTable) {
+ property.assertTypes(symbols)
+ }
+
+ def symbolTableDependencies = property.symbolTableDependencies
}
case class LiteralRegularExpression(a: Expression, regex: Literal) extends Predicate {
@@ -198,14 +234,19 @@ case class LiteralRegularExpression(a: Expression, regex: Literal) extends Predi
def isMatch(m: Map[String, Any]) = pattern.matcher(a(m).asInstanceOf[String]).matches()
def atoms = Seq(this)
- def exists(f: (Expression) => Boolean) = a.exists(f) || regex.exists(f)
- def dependencies = a.dependencies(AnyType())
def containsIsNull = false
def rewrite(f: (Expression) => Expression) = regex.rewrite(f) match {
case lit:Literal => LiteralRegularExpression(a.rewrite(f), lit)
case other => RegularExpression(a.rewrite(f), other)
}
def filter(f: (Expression) => Boolean) = a.filter(f) ++ regex.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.evaluateType(StringType(), symbols)
+ regex.evaluateType(StringType(), symbols)
+ }
+
+ def symbolTableDependencies = a.symbolTableDependencies ++ regex.symbolTableDependencies
}
case class RegularExpression(a: Expression, regex: Expression) extends Predicate {
@@ -216,36 +257,40 @@ case class RegularExpression(a: Expression, regex: Expression) extends Predicate
regularExp.r.pattern.matcher(value).matches()
}
- def dependencies: Seq[Identifier] = a.dependencies(StringType()) ++ regex.dependencies(StringType())
def atoms: Seq[Predicate] = Seq(this)
- override def toString: String = a.toString() + " ~= /" + regex.toString() + "/"
- def exists(f: (Expression) => Boolean) = a.exists(f)||regex.exists(f)
+ override def toString(): String = a.toString() + " ~= /" + regex.toString() + "/"
def containsIsNull = false
def rewrite(f: (Expression) => Expression) = regex.rewrite(f) match {
case lit:Literal => LiteralRegularExpression(a.rewrite(f), lit)
case other => RegularExpression(a.rewrite(f), other)
}
def filter(f: (Expression) => Boolean) = a.filter(f) ++ regex.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ a.evaluateType(StringType(), symbols)
+ regex.evaluateType(StringType(), symbols)
+ }
+ def symbolTableDependencies = a.symbolTableDependencies ++ regex.symbolTableDependencies
}
-case class NonEmpty(inner:Expression) extends Predicate with IterableSupport {
+case class NonEmpty(collection:Expression) extends Predicate with CollectionSupport {
def isMatch(m: Map[String, Any]): Boolean = {
- val collection = inner(m)
- if (this.isCollection(collection)) {
- this.makeTraversable(inner(m)).nonEmpty
- } else if(collection == null) {
- false
- } else {
- throw new SyntaxException("wut")
+ collection(m) match {
+ case IsCollection(x) => this.makeTraversable(collection(m)).nonEmpty
+ case null => false
+ case x => throw new CypherTypeException("Expected a collection, got `%s`".format(x))
}
-
}
- def dependencies: Seq[Identifier] = inner.dependencies(AnyIterableType())
def atoms: Seq[Predicate] = Seq(this)
- override def toString: String = "nonEmpty(" + inner.identifier.name + ")"
+ override def toString(): String = "nonEmpty(" + collection + ")"
def containsIsNull = false
- def exists(f: (Expression) => Boolean) = inner.exists(f)
- def rewrite(f: (Expression) => Expression) = NonEmpty(inner.rewrite(f))
- def filter(f: (Expression) => Boolean) = inner.filter(f)
+ def rewrite(f: (Expression) => Expression) = NonEmpty(collection.rewrite(f))
+ def filter(f: (Expression) => Boolean) = collection.filter(f)
+
+ def assertInnerTypes(symbols: SymbolTable) {
+ collection.evaluateType(AnyCollectionType(), symbols)
+ }
+
+ def symbolTableDependencies = collection.symbolTableDependencies
}
View
1  cypher/src/main/scala/org/neo4j/cypher/internal/commands/Query.scala
@@ -20,6 +20,7 @@
package org.neo4j.cypher.internal.commands
import org.neo4j.cypher.internal.mutation.{CreateUniqueAction, UniqueLink, UpdateAction}
+import expressions.{Expression, AggregationExpression}
object Query {
def start(startItems: StartItem*) = new QueryBuilder(startItems)
View
1  cypher/src/main/scala/org/neo4j/cypher/internal/commands/QueryBuilder.scala
@@ -19,6 +19,7 @@
*/
package org.neo4j.cypher.internal.commands
+import expressions.{ParameterExpression, Literal, Expression, AggregationExpression}
import org.neo4j.cypher.internal.mutation.UpdateAction
class QueryBuilder(startItems: Seq[StartItem]) {
View
33 cypher/src/main/scala/org/neo4j/cypher/internal/commands/ReturnItem.scala
@@ -19,38 +19,29 @@
*/
package org.neo4j.cypher.internal.commands
-import org.neo4j.cypher.internal.pipes.Dependant
+import expressions.{Identifier, Expression}
import org.neo4j.cypher.internal.symbols._
+import collection.Map
-abstract class ReturnColumn extends Dependant {
- def expressions(symbols: SymbolTable): Seq[Expression]
+abstract class ReturnColumn {
+ def expressions(symbols: SymbolTable): Map[String,Expression]
def name: String
}
case class AllIdentifiers() extends ReturnColumn {
- def expressions(symbols: SymbolTable) = symbols.identifiers.flatMap {
- case Identifier(name, _) if name.startsWith(" UNNAMED") => None
- case Identifier(name, typ) if MapType().isAssignableFrom(typ) => Some(Entity(name))
- case Identifier(name, typ) if PathType().isAssignableFrom(typ) => Some(Entity(name))
- case _ => None
- }
+ def expressions(symbols: SymbolTable): Map[String, Expression] = symbols.identifiers.keys.
+ filterNot(_.startsWith(" UNNAMED")).
+ map(n => n -> Identifier(n)).toMap
def name = "*"
-
- def dependencies = Seq()
}
-case class ReturnItem(expression: Expression, name: String, renamed: Boolean = false) extends ReturnColumn {
- def expressions(symbols: SymbolTable) = Seq(expression)
-
- val dependencies = expression.dependencies(AnyType())
-
- val identifier = Identifier(name, expression.identifier.typ)
-
- val columnName = identifier.name
+case class ReturnItem(expression: Expression, name: String, renamed: Boolean = false)
+ extends ReturnColumn {
+ def expressions(symbols: SymbolTable) = Map(name -> expression)
- override def toString() = identifier.name
+ override def toString = name
- def rename(newName: String) = ReturnItem(expression, newName, true)
+ def rename(newName: String) = ReturnItem(expression, newName, renamed = true)
}
View
9 cypher/src/main/scala/org/neo4j/cypher/internal/commands/SortItem.scala
@@ -19,11 +19,14 @@
*/
package org.neo4j.cypher.internal.commands
+import expressions.{CachedExpression, Identifier, Expression}
import java.lang.String
+import org.neo4j.helpers.ThisShouldNotHappenError