Skip to content

Commit 7f82e7b

Browse files
committed
Remove protocol 1 and 2
The reference this protocols are not needed since it's not used by the driver anymore. During the remotion of these protocol version, the tests were refactoried to be specific per version instead of assume the re-use done on the protocols implementation.
1 parent 53fa23f commit 7f82e7b

File tree

61 files changed

+2753
-2321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2753
-2321
lines changed

driver/src/main/java/org/neo4j/driver/TransactionConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ public Builder withTimeout( Duration timeout )
202202
public Builder withMetadata( Map<String,Object> metadata )
203203
{
204204
requireNonNull( metadata, "Transaction metadata should not be null" );
205-
206205
this.metadata = Extract.mapOfValues( metadata );
207206
return this;
208207
}

driver/src/main/java/org/neo4j/driver/internal/handlers/PullHandlers.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,11 @@
2424
import org.neo4j.driver.internal.handlers.pulln.AutoPullResponseHandler;
2525
import org.neo4j.driver.internal.handlers.pulln.BasicPullResponseHandler;
2626
import org.neo4j.driver.internal.handlers.pulln.PullResponseHandler;
27-
import org.neo4j.driver.internal.messaging.v1.BoltProtocolV1;
2827
import org.neo4j.driver.internal.messaging.v3.BoltProtocolV3;
2928
import org.neo4j.driver.internal.spi.Connection;
3029

3130
public class PullHandlers
3231
{
33-
public static PullAllResponseHandler newBoltV1PullAllHandler(Query query, RunResponseHandler runHandler,
34-
Connection connection, UnmanagedTransaction tx )
35-
{
36-
PullResponseCompletionListener completionListener = createPullResponseCompletionListener( connection, BookmarkHolder.NO_OP, tx );
37-
38-
return new LegacyPullAllResponseHandler(query, runHandler, connection, BoltProtocolV1.METADATA_EXTRACTOR, completionListener );
39-
}
4032

4133
public static PullAllResponseHandler newBoltV3PullAllHandler(Query query, RunResponseHandler runHandler, Connection connection,
4234
BookmarkHolder bookmarkHolder, UnmanagedTransaction tx )

driver/src/main/java/org/neo4j/driver/internal/messaging/BoltProtocol.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import org.neo4j.driver.internal.async.UnmanagedTransaction;
3636
import org.neo4j.driver.internal.cluster.RoutingContext;
3737
import org.neo4j.driver.internal.cursor.ResultCursorFactory;
38-
import org.neo4j.driver.internal.messaging.v1.BoltProtocolV1;
39-
import org.neo4j.driver.internal.messaging.v2.BoltProtocolV2;
4038
import org.neo4j.driver.internal.messaging.v3.BoltProtocolV3;
4139
import org.neo4j.driver.internal.messaging.v4.BoltProtocolV4;
4240
import org.neo4j.driver.internal.messaging.v41.BoltProtocolV41;
@@ -154,25 +152,19 @@ static BoltProtocol forChannel( Channel channel )
154152
*/
155153
static BoltProtocol forVersion( BoltProtocolVersion version )
156154
{
157-
if ( BoltProtocolV1.VERSION.equals( version ) )
158-
{
159-
return BoltProtocolV1.INSTANCE;
160-
}
161-
else if ( BoltProtocolV2.VERSION.equals( version ) )
162-
{
163-
return BoltProtocolV2.INSTANCE;
164-
}
165-
else if ( BoltProtocolV3.VERSION.equals( version ) )
155+
if ( BoltProtocolV3.VERSION.equals( version ) )
166156
{
167157
return BoltProtocolV3.INSTANCE;
168158
}
169159
else if ( BoltProtocolV4.VERSION.equals( version ) )
170160
{
171161
return BoltProtocolV4.INSTANCE;
172-
} else if ( BoltProtocolV41.VERSION.equals( version ) )
162+
}
163+
else if ( BoltProtocolV41.VERSION.equals( version ) )
173164
{
174165
return BoltProtocolV41.INSTANCE;
175-
} else if ( BoltProtocolV42.VERSION.equals( version ) )
166+
}
167+
else if ( BoltProtocolV42.VERSION.equals( version ) )
176168
{
177169
return BoltProtocolV42.INSTANCE;
178170
}

