Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Andres Taylor authored

Showing 230 changed files with 5,029 additions and 3,007 deletions. Show diff stats Hide diff stats

  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
7 cypher/CHANGES.txt
... ... @@ -1,3 +1,10 @@
  1 +1.9
  2 +--------------------
  3 +o Refactored the type system from the bottom up
  4 +o Predicates can now be returned and used to set properties
  5 +o Fixes #797: CREATE UNIQUE now makes sure used identifiers have the same properties even if
  6 + they are re-used without the properties
  7 +
1 8 1.8.RC1 (2012-09-05)
2 9 --------------------
3 10 o Removed the /../ literal for regular expressions. Now a normal string literal is used instead
6 cypher/pom.xml
@@ -125,6 +125,12 @@
125 125 <phase>process-test-resources</phase>
126 126 </execution>
127 127 </executions>
  128 + <configuration>
  129 + <jvmArgs>
  130 + <jvmArg>-Xms64m</jvmArg>
  131 + <jvmArg>-Xmx1024m</jvmArg>
  132 + </jvmArgs>
  133 + </configuration>
128 134 </plugin>
129 135 <plugin>
130 136 <artifactId>maven-site-plugin</artifactId>
3  cypher/src/main/java/org/neo4j/cypher/javacompat/CypherParser.java
@@ -45,7 +45,8 @@ public static Query parseStrict(String query) throws SyntaxException {
45 45 return new org.neo4j.cypher.CypherParser().parse( query );
46 46 }
47 47
  48 + @Deprecated
48 49 public static Query parseConsole(String query) throws SyntaxException {
49   - return new org.neo4j.cypher.internal.parser.v1_6.ConsoleCypherParser().parse( query );
  50 + return new org.neo4j.cypher.CypherParser().parse( query );
50 51 }
51 52 }
4 cypher/src/main/scala/org/neo4j/cypher/CypherException.scala
@@ -19,7 +19,7 @@
19 19 */
20 20 package org.neo4j.cypher
21 21
22   -import internal.commands.Expression
  22 +import internal.commands.expressions.Expression
