DATAGRAPH-729 - Make SDN 3.4 support Neo4j 2.2.x only.

This commit is contained in:
Michael Hunger
2015-08-06 09:42:32 +02:00
parent 76d9953579
commit 21f5252184
6 changed files with 9 additions and 718 deletions

27
pom.xml
View File

@@ -38,9 +38,9 @@
<source.level>1.7</source.level>
<target.level>1.7</target.level>
<neo4j.version>2.1.8</neo4j.version>
<neo4j.version>2.2.3</neo4j.version>
<neo4j.spatial.version>0.14-neo4j-2.2.3</neo4j.spatial.version>
<neo4j.spatial.version>0.13-neo4j-2.1.6</neo4j.spatial.version>
<neo4j-cypher-dsl.version>2.0.1</neo4j-cypher-dsl.version>
<bundlor.failOnWarnings>false</bundlor.failOnWarnings>
</properties>
@@ -53,22 +53,6 @@
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<id>neo22</id>
<properties>
<neo4j.version>2.2.3</neo4j.version>
<neo4j.spatial.version>0.14-neo4j-2.2.3</neo4j.spatial.version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-io</artifactId>
<version>${neo4j.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>
</profile>
<profile>
<id>distribute</id>
<properties>
@@ -180,6 +164,13 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-io</artifactId>
<version>${neo4j.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>

View File

@@ -1,79 +0,0 @@
package org.neo4j.graphdb;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
public interface Result extends ResourceIterator<Map<String, Object>>
{
/**
* The exact names used to represent each column in the result set.
*
* @return List of the column names.
*/
List<String> columns();
/**
* Returns an iterator with the result objects from a single column of the result set. This method is best used for
* single column results.
*
* <p><b>To ensure that any resources, including transactions bound to it, are properly closed, the iterator must
* either be fully exhausted, or the {@link ResourceIterator#close() close()} method must be
* called.</b></p>
*
* @param name exact name of the column, as it appeared in the original query
* @param <T> desired type cast for the result objects
* @return an iterator of the result objects, possibly empty
* @throws ClassCastException when the result object can not be cast to the requested type
* @throws NotFoundException when the column name does not appear in the original query
*/
<T> ResourceIterator<T> columnAs(String name);
/**
* Denotes there being more rows available in this result. These rows must either be consumed, by invoking
* {@link #next()}, or the result has to be {@link #close() closed}.
*
* @return {@code true} if there is more rows available in this result, {@code false} otherwise.
*/
boolean hasNext();
/**
* Returns the next row in this result.
*
* @return the next row in this result.
*/
Map<String, Object> next();
/**
* Closes the result, freeing up any resources held by the result.
*
* This is an idempotent operation, invoking it multiple times has the same effect as invoking it exactly once.
* It is thus safe (and even encouraged, for style and simplicity) to invoke this method even after consuming all
* rows in the result through the {@link #next() next-method}.
*/
void close();
/**
* Provides a textual representation of the query result.
* <p><b>
* The execution result represented by this object will be consumed in its entirety after this method is called.
* Calling any of the other iterating methods on it should not be expected to return any results.
* </b></p>
*
* @return the execution result formatted as a string
*/
String resultAsString();
/**
* Provides a textual representation of the query result to the provided {@link PrintWriter}.
* <p><b>
* The execution result represented by this object will be consumed in its entirety after this method is called.
* Calling any of the other iterating methods on it should not be expected to return any results.
* </b></p>
* @param writer the {@link PrintWriter} to receive the textual representation of the query result.
*/
void writeAsStringTo(PrintWriter writer);
/** Removing rows from the result is not supported. */
void remove();
}

View File

@@ -1,98 +0,0 @@
/*
* Copyright (c) 2002-2015 "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.graphdb;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Instances describe single execution steps in a Cypher query execution plan
*
* Execution plans form a tree of execution steps. Each step is described by a {@link ExecutionPlanDescription} object.
*/
public interface ExecutionPlanDescription
{
/**
* Retrieves the name of this execution step.
*
* @return descriptive name for this kind of execution step
*/
String getName();
/**
* Retrieves the children of this execution step.
*
* @return list of previous (child) execution step descriptions
*/
List<ExecutionPlanDescription> getChildren();
/**
* Retrieve argument map for the associated execution step
*
* Valid arguments are all Java primitive values, Strings, Arrays of those, and Maps from Strings to
* valid arguments. Results are guaranteed to be trees (i.e. there are no cyclic dependencies among values)
*
* @return a map containing arguments that describe this execution step in more detail
*/
Map<String, Object> getArguments();
/**
* @return the set of identifiers used in this execution step
*/
public Set<String> getIdentifiers();
/**
* Signifies that the query was profiled, and that statistics from the profiling can
* {@link #getProfilerStatistics() be retrieved}.
*
* The <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code PROFILE}</a> directive in Cypher
* ensures the presence of profiler statistics in the plan description.
*
* @return true, if {@link ProfilerStatistics} are available for this execution step
*/
boolean hasProfilerStatistics();
/**
* Retrieve the statistics collected from profiling this query.
*
* If the query was not profiled, this method will throw {@link java.util.NoSuchElementException}.
*
* @return profiler statistics for this execution step iff available
* @throws java.util.NoSuchElementException iff profiler statistics are not available
*/
ProfilerStatistics getProfilerStatistics();
/**
* Instances describe statistics from the profiler of a particular step in the execution plan.
*/
interface ProfilerStatistics
{
/**
* @return number of rows processed by the associated execution step
*/
long getRows();
/**
* @return number of database hits (potential disk accesses) caused by executing the associated execution step
*/
long getDbHits();
}
}

View File

@@ -1,228 +0,0 @@
/*
* Copyright (c) 2002-2015 "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.graphdb;
import static java.util.Objects.requireNonNull;
/**
* Signifies how a query is executed, as well as what side effects and results could be expected from the query.
* <p/>
* In Cypher there are three different modes of execution:
* <ul>
* <li>Normal execution,</li>
* <li>execution with the <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code PROFILE}</a> directive,
* and</li>
* <li>execution with the <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code EXPLAIN}</a>
* directive.</li>
* </ul>
* Instances of this class contain the required information to be able to tell these different execution modes apart.
* It also contains information about what effects the query could have, and whether it could yield any results, in
* form
* of the {@link QueryType QueryType enum}.
* <p/>
* Queries executed with the {@code PROFILE} directive can have side effects and produce results in the same way as a
* normally executed method. The difference being that the user has expressed an interest in seeing the plan used to
* execute the query, and that this plan will (after execution completes) be annotated with
* {@linkplain org.neo4j.graphdb.ExecutionPlanDescription#getProfilerStatistics() profiling information} from the execution of the query.
* <p/>
* Queries executed with the {@code EXPLAIN} directive never have any side effects, nor do they ever yield any rows in
* the results, the sole purpose of this mode of execution is to
* {@linkplain org.neo4j.graphdb.Result#getExecutionPlanDescription() get a description of the plan} that <i>would</i> be executed
* if/when the query is executed normally (or under {@code PROFILE}).
*/
public final class QueryExecutionType
{
/**
* Signifies what type of query an {@link QueryExecutionType} executes.
*/
public enum QueryType
{
/** A read-only query, that does not change any data, but only produces a result. */
READ_ONLY,
/** A read/write query, that creates or updates data, and also produces a result. */
READ_WRITE,
/** A write-only query, that creates or updates data, but does not yield any rows in the result. */
WRITE,
/**
* A schema changing query, that updates the schema but neither changes any data nor yields any rows in the
* result.
*/
SCHEMA_WRITE,;
private final QueryExecutionType query, profiled, explained;
QueryType()
{
this.query = new QueryExecutionType( Execution.QUERY, this );
this.profiled = new QueryExecutionType( Execution.PROFILE, this );
this.explained = new QueryExecutionType( Execution.EXPLAIN, this );
}
}
/**
* Get the {@link QueryExecutionType} that signifies normal execution of a query of the supplied type.
*
* @param type the type of query executed.
* @return The instance that signifies normal execution of the supplied {@link QueryType}.
*/
public static QueryExecutionType query( QueryType type )
{
return requireNonNull( type, "QueryType" ).query;
}
/**
* Get the {@link QueryExecutionType} that signifies profiled execution of a query of the supplied type.
*
* @param type the type of query executed.
* @return The instance that signifies profiled execution of the supplied {@link QueryType}.
*/
public static QueryExecutionType profiled( QueryType type )
{
return requireNonNull( type, "QueryType" ).profiled;
}
/**
* Get the {@link QueryExecutionType} that signifies explaining the plan of a query of the supplied type.
*
* @param type the type of query executed.
* @return The instance that signifies explaining the plan of the supplied {@link QueryType}.
*/
public static QueryExecutionType explained( QueryType type )
{
return requireNonNull( type, "QueryType" ).explained;
}
/**
* Get the type of query this execution refers to.
*
* @return the type of query this execution refers to.
*/
public QueryType queryType()
{
return type;
}
/**
* Signifies whether results from this execution
* {@linkplain org.neo4j.graphdb.ExecutionPlanDescription#getProfilerStatistics() contains profiling information}.
*
* This is {@code true} for queries executed with the
* <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code PROFILE}</a> directive.
*
* @return {@code true} if the results from this execution would contain profiling information.
*/
public boolean isProfiled()
{
return execution == Execution.PROFILE;
}
/**
* Signifies whether the supplied query contained a directive that asked for a
* {@linkplain org.neo4j.graphdb.ExecutionPlanDescription description of the execution plan}.
*
* This is {@code true} for queries executed with either the
* <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code EXPLAIN} or {@code PROFILE} directives</a>.
*
* @return {@code true} if a description of the plan should be presented to the user.
*/
public boolean requestedExecutionPlanDescription()
{
return execution != Execution.QUERY;
}
/**
* Signifies that the query was executed with the
* <a href="http://neo4j.com/docs/stable/execution-plans.html">{@code EXPLAIN} directive</a>.
*
* @return {@code true} if the query was executed using the {@code EXPLAIN} directive.
*/
public boolean isExplained()
{
return execution == Execution.EXPLAIN;
}
/**
* Signifies that the execution of the query could produce a result.
*
* This is an important distinction from the result being empty.
*
* @return {@code true} if the execution would yield rows in the result set.
*/
public boolean canContainResults()
{
return (type == QueryType.READ_ONLY || type == QueryType.READ_WRITE) && execution != Execution.EXPLAIN;
}
/**
* Signifies that the execution of the query could perform changes to the data.
*
* {@link org.neo4j.graphdb.Result}{@link org.neo4j.graphdb.Result#getQueryStatistics() .getQueryStatistics()}{@link org.neo4j.graphdb.QueryStatistics#containsUpdates()
* .containsUpdates()} signifies whether the query actually performed any updates.
*
* @return {@code true} if the execution could perform changes to data.
*/
public boolean canUpdateData()
{
return (type == QueryType.READ_WRITE || type == QueryType.WRITE) && execution != Execution.EXPLAIN;
}
/**
* Signifies that the execution of the query updates the schema.
*
* @return {@code true} if the execution updates the schema.
*/
public boolean canUpdateSchema()
{
return type == QueryType.SCHEMA_WRITE && execution != Execution.EXPLAIN;
}
private final Execution execution;
private final QueryType type;
private QueryExecutionType(Execution execution, QueryType type)
{
this.execution = execution;
this.type = type;
}
@Override
public String toString()
{
return execution.toString( type );
}
private enum Execution
{
QUERY
{
@Override
String toString( QueryType type )
{
return type.name();
}
},
PROFILE,
EXPLAIN,;
String toString( QueryType type )
{
return name() + ":" + type.name();
}
}
}

View File

@@ -1,114 +0,0 @@
/*
* Copyright (c) 2002-2015 "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.graphdb;
/**
* Represents statistics about the effects of a query.
*
* If the query did not perform any {@link #containsUpdates() updates}, all the methods of this interface will return
* {@code 0}.
*/
public interface QueryStatistics
{
/**
* Returns the number of nodes created by this query.
*
* @return the number of nodes created by this query.
*/
int getNodesCreated();
/**
* Returns the number of nodes deleted by this query.
*
* @return the number of nodes deleted by this query.
*/
int getNodesDeleted();
/**
* Returns the number of relationships created by this query.
*
* @return the number of relationships created by this query.
*/
int getRelationshipsCreated();
/**
* Returns the number of relationships deleted by this query.
*
* @return the number of relationships deleted by this query.
*/
int getRelationshipsDeleted();
/**
* Returns the number of properties set by this query. Setting a property to the same value again still counts
* towards this.
*
* @return the number of properties set by this query.
*/
int getPropertiesSet();
/**
* Returns the number of labels added to any node by this query.
*
* @return the number of labels added to any node by this query.
*/
int getLabelsAdded();
/**
* Returns the number of labels removed from any node by this query.
*
* @return the number of labels removed from any node by this query.
*/
int getLabelsRemoved();
/**
* Returns the number of indexes added by this query.
*
* @return the number of indexes added by this query.
*/
int getIndexesAdded();
/**
* Returns the number of indexes removed by this query.
*
* @return the number of indexes removed by this query.
*/
int getIndexesRemoved();
/**
* Returns the number of constraints added by this query.
*
* @return the number of constraints added by this query.
*/
int getConstraintsAdded();
/**
* Returns the number of constraints removed by this query.
*
* @return the number of constraints removed by this query.
*/
int getConstraintsRemoved();
/**
* If the query updated the graph in any way, this method will return true.
*
* @return if the graph has been updated.
*/
boolean containsUpdates();
}

View File

@@ -1,181 +0,0 @@
/*
* Copyright (c) 2002-2015 "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.graphdb;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
/**
* Represents the result of {@link org.neo4j.graphdb.GraphDatabaseService#execute(String, java.util.Map) executing} a query.
* <p/>
* The result is comprised of a number of rows, potentially computed lazily, with this result object being an iterator
* over those rows. Each row is represented as a <code>{@link java.util.Map}&lt;{@link String}, {@link Object}&gt;</code>, the
* keys in this map are the names of the columns in the row, as specified by the {@code return} clause of the query,
* and the values of the map is the corresponding computed value of the expression in the {@code return} clause. Each
* row will thus have the same set of keys, and these keys can be retrieved using the
* {@linkplain #columns() columns-method}.
* <p/>
* To ensure that any resource, including transactions bound to the query, are properly freed, the result must either
* be fully exhausted, by means of the {@linkplain java.util.Iterator iterator protocol}, or the result has to be
* explicitly closed, by invoking the {@linkplain #close() close-method}.
* <p/>
* Idiomatic use of the Result object would look like this:
* <pre><code>
* try ( Result result = graphDatabase.execute( query, parameters ) )
* {
* while ( result.hasNext() )
* {
* Map&lt;String, Object&gt; row = result.next();
* for ( String key : result.columns() )
* {
* System.out.printf( "%s = %s%n", key, row.get( key ) );
* }
* }
* }
* </code></pre>
* If the result consists of only a single column, or if only one of the columns is of interest, a projection can be
* extracted using {@link #columnAs(String)}. This produces a new iterator over the values of the named column. It
* should be noted that this iterator consumes the rows of the result in the same way as invoking {@link #next()} on
* this object would, and that the {@link #close() close-method} on either iterator has the same effect. It is thus
* safe to either close the projected column iterator, or this iterator, or both if all rows have not been consumed.
* <p/>
* In addition to the {@link #next() iteration methods} on this interface, {@link #close()}, and the
* {@link #columnAs(String) column projection method}, there are two methods for getting a string representation of the
* result that also consumes the entire result if invoked. {@link #resultAsString()} returns a single string
* representation of all (remaining) rows in the result, and {@link #writeAsStringTo(java.io.PrintWriter)} does the same, but
* streams the result to the provided {@link java.io.PrintWriter} instead, without allocating large string objects.
* <p/>
* The methods that do not consume any rows from the result, or in other ways alter the state of the result are safe to
* invoke at any time, even after the result has been {@linkplain #close() closed} or fully exhausted. These methods
* are:
* <ul>
* <li>{@link #columns()}</li>
* <li>{@link #getQueryStatistics()}</li>
* <li>{@link #getQueryExecutionType()}</li>
* <li>{@link #getExecutionPlanDescription()}</li>
* </ul>
* <p/>
* Not all queries produce an actual result, and some queries that do might yield an empty result set. In order to
* distinguish between these cases the {@link org.neo4j.graphdb.QueryExecutionType} {@linkplain #getQueryExecutionType() of this result}
* can be queried.
*/
public interface Result extends ResourceIterator<Map<String, Object>>
{
/**
* Indicates what kind of query execution produced this result.
*
* @return an object that indicates what kind of query was executed to produce this result.
*/
QueryExecutionType getQueryExecutionType();
/**
* The exact names used to represent each column in the result set.
*
* @return List of the column names.
*/
List<String> columns();
/**
* Returns an iterator with the result objects from a single column of the result set. This method is best used for
* single column results.
*
* <p><b>To ensure that any resources, including transactions bound to it, are properly closed, the iterator must
* either be fully exhausted, or the {@link ResourceIterator#close() close()} method must be
* called.</b></p>
*
* @param name exact name of the column, as it appeared in the original query
* @param <T> desired type cast for the result objects
* @return an iterator of the result objects, possibly empty
* @throws ClassCastException when the result object can not be cast to the requested type
* @throws NotFoundException when the column name does not appear in the original query
*/
<T> ResourceIterator<T> columnAs(String name);
/**
* Denotes there being more rows available in this result. These rows must either be consumed, by invoking
* {@link #next()}, or the result has to be {@link #close() closed}.
*
* @return {@code true} if there is more rows available in this result, {@code false} otherwise.
*/
boolean hasNext();
/**
* Returns the next row in this result.
*
* @return the next row in this result.
*/
Map<String, Object> next();
/**
* Closes the result, freeing up any resources held by the result.
*
* This is an idempotent operation, invoking it multiple times has the same effect as invoking it exactly once.
* It is thus safe (and even encouraged, for style and simplicity) to invoke this method even after consuming all
* rows in the result through the {@link #next() next-method}.
*/
void close();
/**
* Statistics about the effects of the query.
*
* @return statistics about the effects of the query.
*/
QueryStatistics getQueryStatistics();
/**
* Returns a description of the query plan used to produce this result.
*
* Retrieving a description of the execution plan that was executed is always possible, regardless of whether the
* query requested a plan or not. For implementing a client with the ability to present the plan to the user, it is
* useful to be able to tell if the query requested a description of the plan or not. For these purposes the
* {@link org.neo4j.graphdb.QueryExecutionType#requestedExecutionPlanDescription()}-method is used.
*
* Being able to invoke this method, regardless of whether the user requested the plan or not is useful for
* purposes of debugging queries in applications.
*
* @return a description of the query plan used to produce this result.
*/
ExecutionPlanDescription getExecutionPlanDescription();
/**
* Provides a textual representation of the query result.
* <p><b>
* The execution result represented by this object will be consumed in its entirety after this method is called.
* Calling any of the other iterating methods on it should not be expected to return any results.
* </b></p>
*
* @return the execution result formatted as a string
*/
String resultAsString();
/**
* Provides a textual representation of the query result to the provided {@link java.io.PrintWriter}.
* <p><b>
* The execution result represented by this object will be consumed in its entirety after this method is called.
* Calling any of the other iterating methods on it should not be expected to return any results.
* </b></p>
* @param writer the {@link java.io.PrintWriter} to receive the textual representation of the query result.
*/
void writeAsStringTo(PrintWriter writer);
/** Removing rows from the result is not supported. */
void remove();
}