driver/src/main/java/org/neo4j/driver/internal/messaging/v1/MessageReaderV1.java renamed to driver/src/main/java/org/neo4j/driver/internal/messaging/common/CommonMessageReader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver.internal.messaging.v1;
19+
package org.neo4j.driver.internal.messaging.common;
2020

2121
import java.io.IOException;
2222
import java.util.Map;
2323

24+
import org.neo4j.driver.Value;
2425
import org.neo4j.driver.internal.messaging.MessageFormat;
2526
import org.neo4j.driver.internal.messaging.ResponseMessageHandler;
2627
import org.neo4j.driver.internal.messaging.ValueUnpacker;
@@ -29,18 +30,17 @@
2930
import org.neo4j.driver.internal.messaging.response.RecordMessage;
3031
import org.neo4j.driver.internal.messaging.response.SuccessMessage;
3132
import org.neo4j.driver.internal.packstream.PackInput;
32-
import org.neo4j.driver.Value;
3333

34-
public class MessageReaderV1 implements MessageFormat.Reader
34+
public class CommonMessageReader implements MessageFormat.Reader
3535
{
3636
private final ValueUnpacker unpacker;
3737

38-
public MessageReaderV1( PackInput input )
38+
public CommonMessageReader( PackInput input )
3939
{
40-
this( new ValueUnpackerV1( input ) );
40+
this( new CommonValueUnpacker( input ) );
4141
}
4242

43-
protected MessageReaderV1( ValueUnpacker unpacker )
43+
protected CommonMessageReader( ValueUnpacker unpacker )
4444
{
4545
this.unpacker = unpacker;
4646
}

driver/src/main/java/org/neo4j/driver/internal/messaging/v2/ValuePackerV2.java renamed to driver/src/main/java/org/neo4j/driver/internal/messaging/common/CommonValuePacker.java

Lines changed: 121 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver.internal.messaging.v2;
19+
20+
package org.neo4j.driver.internal.messaging.common;
2021

2122
import java.io.IOException;
2223
import java.time.LocalDate;
@@ -26,47 +27,99 @@
2627
import java.time.ZoneId;
2728
import java.time.ZoneOffset;
2829
import java.time.ZonedDateTime;
30+
import java.util.Map;
2931

32+
import org.neo4j.driver.Value;
3033
import org.neo4j.driver.internal.InternalPoint2D;
3134
import org.neo4j.driver.internal.InternalPoint3D;
32-
import org.neo4j.driver.internal.messaging.v1.ValuePackerV1;
35+
import org.neo4j.driver.internal.messaging.ValuePacker;
3336
import org.neo4j.driver.internal.packstream.PackOutput;
34-
import org.neo4j.driver.internal.types.TypeConstructor;
37+
import org.neo4j.driver.internal.packstream.PackStream;
3538
import org.neo4j.driver.internal.value.InternalValue;
3639
import org.neo4j.driver.types.IsoDuration;
3740
import org.neo4j.driver.types.Point;
3841

3942
import static java.time.ZoneOffset.UTC;
40-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DATE;
41-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DATE_STRUCT_SIZE;
42-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DATE_TIME_STRUCT_SIZE;
43-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DATE_TIME_WITH_ZONE_ID;
44-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DATE_TIME_WITH_ZONE_OFFSET;
45-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DURATION;
46-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.DURATION_TIME_STRUCT_SIZE;
47-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.LOCAL_DATE_TIME;
48-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.LOCAL_DATE_TIME_STRUCT_SIZE;
49-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.LOCAL_TIME;
50-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.LOCAL_TIME_STRUCT_SIZE;
51-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.POINT_2D_STRUCT_SIZE;
52-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.POINT_2D_STRUCT_TYPE;
53-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.POINT_3D_STRUCT_SIZE;
54-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.POINT_3D_STRUCT_TYPE;
55-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.TIME;
56-
import static org.neo4j.driver.internal.messaging.v2.MessageFormatV2.TIME_STRUCT_SIZE;
57-
58-
public class ValuePackerV2 extends ValuePackerV1
43+
44+
public class CommonValuePacker implements ValuePacker
5945
{
60-
public ValuePackerV2( PackOutput output )
46+
47+
public static final byte DATE = 'D';
48+
public static final int DATE_STRUCT_SIZE = 1;
49+
50+
public static final byte TIME = 'T';
51+
public static final int TIME_STRUCT_SIZE = 2;
52+
53+
public static final byte LOCAL_TIME = 't';
54+
public static final int LOCAL_TIME_STRUCT_SIZE = 1;
55+
56+
public static final byte LOCAL_DATE_TIME = 'd';
57+
public static final int LOCAL_DATE_TIME_STRUCT_SIZE = 2;
58+
59+
public static final byte DATE_TIME_WITH_ZONE_OFFSET = 'F';
60+
public static final byte DATE_TIME_WITH_ZONE_ID = 'f';
61+
public static final int DATE_TIME_STRUCT_SIZE = 3;
62+
63+
public static final byte DURATION = 'E';
64+
public static final int DURATION_TIME_STRUCT_SIZE = 4;
65+
66+
public static final byte POINT_2D_STRUCT_TYPE = 'X';
67+
public static final int POINT_2D_STRUCT_SIZE = 3;
68+
69+
public static final byte POINT_3D_STRUCT_TYPE = 'Y';
70+
public static final int POINT_3D_STRUCT_SIZE = 4;
71+
72+
protected final PackStream.Packer packer;
73+
74+
public CommonValuePacker( PackOutput output )
75+
{
76+
this.packer = new PackStream.Packer( output );
77+
}
78+
79+
@Override
80+
public final void packStructHeader( int size, byte signature ) throws IOException
81+
{
82+
packer.packStructHeader( size, signature );
83+
}
84+
85+
@Override
86+
public final void pack( String string ) throws IOException
6187
{
62-
super( output );
88+
packer.pack( string );
89+
}
90+
91+
@Override
92+
public final void pack( Value value ) throws IOException
93+
{
94+
if ( value instanceof InternalValue )
95+
{
96+
packInternalValue( ((InternalValue) value) );
97+
}
98+
else
99+
{
100+
throw new IllegalArgumentException( "Unable to pack: " + value );
101+
}
63102
}
64103

65104
@Override
105+
public final void pack( Map<String,Value> map ) throws IOException
106+
{
107+
if ( map == null || map.size() == 0 )
108+
{
109+
packer.packMapHeader( 0 );
110+
return;
111+
}
112+
packer.packMapHeader( map.size() );
113+
for ( Map.Entry<String,Value> entry : map.entrySet() )
114+
{
115+
packer.pack( entry.getKey() );
116+
pack( entry.getValue() );
117+
}
118+
}
119+
66120
protected void packInternalValue( InternalValue value ) throws IOException
67121
{
68-
TypeConstructor typeConstructor = value.typeConstructor();
69-
switch ( typeConstructor )
122+
switch ( value.typeConstructor() )
70123
{
71124
case DATE:
72125
packDate( value.asLocalDate() );
@@ -89,8 +142,49 @@ protected void packInternalValue( InternalValue value ) throws IOException
89142
case POINT:
90143
packPoint( value.asPoint() );
91144
break;
145+
case NULL:
146+
packer.packNull();
147+
break;
148+
149+
case BYTES:
150+
packer.pack( value.asByteArray() );
151+
break;
152+
153+
case STRING:
154+
packer.pack( value.asString() );
155+
break;
156+
157+
case BOOLEAN:
158+
packer.pack( value.asBoolean() );
159+
break;
160+
161+
case INTEGER:
162+
packer.pack( value.asLong() );
163+
break;
164+
165+
case FLOAT:
166+
packer.pack( value.asDouble() );
167+
break;
168+
169+
case MAP:
170+
packer.packMapHeader( value.size() );
171+
for ( String s : value.keys() )
172+
{
173+
packer.pack( s );
174+
pack( value.get( s ) );
175+
}
176+
break;
177+
178+
case LIST:
179+
packer.packListHeader( value.size() );
180+
for ( Value item : value.values() )
181+
{
182+
pack( item );
183+
}
184+
break;
185+
92186
default:
93-
super.packInternalValue( value );
187+
throw new IOException( "Unknown type: " + value.type().name() );
94188
}
95189
}
96190

0 commit comments

Comments
 (0)