From 92cb164856fc21bd0d6d5351a4106985c79e8fd7 Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Wed, 2 Aug 2017 17:00:53 +0200 Subject: [PATCH] Refactor bolt module - Remove unused stuff - Make packing/unpacking symmetric in types --- .../bolt/v1/messaging/BoltMessageRouter.java | 3 +- .../messaging/BoltRequestMessageReader.java | 4 +- .../messaging/BoltResponseMessageHandler.java | 5 +- .../messaging/BoltResponseMessageWriter.java | 4 +- .../messaging/MessageProcessingHandler.java | 11 +- .../neo4j/bolt/v1/messaging/Neo4jPack.java | 104 ++-- .../org/neo4j/bolt/v1/messaging/PathPack.java | 228 -------- .../infrastructure/UnboundRelationship.java | 34 -- .../messaging/infrastructure/ValueNode.java | 335 ----------- .../messaging/infrastructure/ValuePath.java | 297 ---------- .../ValuePropertyContainer.java | 68 --- .../infrastructure/ValueRelationship.java | 234 -------- .../ValueUnboundRelationship.java | 223 ------- .../bolt/v1/runtime/BoltResponseHandler.java | 3 +- .../bolt/v1/runtime/BoltStateMachine.java | 66 ++- .../bolt/v1/runtime/CypherAdapterStream.java | 71 ++- .../v1/runtime/ExecutionPlanConverter.java | 37 +- .../neo4j/bolt/v1/runtime/spi/BoltResult.java | 3 +- .../bolt/v1/runtime/spi/BookmarkResult.java | 4 +- .../org/neo4j/bolt/testing/BoltMatchers.java | 6 +- .../bolt/testing/BoltResponseRecorder.java | 11 +- .../bolt/testing/NullResponseHandler.java | 3 +- .../bolt/testing/RecordedBoltResponse.java | 5 +- .../v1/messaging/BoltRequestMessageTest.java | 37 +- .../messaging/BoltRequestMessageWriter.java | 9 +- .../messaging/BoltResponseMessageReader.java | 14 +- .../BoltResponseMessageRecorder.java | 5 +- .../v1/messaging/BoltResponseMessageTest.java | 37 +- .../MessageProcessingHandlerTest.java | 4 +- .../bolt/v1/messaging/Neo4jPackTest.java | 108 ++-- .../bolt/v1/messaging/example/Edges.java | 57 ++ .../bolt/v1/messaging/example/Nodes.java | 43 +- .../bolt/v1/messaging/example/Paths.java | 80 ++- .../v1/messaging/example/Relationships.java | 64 -- .../bolt/v1/messaging/example/Support.java | 68 +-- .../infrastructure/ValuePathTest.java | 166 ------ .../v1/messaging/message/SuccessMessage.java | 9 +- .../v1/messaging/util/MessageMatchers.java | 61 +- .../v1/runtime/CypherAdapterStreamTest.java | 199 ++++--- .../runtime/ExecutionPlanConverterTest.java | 28 +- .../neo4j/bolt/v1/runtime/ResetFuzzTest.java | 3 +- .../integration/BoltConnectionAuthIT.java | 14 +- .../runtime/integration/BoltConnectionIT.java | 3 +- .../bolt/v1/runtime/spi/StreamMatchers.java | 3 +- .../javacompat/ValueToObjectSerializer.java | 508 +--------------- .../compatibility/v2_3/Compatibility.scala | 2 +- .../runtime/commands/expressions/Add.scala | 8 +- .../expressions/DesugaredMapProjection.scala | 4 +- .../main/java/org/neo4j/values/AnyValues.java | 43 -- .../neo4j/values/BaseToObjectValueWriter.java | 545 ++++++++++++++++++ .../org/neo4j/values/storable/TextArray.java | 2 +- .../neo4j/values/virtual/ArrayHelpers.java | 16 +- .../org/neo4j/values/virtual/ListValue.java | 83 ++- .../org/neo4j/values/virtual/MapValue.java | 6 + .../neo4j/values/virtual/VirtualValues.java | 49 ++ 55 files changed, 1350 insertions(+), 2687 deletions(-) delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PathPack.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/UnboundRelationship.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueNode.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValuePath.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValuePropertyContainer.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueRelationship.java delete mode 100644 community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueUnboundRelationship.java create mode 100644 community/bolt/src/test/java/org/neo4j/bolt/v1/messaging/example/Edges.java delete mode 100644 community/bolt/src/test/java/org/neo4j/bolt/v1/messaging/example/Relationships.java delete mode 100644 community/bolt/src/test/java/org/neo4j/bolt/v1/messaging/infrastructure/ValuePathTest.java create mode 100644 community/values/src/main/java/org/neo4j/values/BaseToObjectValueWriter.java diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltMessageRouter.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltMessageRouter.java index 3e56073c9fe31..e58bb32097356 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltMessageRouter.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltMessageRouter.java @@ -26,6 +26,7 @@ import org.neo4j.bolt.v1.runtime.Neo4jError; import org.neo4j.bolt.v1.runtime.spi.BoltResult; import org.neo4j.logging.Log; +import org.neo4j.values.AnyValue; import org.neo4j.values.result.QueryResult; /** @@ -139,7 +140,7 @@ public void visit( QueryResult.Record record ) throws Exception } @Override - public void addMetadata( String key, Object value ) + public void addMetadata( String key, AnyValue value ) { metadata.put( key, value ); } diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltRequestMessageReader.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltRequestMessageReader.java index eeb5e9b2bc214..3dc7fe7b550d3 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltRequestMessageReader.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltRequestMessageReader.java @@ -63,7 +63,7 @@ public void read( BoltRequestMessageHandler handler ) t { case INIT: String clientName = unpacker.unpackString(); - Map credentials = unpacker.unpackMap(); + Map credentials = unpacker.unpackToRawMap(); handler.onInit( clientName, credentials ); break; case ACK_FAILURE: @@ -74,7 +74,7 @@ public void read( BoltRequestMessageHandler handler ) t break; case RUN: String statement = unpacker.unpackString(); - Map params = unpacker.unpackMap(); + Map params = unpacker.unpackToRawMap(); Optional error = unpacker.consumeError(); if ( error.isPresent() ) { diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageHandler.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageHandler.java index a91a7a14360ba..a7ee5b9d21480 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageHandler.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageHandler.java @@ -19,10 +19,9 @@ */ package org.neo4j.bolt.v1.messaging; -import java.util.Map; - import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.values.result.QueryResult; +import org.neo4j.values.virtual.MapValue; /** * Interface defining simple handler methods for each defined @@ -32,7 +31,7 @@ */ public interface BoltResponseMessageHandler { - void onSuccess( Map metadata ) throws E; + void onSuccess( MapValue metadata ) throws E; void onRecord( QueryResult.Record item ) throws E; diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageWriter.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageWriter.java index d82bf4b9ef279..36a80c19b9903 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageWriter.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/BoltResponseMessageWriter.java @@ -20,11 +20,11 @@ package org.neo4j.bolt.v1.messaging; import java.io.IOException; -import java.util.Map; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.values.AnyValue; import org.neo4j.values.result.QueryResult; +import org.neo4j.values.virtual.MapValue; import static org.neo4j.bolt.v1.messaging.BoltResponseMessage.FAILURE; import static org.neo4j.bolt.v1.messaging.BoltResponseMessage.IGNORED; @@ -72,7 +72,7 @@ public void onRecord( QueryResult.Record item ) throws IOException } @Override - public void onSuccess( Map metadata ) throws IOException + public void onSuccess( MapValue metadata ) throws IOException { packer.packStructHeader( 1, SUCCESS.signature() ); packer.packRawMap( metadata ); diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/MessageProcessingHandler.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/MessageProcessingHandler.java index 909c8fa30c89f..a0550c432d54e 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/MessageProcessingHandler.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/MessageProcessingHandler.java @@ -29,10 +29,13 @@ import org.neo4j.bolt.v1.runtime.Neo4jError; import org.neo4j.bolt.v1.runtime.spi.BoltResult; import org.neo4j.logging.Log; +import org.neo4j.values.AnyValue; +import org.neo4j.values.virtual.MapValue; +import org.neo4j.values.virtual.VirtualValues; class MessageProcessingHandler implements BoltResponseHandler { - protected final Map metadata = new HashMap<>(); + protected final Map metadata = new HashMap<>(); protected final Log log; protected final BoltWorker worker; @@ -62,7 +65,7 @@ public void onRecords( BoltResult result, boolean pull ) throws Exception } @Override - public void onMetadata( String key, Object value ) + public void onMetadata( String key, AnyValue value ) { metadata.put( key, value ); } @@ -109,9 +112,9 @@ else if ( error != null ) } } - Map getMetadata() + MapValue getMetadata() { - return metadata; + return VirtualValues.map( metadata ); } private void clearState() diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/Neo4jPack.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/Neo4jPack.java index e2717f30b688d..67f5b23bdfc27 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/Neo4jPack.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/Neo4jPack.java @@ -32,18 +32,25 @@ import org.neo4j.bolt.v1.packstream.PackType; import org.neo4j.bolt.v1.runtime.Neo4jError; import org.neo4j.collection.primitive.PrimitiveLongIntKeyValueArray; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Relationship; +import org.neo4j.graphdb.spatial.Point; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.values.AnyValue; import org.neo4j.values.AnyValueWriter; -import org.neo4j.values.AnyValues; +import org.neo4j.values.BaseToObjectValueWriter; import org.neo4j.values.storable.TextArray; import org.neo4j.values.storable.TextValue; +import org.neo4j.values.storable.Values; import org.neo4j.values.virtual.CoordinateReferenceSystem; import org.neo4j.values.virtual.EdgeValue; +import org.neo4j.values.virtual.ListValue; import org.neo4j.values.virtual.MapValue; import org.neo4j.values.virtual.NodeValue; +import org.neo4j.values.virtual.VirtualValues; import static org.neo4j.bolt.v1.packstream.PackStream.UNKNOWN_SIZE; +import static org.neo4j.values.storable.Values.byteArray; /** * Extended PackStream packer and unpacker classes for working @@ -52,7 +59,7 @@ public class Neo4jPack { private static final List EMPTY_LIST = new ArrayList<>(); - private static final Map EMPTY_MAP = new HashMap<>(); + private static final Map EMPTY_MAP = new HashMap<>(); public static final byte NODE = 'N'; public static final byte RELATIONSHIP = 'R'; @@ -79,26 +86,10 @@ public void pack( AnyValue value ) throws IOException value.writeTo( this ); } - //TODO this should go away when we have cypher providing us with values - public void pack( Object value ) throws IOException - { - try - { - pack( AnyValues.of( value ) ); - } - catch ( IllegalArgumentException e ) - { - error = new Error( Status.Request.Invalid, - "Unpackable value " + value + " of type " + value.getClass().getName() ); - packNull(); - } - } - - //TODO this needs to go away as well since it is relying on pack(Object) - public void packRawMap( Map map ) throws IOException + public void packRawMap( MapValue map ) throws IOException { packMapHeader( map.size() ); - for ( Map.Entry entry : map.entrySet() ) + for ( Map.Entry entry : map.entrySet() ) { pack( entry.getKey() ); pack( entry.getValue() ); @@ -440,25 +431,25 @@ public Unpacker( PackInput input ) super( input ); } - public Object unpack() throws IOException + public AnyValue unpack() throws IOException { PackType valType = peekNextType(); switch ( valType ) { case BYTES: - return unpackBytes(); + return byteArray( unpackBytes() ); case STRING: - return unpackString(); + return Values.stringValue( unpackString() ); case INTEGER: - return unpackLong(); + return Values.longValue( unpackLong() ); case FLOAT: - return unpackDouble(); + return Values.doubleValue( unpackDouble() ); case BOOLEAN: - return unpackBoolean(); + return Values.booleanValue( unpackBoolean() ); case NULL: // still need to move past the null value unpackNull(); - return null; + return Values.NO_VALUE; case LIST: { return unpackList(); @@ -505,14 +496,14 @@ public Object unpack() throws IOException } } - List unpackList() throws IOException + ListValue unpackList() throws IOException { int size = (int) unpackListHeader(); if ( size == 0 ) { - return EMPTY_LIST; + return VirtualValues.EMPTY_LIST; } - ArrayList list; + ArrayList list; if ( size == UNKNOWN_SIZE ) { list = new ArrayList<>(); @@ -539,17 +530,17 @@ List unpackList() throws IOException list.add( unpack() ); } } - return list; + return VirtualValues.list( list.toArray( new AnyValue[list.size()] ) ); } - public Map unpackMap() throws IOException + public MapValue unpackMap() throws IOException { int size = (int) unpackMapHeader(); if ( size == 0 ) { - return EMPTY_MAP; + return VirtualValues.EMPTY_MAP; } - Map map; + Map map; if ( size == UNKNOWN_SIZE ) { map = new HashMap<>(); @@ -558,7 +549,7 @@ public Map unpackMap() throws IOException { PackType keyType = peekNextType(); String key; - Object val; + AnyValue val; switch ( keyType ) { case END_OF_STREAM: @@ -608,13 +599,26 @@ public Map unpackMap() throws IOException throw new PackStream.PackStreamException( "Bad key type: " + type ); } - Object val = unpack(); + AnyValue val = unpack(); if ( map.put( key, val ) != null ) { errors.add( Neo4jError.from( Status.Request.Invalid, "Duplicate map key `" + key + "`." ) ); } } } + return VirtualValues.map( map ); + } + + public Map unpackToRawMap() throws IOException + { + MapValue mapValue = unpackMap(); + HashMap map = new HashMap<>( mapValue.size() ); + for ( Map.Entry entry : mapValue.entrySet() ) + { + UnpackerWriter unpackerWriter = new UnpackerWriter(); + entry.getValue().writeTo( unpackerWriter ); + map.put( entry.getKey(), unpackerWriter.value() ); + } return map; } @@ -658,4 +662,32 @@ String msg() private Neo4jPack() { } + + private static class UnpackerWriter extends BaseToObjectValueWriter + { + + @Override + protected Node newNodeProxyById( long id ) + { + throw new UnsupportedOperationException( "Cannot unpack nodes" ); + } + + @Override + protected Relationship newRelationshipProxyById( long id ) + { + throw new UnsupportedOperationException( "Cannot unpack relationships" ); + } + + @Override + protected Point newGeographicPoint( double longitude, double latitude, String name, int code, String href ) + { + throw new UnsupportedOperationException( "Cannot unpack points" ); + } + + @Override + protected Point newCartesianPoint( double x, double y, String name, int code, String href ) + { + throw new UnsupportedOperationException( "Cannot unpack points" ); + } + } } diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PathPack.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PathPack.java deleted file mode 100644 index d325ff759a769..0000000000000 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PathPack.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2002-2017 "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 . - */ -package org.neo4j.bolt.v1.messaging; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.neo4j.bolt.v1.messaging.infrastructure.ValueNode; -import org.neo4j.bolt.v1.messaging.infrastructure.ValuePath; -import org.neo4j.collection.primitive.PrimitiveLongIntKeyValueArray; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.PropertyContainer; -import org.neo4j.graphdb.Relationship; -import org.neo4j.bolt.v1.messaging.infrastructure.ValueUnboundRelationship; - -public class PathPack -{ - private static final int STRUCT_FIELD_COUNT = 5; - private static final int NO_SUCH_ID = -1; - - public static class Packer - { - private static final int INITIAL_PATH_CAPACITY = 500; - - private final PrimitiveLongIntKeyValueArray nodes = - new PrimitiveLongIntKeyValueArray( INITIAL_PATH_CAPACITY + 1 ); - private final PrimitiveLongIntKeyValueArray relationships = - new PrimitiveLongIntKeyValueArray( INITIAL_PATH_CAPACITY ); - - private void packNodes( Neo4jPack.Packer packer, Path path ) - throws IOException - { - nodes.reset( path.length() + 1 ); - for ( Node node : path.nodes() ) - { - nodes.putIfAbsent( node.getId(), nodes.size() ); - } - int size = nodes.size(); - packer.packListHeader( size ); - if ( size > 0 ) - { - Iterator iterator = path.nodes().iterator(); - Node node = iterator.next(); - for ( long id : nodes.keys() ) - { - while ( node.getId() != id ) - { - node = iterator.next(); - } - ValueNode.pack( packer, node ); - if ( iterator.hasNext() ) - { - node = iterator.next(); - } - } - } - } - - private void packRelationships( Neo4jPack.Packer packer, Path path ) - throws IOException - { - relationships.reset( path.length() ); - for ( Relationship rel : path.relationships() ) - { - // relationship indexes are one-based - relationships.putIfAbsent( rel.getId(), relationships.size() + 1 ); - } - int size = relationships.size(); - packer.packListHeader( size ); - if ( size > 0 ) - { - Iterator iterator = path.relationships().iterator(); - Relationship rel = iterator.next(); - for ( long id : relationships.keys() ) - { - while ( rel.getId() != id ) - { - rel = iterator.next(); - } - ValueUnboundRelationship.pack( packer, ValueUnboundRelationship.unbind( rel ) ); - if ( iterator.hasNext() ) - { - rel = iterator.next(); - } - } - } - } - - public void pack( Neo4jPack.Packer packer, Path path ) throws IOException - { - packer.packStructHeader( 3, Neo4jPack.PATH ); - - packNodes( packer, path ); - packRelationships( packer, path ); - - Node node = null; - packer.packListHeader( 2 * path.length() ); - int i = 0; - for ( PropertyContainer entity : path ) - { - if ( i % 2 == 0 ) - { - node = (Node) entity; - if ( i > 0 ) - { - int index = nodes.getOrDefault( node.getId(), NO_SUCH_ID ); - packer.pack( index ); - } - } - else - { - Relationship relationship = (Relationship) entity; - int index = relationships.getOrDefault( relationship.getId(), NO_SUCH_ID ); - if ( node != null && node.getId() == relationship.getStartNode().getId() ) - { - packer.pack( index ); - } - else - { - packer.pack( -index ); - } - } - i += 1; - } - } - - } - - public static class Unpacker - { - - public ValuePath unpack( Neo4jPack.Unpacker unpacker ) - throws IOException - { - assert unpacker.unpackStructHeader() == STRUCT_FIELD_COUNT; - assert unpacker.unpackStructSignature() == Neo4jPack.PATH; - return unpackFields( unpacker ); - } - - public ValuePath unpackFields( Neo4jPack.Unpacker unpacker ) throws IOException - { - List nodes = unpackNodes( unpacker ); - List relationships = unpackRelationships( unpacker ); - List sequence = unpackSequence( unpacker ); - return new ValuePath( nodes, relationships, sequence ); - } - - private List unpackNodes( Neo4jPack.Unpacker unpacker ) - throws IOException - { - int count = (int) unpacker.unpackListHeader(); - if ( count > 0 ) - { - List items = new ArrayList<>( count ); - for ( int i = 0; i < count; i++ ) - { - items.add( ValueNode.unpack( unpacker ) ); - } - return items; - } - else - { - return Collections.emptyList(); - } - } - - private List unpackRelationships( Neo4jPack.Unpacker unpacker ) - throws IOException - { - int count = (int) unpacker.unpackListHeader(); - if ( count > 0 ) - { - List items = new ArrayList<>( count ); - for ( int i = 0; i < count; i++ ) - { - items.add( ValueUnboundRelationship.unpack( unpacker ) ); - } - return items; - } - else - { - return Collections.emptyList(); - } - } - - private List unpackSequence( Neo4jPack.Unpacker unpacker ) - throws IOException - { - int count = (int) unpacker.unpackListHeader(); - if ( count > 0 ) - { - List items = new ArrayList<>( count ); - for ( int i = 0; i < count; i++ ) - { - items.add( unpacker.unpackInteger() ); - } - return items; - } - else - { - return Collections.emptyList(); - } - } - - } - -} diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/UnboundRelationship.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/UnboundRelationship.java deleted file mode 100644 index 1babe062939b3..0000000000000 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/UnboundRelationship.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2002-2017 "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 . - */ -package org.neo4j.bolt.v1.messaging.infrastructure; - -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; - -public interface UnboundRelationship extends Relationship -{ - - /** - * Bind this relationship to a pair of nodes to create a full relationship. - * - */ - Relationship bind( Node startNode, Node endNode ); - -} diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueNode.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueNode.java deleted file mode 100644 index 8cd6c0ab8bbb3..0000000000000 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/infrastructure/ValueNode.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 2002-2017 "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 . - */ -package org.neo4j.bolt.v1.messaging.infrastructure; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.neo4j.bolt.v1.messaging.BoltIOException; -import org.neo4j.bolt.v1.messaging.Neo4jPack; -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Label; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.NotFoundException; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.RelationshipType; -import org.neo4j.helpers.collection.Iterables; -import org.neo4j.kernel.api.exceptions.Status; - -public class ValueNode - extends ValuePropertyContainer - implements Node -{ - private static final int STRUCT_FIELD_COUNT = 3; - - public static void pack( Neo4jPack.Packer packer, Node node ) - throws IOException - { - //TODO: We should mark deleted nodes properly but that requires updates to protocol and - //clients. Until that we merely don't fail and return a node with neither labels nor properties - packer.packStructHeader( STRUCT_FIELD_COUNT, Neo4jPack.NODE ); - packer.pack( node.getId() ); - try - { - //read labels and properties, will fail if node has been deleted - Collection