Skip to content

Commit 9950bbd

Browse files
committed
Merge with 1.0 and fixed conflicts
2 parents 7f43744 + 7a5b05f commit 9950bbd

File tree

77 files changed

+2161
-1190
lines changed

Some content is hidden

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

77 files changed

+2161
-1190
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright (c) 2002-2016 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.internal;
20+
21+
import java.net.URI;
22+
23+
import org.neo4j.driver.internal.pool.InternalConnectionPool;
24+
import org.neo4j.driver.internal.spi.ConnectionPool;
25+
import org.neo4j.driver.v1.AuthToken;
26+
import org.neo4j.driver.v1.Config;
27+
import org.neo4j.driver.v1.Driver;
28+
import org.neo4j.driver.v1.Session;
29+
30+
public class InternalDriver implements Driver
31+
{
32+
private final ConnectionPool connections;
33+
private final URI url;
34+
private final Config config;
35+
36+
public InternalDriver( URI url, AuthToken authToken, Config config )
37+
{
38+
this.url = url;
39+
this.connections = new InternalConnectionPool( config, authToken );
40+
this.config = config;
41+
}
42+
43+
/**
44+
* Establish a session
45+
* @return a session that could be used to run {@link Session#run(String) a statement} or
46+
* {@link Session#beginTransaction() a transaction }.
47+
*/
48+
@Override
49+
public Session session()
50+
{
51+
return new InternalSession( connections.acquire( url ), config.logging().getLog( "session" ) );
52+
}
53+
54+
/**
55+
* Close all the resources assigned to this driver
56+
* @throws Exception any error that might happen when releasing all resources
57+
*/
58+
public void close() throws Exception
59+
{
60+
connections.close();
61+
}
62+
}

driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.neo4j.driver.internal;
2020

2121
import java.util.Arrays;
22+
import java.util.HashMap;
2223
import java.util.List;
2324
import java.util.Map;
2425
import java.util.NoSuchElementException;
@@ -37,14 +38,12 @@
3738
public class InternalRecord extends InternalRecordAccessor implements Record
3839
{
3940
private final List<String> keys;
40-
private final Map<String, Integer> keyIndexLookup;
4141
private final Value[] values;
4242
private int hashcode = 0;
4343

44-
public InternalRecord( List<String> keys, Map<String, Integer> keyIndexLookup, Value[] values )
44+
public InternalRecord( List<String> keys, Value[] values )
4545
{
4646
this.keys = keys;
47-
this.keyIndexLookup = keyIndexLookup;
4847
this.values = values;
4948
}
5049

@@ -57,8 +56,8 @@ public List<String> keys()
5756
@Override
5857
public int index( String key )
5958
{
60-
Integer result = keyIndexLookup.get( key );
61-
if ( result == null )
59+
int result = keys.indexOf( key );
60+
if ( result == -1 )
6261
{
6362
throw new NoSuchElementException( "Unknown key: " + key );
6463
}
@@ -71,15 +70,15 @@ public int index( String key )
7170
@Override
7271
public boolean containsKey( String key )
7372
{
74-
return keyIndexLookup.containsKey( key );
73+
return keys.contains( key );
7574
}
7675

7776
@Override
7877
public Value get( String key )
7978
{
80-
Integer fieldIndex = keyIndexLookup.get( key );
79+
int fieldIndex = keys.indexOf( key );
8180

82-
if ( fieldIndex == null )
81+
if ( fieldIndex == -1 )
8382
{
8483
return Values.NULL;
8584
}

0 commit comments

Comments
 (0)