23 23
24 24 abstract class CypherException(message: String, cause: Throwable) extends RuntimeException(message, cause) {
25 25 def this(message:String) = this(message, null)
@@ -33,7 +33,7 @@ class CypherTypeException(message: String, cause: Throwable = null) extends Cyph
33 33
34 34 class IterableRequiredException(message:String, cause:Throwable) extends CypherException(message, cause) {
35 35 def this(message:String) = this(message, null)
36   - def this(expression:Expression) = this("Expected " + expression.identifier.name + " to be a collection, but it is not.", null)
  36 + def this(expression:Expression) = this("Expected " + expression + " to be an collection, but it is not.", null)
37 37 }
38 38
39 39 class ParameterNotFoundException(message:String, cause:Throwable) extends CypherException(message, cause) {
8 cypher/src/main/scala/org/neo4j/cypher/CypherParser.scala
@@ -22,13 +22,13 @@ package org.neo4j.cypher
22 22 import internal.commands.Query
23 23
24 24 class CypherParser(version: String) {
25   - def this() = this ("1.8")
  25 + def this() = this("1.9")
26 26
27 27 val hasVersionDefined = """(?si)^\s*cypher\s*([^\s]+)\s*(.*)""".r
28 28
29   - val v16 = new internal.parser.v1_6.CypherParserImpl
30 29 val v17 = new internal.parser.v1_7.CypherParserImpl
31 30 val v18 = new internal.parser.v1_8.CypherParserImpl
  31 + val v19 = new internal.parser.v1_9.CypherParserImpl
32 32
33 33 @throws(classOf[SyntaxException])
34 34 def parse(queryText: String): Query = {
@@ -39,10 +39,10 @@ class CypherParser(version: String) {
39 39 }
40 40
41 41 v match {
42   - case "1.6" => v16.parse(q)
43 42 case "1.7" => v17.parse(q)
44 43 case "1.8" => v18.parse(q)
45   - case _ => throw new SyntaxException("Versions supported are 1.6, 1.7 and 1.8")
  44 + case "1.9" => v19.parse(q)
  45 + case _ => throw new SyntaxException("Versions supported are 1.7, 1.8 and 1.9")
46 46 }
47 47 }
48 48 }
7 cypher/src/main/scala/org/neo4j/cypher/EagerPipeExecutionResult.scala
@@ -20,17 +20,14 @@
20 20 package org.neo4j.cypher
21 21
22 22 import internal.pipes.QueryState
23   -import internal.symbols.SymbolTable
24   -import org.neo4j.graphdb.{Transaction, GraphDatabaseService}
25   -import org.neo4j.kernel.GraphDatabaseAPI
  23 +import org.neo4j.graphdb.GraphDatabaseService
26 24 import collection.Map
27 25
28 26 class EagerPipeExecutionResult(r: => Traversable[Map[String, Any]],
29   - symbols: SymbolTable,
30 27 columns: List[String],
31 28 state: QueryState,
32 29 db: GraphDatabaseService)
33   - extends PipeExecutionResult(r, symbols, columns) {
  30 + extends PipeExecutionResult(r, columns) {
34 31
35 32 override lazy val queryStatistics = QueryStatistics(
36 33 nodesCreated = state.createdNodes.count,
2  cypher/src/main/scala/org/neo4j/cypher/ExecutionEngine.scala
@@ -40,7 +40,7 @@ class ExecutionEngine(graph: GraphDatabaseService) {
40 40 val database = graph.asInstanceOf[InternalAbstractGraphDatabase]
41 41 database.getConfig.getParams.asScala.get("cypher_parser_version") match {
42 42 case None => new CypherParser()
43   - case Some(v) => new CypherParser(v.toString)
  43 + case Some(v) => new CypherParser(v)
44 44 }
45 45 }
46 46 else {
3  cypher/src/main/scala/org/neo4j/cypher/ExecutionResult.scala
@@ -21,12 +21,9 @@ package org.neo4j.cypher
21 21
22 22 import java.io.PrintWriter
23 23 import java.lang.String
24   -import internal.symbols.SymbolTable
25   -
26 24
27 25 trait ExecutionResult extends Iterator[Map[String, Any]] {
28 26 def columns: List[String]
29   - def symbols: SymbolTable
30 27 def javaColumns: java.util.List[String]
31 28 def javaColumnAs[T](column: String): java.util.Iterator[T]
32 29 def columnAs[T](column: String): Iterator[T]
9 cypher/src/main/scala/org/neo4j/cypher/PipeExecutionResult.scala
@@ -19,20 +19,19 @@
19 19 */
20 20 package org.neo4j.cypher
21 21
22   -import internal.commands.{IterableSupport, IsIterable}
  22 +import internal.commands.{CollectionSupport, IsCollection}
23 23 import internal.StringExtras
24 24 import scala.collection.JavaConverters._
25 25 import org.neo4j.graphdb.{PropertyContainer, Relationship, Node}
26 26 import java.io.{StringWriter, PrintWriter}
27 27 import java.lang.String
28   -import internal.symbols.SymbolTable
29 28 import collection.Map
30 29 import collection.immutable.{Map => ImmutableMap}
31 30
32   -class PipeExecutionResult(r: => Traversable[Map[String, Any]], val symbols: SymbolTable, val columns: List[String])
  31 +class PipeExecutionResult(r: => Traversable[Map[String, Any]], val columns: List[String])
33 32 extends ExecutionResult
34 33 with StringExtras
35   - with IterableSupport {
  34 + with CollectionSupport {
36 35
37 36 lazy val immutableResult = r.map(m => m.toMap)
38 37
@@ -134,7 +133,7 @@ class PipeExecutionResult(r: => Traversable[Map[String, Any]], val symbols: Symb
134 133 private def text(obj: Any): String = obj match {
135 134 case x: Node => x.toString + props(x)
136 135 case x: Relationship => ":" + x.getType.toString + "[" + x.getId + "] " + props(x)
137   - case IsIterable(coll) => coll.map(text).mkString("[", ",", "]")
  136 + case IsCollection(coll) => coll.map(text).mkString("[", ",", "]")
138 137 case x: String => "\"" + x + "\""
139 138 case Some(x) => x.toString
140 139 case null => "<null>"
7 cypher/src/main/scala/org/neo4j/cypher/internal/ReattachAliasedExpressions.scala
@@ -20,6 +20,7 @@
20 20 package org.neo4j.cypher.internal
21 21
22 22 import commands._
  23 +import expressions.{Identifier, Expression}
23 24
24 25
25 26 /*
@@ -38,15 +39,15 @@ object ReattachAliasedExpressions {
38 39 }
39 40
40 41 private def expressionRewriter(returnColumns: Seq[ReturnColumn])(expression: Expression): Expression = expression match {
41   - case e: Entity => {
  42 + case e@Identifier(entityName) =>
42 43 val returnItems = keepReturnItems(returnColumns)
43 44 val found = returnItems.find(_.name == e.entityName)
44 45
45 46 found match {
46   - case None => e
  47 + case None => e
47 48 case Some(returnItem) => returnItem.expression
48 49 }
49   - }
  50 +
50 51 case somethingElse => somethingElse
51 52 }
52 53
165 cypher/src/main/scala/org/neo4j/cypher/internal/commands/AggregationExpression.scala
... ... @@ -1,165 +0,0 @@
1   -/**
2   - * Copyright (c) 2002-2012 "Neo Technology,"
3   - * Network Engine for Objects in Lund AB [http://neotechnology.com]
4   - *
5   - * This file is part of Neo4j.
6   - *
7   - * Neo4j is free software: you can redistribute it and/or modify
8   - * it under the terms of the GNU General Public License as published by
9   - * the Free Software Foundation, either version 3 of the License, or
10   - * (at your option) any later version.
11   - *
12   - * This program is distributed in the hope that it will be useful,
13   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   - * GNU General Public License for more details.
16   - *
17   - * You should have received a copy of the GNU General Public License
18   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
19   - */
20   -package org.neo4j.cypher.internal.commands
21   -
22   -import collection.Seq
23   -import org.neo4j.cypher.internal.pipes.aggregation._
24   -import org.neo4j.cypher.internal.symbols._
25   -import org.neo4j.cypher.SyntaxException
26   -import collection.Map
27   -abstract class AggregationExpression extends Expression {
28   - def compute(m: Map[String, Any]) = m.get(name) match {
29   - case None => null
30   - case Some(x) => x
31   - }
32   -
33   - override val identifier = Identifier(name, typ)
34   -
35   - def name: String
36   -
37   - def typ: AnyType
38   -
39   - def createAggregationFunction: AggregationFunction
40   -}
41   -
42   -case class CountStar() extends AggregationExpression {
43   - def name = "count(*)"
44   -
45   - def typ = LongType()
46   -
47   - def declareDependencies(extectedType: AnyType) = Seq()
48   -
49   - def rewrite(f: (Expression) => Expression) = f(CountStar())
50   -
51   - def createAggregationFunction = new CountStarFunction
52   -
53   - def filter(f: (Expression) => Boolean) = if (f(this))
54   - Seq(this)
55   - else
56   - Seq()
57   -
58   - override def toString() = "count(*)"
59   -}
60   -
61   -abstract class AggregationWithInnerExpression(inner:Expression) extends AggregationExpression {
62   - if(inner.containsAggregate)
63   - throw new SyntaxException("Can't use aggregate functions inside of aggregate functions.")
64   -
65   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = inner.dependencies(expectedInnerType)
66   - def expectedInnerType: AnyType
67   -
68   - override val identifier = Identifier("%s(%s)".format(name, inner.identifier.name), typ)
69   -
70   - def filter(f: (Expression) => Boolean) = if (f(this))
71   - Seq(this) ++ inner.filter(f)
72   - else
73   - inner.filter(f)
74   -}
75   -
76   -case class Distinct(innerAggregator: AggregationExpression, expression: Expression) extends AggregationWithInnerExpression(expression) {
77   - def typ = innerAggregator.identifier.typ
78   -
79   - override val identifier = Identifier("%s(distinct %s)".format(innerAggregator.name, expression.identifier.name), innerAggregator.identifier.typ)
80   -
81   - def expectedInnerType: AnyType = AnyType()
82   -
83   - def name = "distinct"
84   -
85   - def createAggregationFunction = new DistinctFunction(expression, innerAggregator.createAggregationFunction)
86   -
87   - override def declareDependencies(extectedType: AnyType): Seq[Identifier] = innerAggregator.dependencies(extectedType) ++ expression.dependencies(AnyType())
88   -
89   - def rewrite(f: (Expression) => Expression) = innerAggregator.rewrite(f) match {
90   - case inner: AggregationExpression => f(Distinct(inner, expression.rewrite(f)))
91   - case _ => f(Distinct(innerAggregator, expression.rewrite(f)))
92   - }
93   -}
94   -
95   -case class Count(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
96   - def typ = IntegerType()
97   -
98   - def name = "count"
99   -
100   - def createAggregationFunction = new CountFunction(anInner)
101   -
102   - def expectedInnerType: AnyType = AnyType()
103   -
104   - def rewrite(f: (Expression) => Expression) = f(Count(anInner.rewrite(f)))
105   -}
106   -
107   -case class Sum(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
108   - def typ = NumberType()
109   -
110   - def name = "sum"
111   -
112   - def createAggregationFunction = new SumFunction(anInner)
113   -
114   - def expectedInnerType: AnyType = NumberType()
115   -
116   - def rewrite(f: (Expression) => Expression) = f(Sum(anInner.rewrite(f)))
117   -}
118   -
119   -case class Min(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
120   - def typ = NumberType()
121   -
122   - def name = "min"
123   -
124   - def createAggregationFunction = new MinFunction(anInner)
125   -
126   - def expectedInnerType: AnyType = NumberType()
127   -
128   - def rewrite(f: (Expression) => Expression) = f(Min(anInner.rewrite(f)))
129   -}
130   -
131   -case class Max(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
132   - def typ = NumberType()
133   -
134   - def name = "max"
135   -
136   - def createAggregationFunction = new MaxFunction(anInner)
137   -
138   - def expectedInnerType: AnyType = NumberType()
139   -
140   - def rewrite(f: (Expression) => Expression) = f(Max(anInner.rewrite(f)))
141   -}
142   -
143   -case class Avg(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
144   - def typ = NumberType()
145   -
146   - def name = "avg"
147   -
148   - def createAggregationFunction = new AvgFunction(anInner)
149   -
150   - def expectedInnerType: AnyType = NumberType()
151   -
152   - def rewrite(f: (Expression) => Expression) = f(Avg(anInner.rewrite(f)))
153   -}
154   -
155   -case class Collect(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
156   - def typ = new CollectionType(anInner.identifier.typ)
157   -
158   - def name = "collect"
159   -
160   - def createAggregationFunction = new CollectFunction(anInner)
161   -
162   - def expectedInnerType: AnyType = AnyType()
163   -
164   - def rewrite(f: (Expression) => Expression) = f(Collect(anInner.rewrite(f)))
165   -}
29 cypher/src/main/scala/org/neo4j/cypher/internal/commands/ComparablePredicate.scala
@@ -20,9 +20,10 @@
20 20 package org.neo4j.cypher.internal.commands
21 21
22 22 import collection.Seq
  23 +import expressions.Expression
23 24 import org.neo4j.cypher.internal.Comparer
24 25 import java.lang.String
25   -import org.neo4j.cypher.internal.symbols.{AnyType, ScalarType, Identifier}
  26 +import org.neo4j.cypher.internal.symbols._
26 27 import collection.Map
27 28
28 29 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
37 38 compare(comparisonResult)
38 39 }
39 40
40   - def dependencies: Seq[Identifier] = left.dependencies(ScalarType()) ++ right.dependencies(ScalarType())
41 41 def sign: String
42 42 def atoms: Seq[Predicate] = Seq(this)
43   - override def toString = left.toString() + " " + sign + " " + right.toString()
44   - def exists(f: (Expression) => Boolean) = left.exists(f) || right.exists(f)
  43 + override def toString() = left.toString() + " " + sign + " " + right.toString()
45 44 def containsIsNull = false
46 45 def filter(f: (Expression) => Boolean): Seq[Expression] = left.filter(f) ++ right.filter(f)
  46 +
  47 + def assertInnerTypes(symbols: SymbolTable) {
  48 + left.assertTypes(symbols)
  49 + right.assertTypes(symbols)
  50 + }
  51 +
  52 + def symbolTableDependencies = left.symbolTableDependencies ++ right.symbolTableDependencies
47 53 }
48 54
49 55 case class Equals(a: Expression, b: Expression) extends Predicate with Comparer {
  56 +
50 57 def isMatch(m: Map[String, Any]): Boolean = {
51 58 val a1 = a(m)
52 59 val b1 = b(m)
53 60
54 61 (a1, b1) match {
55   - case (IsIterable(l), IsIterable(r)) => l == r
  62 + case (IsCollection(l), IsCollection(r)) => l == r
56 63 case _ => a1 == b1
57 64 }
58 65 }
  66 +
59 67 def atoms = Seq(this)
60   - def exists(f: (Expression) => Boolean) = a.exists(f) || b.exists(f)
61   - def dependencies = a.dependencies(AnyType()) ++ b.dependencies(AnyType())
62   - override def toString = a.toString() + " == " + b.toString()
  68 + override def toString() = a.toString() + " == " + b.toString()
63 69 def containsIsNull = false
64 70 def rewrite(f: (Expression) => Expression) = Equals(a.rewrite(f), b.rewrite(f))
65 71 def filter(f: (Expression) => Boolean): Seq[Expression] = a.filter(f) ++ b.filter(f)
  72 +
  73 + def assertInnerTypes(symbols: SymbolTable) {
  74 + a.assertTypes(symbols)
  75 + b.assertTypes(symbols)
  76 + }
  77 +
  78 + def symbolTableDependencies = a.symbolTableDependencies ++ b.symbolTableDependencies
66 79 }
67 80
68 81 case class LessThan(a: Expression, b: Expression) extends ComparablePredicate(a, b) {
278 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
... ... @@ -1,278 +0,0 @@
1   -/**
2   - * Copyright (c) 2002-2012 "Neo Technology,"
3   - * Network Engine for Objects in Lund AB [http://neotechnology.com]
4   - *
5   - * This file is part of Neo4j.
6   - *
7   - * Neo4j is free software: you can redistribute it and/or modify
8   - * it under the terms of the GNU General Public License as published by
9   - * the Free Software Foundation, either version 3 of the License, or
10   - * (at your option) any later version.
11   - *
12   - * This program is distributed in the hope that it will be useful,
13   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   - * GNU General Public License for more details.
16   - *
17   - * You should have received a copy of the GNU General Public License
18   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
19   - */
20   -package org.neo4j.cypher.internal.commands
21   -
22   -import java.lang.String
23   -import org.neo4j.cypher._
24   -import internal.symbols._
25   -import org.neo4j.graphdb.{NotFoundException, PropertyContainer}
26   -import collection.Map
27   -
28   -abstract class Expression extends (Map[String, Any] => Any) {
29   - protected def compute(v1: Map[String, Any]) : Any
30   - def apply(m: Map[String, Any]) = m.getOrElse(identifier.name, compute(m))
31   -
32   - val identifier: Identifier
33   - def declareDependencies(expectedType: AnyType): Seq[Identifier]
34   - def dependencies(expectedType: AnyType): Seq[Identifier] = {
35   - val myType = identifier.typ
36   - if (!expectedType.isAssignableFrom(myType) &&
37   - !myType.isAssignableFrom(expectedType))
38   - throw new SyntaxException("`%s` expected to be a %s but it is a %s".format(identifier.name, expectedType, identifier.typ))
39   - declareDependencies(expectedType)
40   - }
41   -
42   - def rewrite(f: Expression => Expression): Expression
43   - def exists(f: Expression => Boolean) = filter(f).nonEmpty
44   - def filter(f: Expression => Boolean): Seq[Expression]
45   - def subExpressions = filter( _ != this)
46   - def containsAggregate = exists(_.isInstanceOf[AggregationExpression])
47   - override def toString() = identifier.name
48   -}
49   -
50   -case class CachedExpression(key:String, identifier:Identifier) extends CastableExpression {
51   - override def apply(m: Map[String, Any]) = m(key)
52   - protected def compute(v1: Map[String, Any]) = null
53   - def declareDependencies(extectedType: AnyType) = Seq()
54   - def rewrite(f: (Expression) => Expression) = f(this)
55   - def filter(f: (Expression) => Boolean) = if(f(this)) Seq(this) else Seq()
56   - override def toString() = "Cached(" + super.toString() + ")"
57   -}
58   -
59   -case class Null() extends Expression {
60   - protected def compute(v1: Map[String, Any]) = null
61   - val identifier: Identifier = Identifier("null", ScalarType())
62   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
63   - def rewrite(f: (Expression) => Expression): Expression = f(this)
64   - def filter(f: (Expression) => Boolean): Seq[Expression] = if(f(this)) Seq(this) else Seq()
65   -}
66   -
67   -case class Add(a: Expression, b: Expression) extends Expression {
68   - val identifier = Identifier("%s + %s".format(a.identifier.name, b.identifier.name), myType)
69   -
70   - private def myType = if(a.identifier.typ.isAssignableFrom(b.identifier.typ))
71   - a.identifier.typ
72   - else if(b.identifier.typ.isAssignableFrom(a.identifier.typ))
73   - b.identifier.typ
74   - else ScalarType()
75   -
76   -
77   - def compute(m: Map[String, Any]) = {
78   - val aVal = a(m)
79   - val bVal = b(m)
80   -
81   - (aVal, bVal) match {
82   - case (x: Number, y: Number) => x.doubleValue() + y.doubleValue()
83   - case (x: String, y: String) => x + y
84   - case (IsIterable(x), IsIterable(y)) => x ++ y
85   - case (IsIterable(x), y) => x ++ Seq(y)
86   - case (x, IsIterable(y)) => Seq(x) ++ y
87   - case _ => throw new CypherTypeException("Don't know how to add `" + aVal.toString + "` and `" + bVal.toString + "`")
88   - }
89   - }
90   -
91   - def declareDependencies(extectedType: AnyType) = a.declareDependencies(extectedType) ++ b.declareDependencies(extectedType)
92   - def rewrite(f: (Expression) => Expression) = f(Add(a.rewrite(f), b.rewrite(f)))
93   - def filter(f: (Expression) => Boolean) = if(f(this))
94   - Seq(this) ++ a.filter(f) ++ b.filter(f)
95   - else
96   - a.filter(f) ++ b.filter(f)
97   -}
98   -
99   -case class Subtract(a: Expression, b: Expression) extends Arithmetics(a, b) {
100   - def operand = "-"
101   - def verb = "subtract"
102   - def stringWithString(a: String, b: String) = throwTypeError(a, b)
103   - def numberWithNumber(a: Number, b: Number) = a.doubleValue() - b.doubleValue()
104   - def rewrite(f: (Expression) => Expression) = f(Subtract(a.rewrite(f), b.rewrite(f)))
105   -}
106   -
107   -case class Modulo(a: Expression, b: Expression) extends Arithmetics(a, b) {
108   - def operand = "%"
109   - def verb = "modulo"
110   - def stringWithString(a: String, b: String) = throwTypeError(a, b)
111   - def numberWithNumber(a: Number, b: Number) = a.doubleValue() % b.doubleValue()
112   - def rewrite(f: (Expression) => Expression) = f(Modulo(a.rewrite(f), b.rewrite(f)))
113   -}
114   -
115   -case class Pow(a: Expression, b: Expression) extends Arithmetics(a, b) {
116   - def operand = "^"
117   - def verb = "power"
118   - def stringWithString(a: String, b: String) = throwTypeError(a, b)
119   - def numberWithNumber(a: Number, b: Number) = math.pow(a.doubleValue(), b.doubleValue())
120   - def rewrite(f: (Expression) => Expression) = f(Pow(a.rewrite(f), b.rewrite(f)))
121   -}
122   -
123   -case class Multiply(a: Expression, b: Expression) extends Arithmetics(a, b) {
124   - def operand = "*"
125   - def verb = "multiply"
126   - def stringWithString(a: String, b: String) = throwTypeError(a, b)
127   - def numberWithNumber(a: Number, b: Number) = a.doubleValue() * b.doubleValue()
128   - def rewrite(f: (Expression) => Expression) = f(Multiply(a.rewrite(f), b.rewrite(f)))
129   -}
130   -
131   -case class Divide(a: Expression, b: Expression) extends Arithmetics(a, b) {
132   - def operand = "/"
133   - def verb = "divide"
134   - def stringWithString(a: String, b: String) = throwTypeError(a, b)
135   - def numberWithNumber(a: Number, b: Number) = a.doubleValue() / b.doubleValue()
136   - def rewrite(f: (Expression) => Expression) = f(Divide(a.rewrite(f), b.rewrite(f)))
137   -}
138   -
139   -abstract class Arithmetics(left: Expression, right: Expression) extends Expression {
140   - val identifier = Identifier("%s %s %s".format(left.identifier.name, operand, right.identifier.name), NumberType())
141   - def operand: String
142   - def throwTypeError(bVal: Any, aVal: Any): Nothing = {
143   - throw new CypherTypeException("Don't know how to " + verb + " `" + name(bVal) + "` with `" + name(aVal) + "`")
144   - }
145   -
146   - private def name(x:Any)=x match {
147   - case null => "null"
148   - case _ => x.toString
149   - }
150   -
151   - def compute(m: Map[String, Any]) = {
152   - val aVal = left(m)
153   - val bVal = right(m)
154   -
155   - (aVal, bVal) match {
156   - case (x: Number, y: Number) => numberWithNumber(x, y)
157   - case (x: String, y: String) => stringWithString(x, y)
158   - case _ => throwTypeError(bVal, aVal)
159   - }
160   -
161   - }
162   -
163   - def verb: String
164   - def stringWithString(a: String, b: String): String
165   - def numberWithNumber(a: Number, b: Number): Number
166   - def declareDependencies(extectedType: AnyType) = left.declareDependencies(extectedType) ++ right.declareDependencies(extectedType)
167   - def filter(f: (Expression) => Boolean) = if(f(this))
168   - Seq(this) ++ left.filter(f) ++ right.filter(f)
169   - else
170   - left.filter(f) ++ right.filter(f)
171   -}
172   -
173   -case class Literal(v: Any) extends Expression {
174   - def compute(m: Map[String, Any]) = v
175   -
176   - override def apply(m: Map[String, Any]): Any = compute(m)
177   -
178   - val identifier = Identifier(name, AnyType.fromJava(v))
179   - private def name = v match {
180   - case null => "null"
181   - case x => x.toString
182   - }
183   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
184   - def rewrite(f: (Expression) => Expression) = f(this)
185   - def filter(f: (Expression) => Boolean) = if(f(this))
186   - Seq(this)
187   - else
188   - Seq()
189   -}
190   -
191   -abstract class CastableExpression extends Expression {
192   - override def dependencies(extectedType: AnyType): Seq[Identifier] = declareDependencies(extectedType)
193   -}
194   -
195   -case class Nullable(expression: Expression) extends Expression {
196   - val identifier = Identifier(expression.identifier.name + "?", expression.identifier.typ)
197   -
198   - def compute(m: Map[String, Any]) = try {
199   - expression.apply(m)
200   - } catch {
201   - case x: EntityNotFoundException => null
202   - }
203   -
204   - def declareDependencies(extectedType: AnyType) = expression.dependencies(extectedType)
205   - override def dependencies(extectedType: AnyType) = expression.dependencies(extectedType)
206   - def rewrite(f: (Expression) => Expression) = f(Nullable(expression.rewrite(f)))
207   -
208   - def filter(f: (Expression) => Boolean) = if(f(this))
209   - Seq(this) ++ expression.filter(f)
210   - else
211   - expression.filter(f)
212   -}
213   -
214   -case class Property(entity: String, property: String) extends CastableExpression {
215   - def compute(m: Map[String, Any]): Any = {
216   - m(entity).asInstanceOf[PropertyContainer] match {
217   - case null => null
218   - case propertyContainer => try {
219   - propertyContainer.getProperty(property)
220   - } catch {
221   - case x: NotFoundException => throw new EntityNotFoundException("The property '%s' does not exist on %s".format(property, propertyContainer), x)
222   - }
223   - }
224   - }
225   -
226   - val identifier: Identifier = Identifier(entity + "." + property, AnyType())
227   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entity, MapType()))
228   - def rewrite(f: (Expression) => Expression) = f(this)
229   - def filter(f: (Expression) => Boolean) = if(f(this))
230   - Seq(this)
231   - else
232   - Seq()
233   -}
234   -
235   -case class Entity(entityName: String) extends CastableExpression {
236   - def compute(m: Map[String, Any]): Any = m.getOrElse(entityName, throw new NotFoundException("Failed to find `" + entityName + "`"))
237   - val identifier: Identifier = Identifier(entityName, AnyType())
238   - override def toString(): String = entityName
239   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entityName, extectedType))
240   - def rewrite(f: (Expression) => Expression) = f(this)
241   - def filter(f: (Expression) => Boolean) = if(f(this))
242   - Seq(this)
243   - else
244   - Seq()
245   -}
246   -
247   -case class Collection(expressions:Expression*) extends CastableExpression {
248   - def compute(m: Map[String, Any]): Any = expressions.map(e=>e(m))
249   -
250   - val identifier: Identifier = Identifier(name, AnyIterableType())
251   -
252   - private def name = expressions.map(_.identifier.name).mkString("[", ", ", "]")
253   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.declareDependencies(AnyType()))
254   - def rewrite(f: (Expression) => Expression): Expression = f(Collection(expressions.map(f):_*))
255   - def filter(f: (Expression) => Boolean): Seq[Expression] = if(f(this))
256   - Seq(this) ++ expressions.flatMap(_.filter(f))
257   - else
258   - expressions.flatMap(_.filter(f))
259   -}
260   -
261   -case class ParameterExpression(parameterName: String) extends CastableExpression {
262   - def compute(m: Map[String, Any]): Any = m.getOrElse("-=PARAMETER=-" + parameterName + "-=PARAMETER=-", throw new ParameterNotFoundException("Expected a parameter named " + parameterName)) match {
263   - case ParameterValue(x) => x
264   - case _ => throw new ParameterNotFoundException("Expected a parameter named " + parameterName)
265   - }
266   -
267   - override def apply(m: Map[String, Any]) = compute(m)
268   - val identifier: Identifier = Identifier(parameterName, AnyType())
269   - override def toString(): String = "{" + parameterName + "}"
270   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq()
271   - def rewrite(f: (Expression) => Expression) = f(this)
272   - def filter(f: (Expression) => Boolean) = if(f(this))
273   - Seq(this)
274   - else
275   - Seq()
276   -}
277   -
278   -case class ParameterValue(value: Any)
245 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Functions.scala
... ... @@ -1,245 +0,0 @@
1   -/**
2   - * Copyright (c) 2002-2012 "Neo Technology,"
3   - * Network Engine for Objects in Lund AB [http://neotechnology.com]
4   - *
5   - * This file is part of Neo4j.
6   - *
7   - * Neo4j is free software: you can redistribute it and/or modify
8   - * it under the terms of the GNU General Public License as published by
9   - * the Free Software Foundation, either version 3 of the License, or
10   - * (at your option) any later version.
11   - *
12   - * This program is distributed in the hope that it will be useful,
13   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   - * GNU General Public License for more details.
16   - *
17   - * You should have received a copy of the GNU General Public License
18   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
19   - */
20   -package org.neo4j.cypher.internal.commands
21   -
22   -import org.neo4j.cypher.{SyntaxException, IterableRequiredException}
23   -import scala.collection.JavaConverters._
24   -import org.neo4j.cypher.internal.symbols._
25   -import org.neo4j.graphdb.{Node, Relationship, Path}
26   -import collection.Map
27   -
28   -trait Functions
29   -
30   -abstract class NullInNullOutExpression(argument: Expression) extends Expression {
31   - def compute(value: Any, m: Map[String, Any]): Any
32   -
33   - def compute(m: Map[String, Any]): Any = argument(m) match {
34   - case null => null
35   - case x => compute(x, m)
36   - }
37   -}
38   -
39   -case class ExtractFunction(collection: Expression, id: String, expression: Expression)
40   - extends NullInNullOutExpression(collection)
41   - with IterableSupport
42   -{
43   - def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).map(iterValue => {
44   - val innerMap = m + (id -> iterValue)
45   - expression(innerMap)
46   - }).toList
47   -
48   - val identifier = Identifier("extract(" + id + " in " + collection.identifier.name + " : " + expression.identifier.name + ")", new CollectionType(expression.identifier.typ))
49   -
50   - def declareDependencies(extectedType: AnyType): Seq[Identifier] =
51   - // Extract depends on everything that the iterable and the expression depends on, except
52   - // the new identifier inserted into the expression context, named with id
53   - collection.dependencies(AnyIterableType()) ++ expression.dependencies(AnyType()).filterNot(_.name == id)
54   -
55   - def rewrite(f: (Expression) => Expression) = f(ExtractFunction(collection.rewrite(f), id, expression.rewrite(f)))
56   -
57   - def filter(f: (Expression) => Boolean) = if (f(this))
58   - Seq(this) ++ collection.filter(f) ++ expression.filter(f)
59   - else
60   - collection.filter(f) ++ expression.filter(f)
61   -}
62   -
63   -case class RelationshipFunction(path: Expression) extends NullInNullOutExpression(path) {
64   - def compute(value: Any, m: Map[String, Any]) = value match {
65   - case p: Path => p.relationships().asScala.toSeq
66   - case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.")
67   - }
68   -
69   - val identifier = Identifier("RELATIONSHIPS(" + path.identifier.name + ")", new CollectionType(RelationshipType()))
70   -
71   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType())
72   -
73   - def rewrite(f: (Expression) => Expression) = f(RelationshipFunction(path.rewrite(f)))
74   -
75   - def filter(f: (Expression) => Boolean) = if (f(this))
76   - Seq(this) ++ path.filter(f)
77   - else
78   - path.filter(f)
79   -}
80   -
81   -case class CoalesceFunction(expressions: Expression*) extends Expression {
82   - def compute(m: Map[String, Any]): Any = expressions.toStream.map(expression => expression(m)).find(value => value != null) match {
83   - case None => null
84   - case Some(x) => x
85   - }
86   -
87   - def innerExpectedType: Option[AnyType] = None
88   -
89   - val argumentsString: String = expressions.map(_.identifier.name).mkString(",")
90   -
91   - //TODO: Find out the closest matching return type
92   - val identifier = Identifier("COALESCE(" + argumentsString + ")", AnyType())
93   -
94   - override def toString() = "coalesce(" + argumentsString + ")"
95   -
96   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.dependencies(AnyType()))
97   -
98   - def rewrite(f: (Expression) => Expression) = f(CoalesceFunction(expressions.map(e => e.rewrite(f)): _*))
99   -
100   - def filter(f: (Expression) => Boolean) = if (f(this))
101   - Seq(this) ++ expressions.flatMap(_.filter(f))
102   - else
103   - expressions.flatMap(_.filter(f))
104   -}
105   -
106   -case class RelationshipTypeFunction(relationship: Expression) extends NullInNullOutExpression(relationship) {
107   - def compute(value: Any, m: Map[String, Any]) = value.asInstanceOf[Relationship].getType.name()
108   -
109   - lazy val identifier = Identifier("TYPE(" + relationship.identifier.name + ")", StringType())
110   -
111   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = relationship.dependencies(RelationshipType())
112   -
113   - def rewrite(f: (Expression) => Expression) = f(RelationshipTypeFunction(relationship.rewrite(f)))
114   -
115   - def filter(f: (Expression) => Boolean) = if (f(this))
116   - Seq(this) ++ relationship.filter(f)
117   - else
118   - relationship.filter(f)
119   -}
120   -
121   -case class LengthFunction(inner: Expression) extends NullInNullOutExpression(inner) with IterableSupport {
122   - def compute(value: Any, m: Map[String, Any]) = value match {
123   - case path: Path => path.length()
124   - case s: String => s.length()
125   - case x => makeTraversable(x).toSeq.length
126   - }
127   -
128   - val identifier = Identifier("LENGTH(" + inner.identifier.name + ")", IntegerType())
129   -
130   - def declareDependencies(extectedType: AnyType): Seq[Identifier] = inner.dependencies(AnyIterableType()).toList
131   -
132   - def rewrite(f: (Expression) => Expression) = f(LengthFunction(inner.rewrite(f)))
133   -
134   - def filter(f: (Expression) => Boolean) = if (f(this))
135   - Seq(this) ++ inner.filter(f)
136   - else
137   - inner.filter(f)
138   -}
139   -
140   -case class IdFunction(inner: Expression) extends NullInNullOutExpression(inner) {
141   -
142   - def compute(value: Any, m: Map[String, Any]) = value match {
143   - case node: Node => node.getId