Skip to content

Commit 32628dd

Browse files
author
Zhen Li
committed
Passing bookmark to rediscover service
For bolt v4, when bookmark is passed into a session, if getRT call is invoked for that session, then the bookmark is passed down to the procedure call. Changed bookmark to be an object. The content of the object is transparent to driver users.
1 parent 5b7f678 commit 32628dd

File tree

105 files changed

+2099
-2126
lines changed

Some content is hidden

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

105 files changed

+2099
-2126
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import org.neo4j.driver.async.AsyncSession;
24+
import org.neo4j.driver.internal.Bookmark;
2425
import org.neo4j.driver.util.Resource;
2526

2627
/**
@@ -212,7 +213,7 @@ public interface Session extends Resource, StatementRunner
212213
*
213214
* @return a reference to a previous transaction
214215
*/
215-
String lastBookmark();
216+
Bookmark lastBookmark();
216217

217218
/**
218219
* Reset the current session. This sends an immediate RESET signal to the server which both interrupts

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

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

2121
import java.util.Arrays;
22-
import java.util.List;
2322
import java.util.Objects;
2423
import java.util.Optional;
2524

2625
import org.neo4j.driver.async.AsyncSession;
26+
import org.neo4j.driver.internal.Bookmark;
2727
import org.neo4j.driver.reactive.RxSession;
2828

2929
import static java.util.Objects.requireNonNull;
@@ -36,7 +36,7 @@ public class SessionConfig
3636
{
3737
private static final SessionConfig EMPTY = builder().build();
3838

39-
private final List<String> bookmarks;
39+
private final Iterable<Bookmark> bookmarks;
4040
private final AccessMode defaultAccessMode;
4141
private final String database;
4242

@@ -85,7 +85,7 @@ public static SessionConfig forDatabase( String database )
8585
*
8686
* @return the initial bookmarks.
8787
*/
88-
public List<String> bookmarks()
88+
public Iterable<Bookmark> bookmarks()
8989
{
9090
return bookmarks;
9191
}
@@ -143,7 +143,7 @@ public String toString()
143143
*/
144144
public static class Builder
145145
{
146-
private List<String> bookmarks = null;
146+
private Iterable<Bookmark> bookmarks = null;
147147
private AccessMode defaultAccessMode = AccessMode.WRITE;
148148
private String database = null;
149149

@@ -164,11 +164,10 @@ private Builder()
164164
* are permitted, and indicate that the bookmarks do not exist or are unknown.
165165
* @return this builder.
166166
*/
167-
public Builder withBookmarks( String... bookmarks )
167+
public Builder withBookmarks( Bookmark... bookmarks )
168168
{
169169
if ( bookmarks == null )
170170
{
171-
// TODO bookmarks should not be null
172171
this.bookmarks = null;
173172
}
174173
else
@@ -189,7 +188,7 @@ public Builder withBookmarks( String... bookmarks )
189188
* are permitted, and indicate that the bookmarks do not exist or are unknown.
190189
* @return this builder
191190
*/
192-
public Builder withBookmarks( List<String> bookmarks )
191+
public Builder withBookmarks( Iterable<Bookmark> bookmarks )
193192
{
194193
this.bookmarks = bookmarks;
195194
return this;

driver/src/main/java/org/neo4j/driver/async/AsyncSession.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.neo4j.driver.Transaction;
3030
import org.neo4j.driver.TransactionConfig;
3131
import org.neo4j.driver.Values;
32+
import org.neo4j.driver.internal.Bookmark;
3233

3334
/**
3435
* Provides a context of work for database interactions.
@@ -301,7 +302,7 @@ public interface AsyncSession extends AsyncStatementRunner
301302
*
302303
* @return a reference to a previous transaction
303304
*/
304-
String lastBookmark();
305+
Bookmark lastBookmark();
305306

306307
/**
307308
* Signal that you are done using this session. In the default driver usage, closing and accessing sessions is
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2002-2019 "Neo4j,"
3+
* Neo4j Sweden AB [http://neo4j.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+
/**
22+
* Causal chaining is carried out by passing bookmarks between transactions.
23+
*
24+
* When starting a session with initial bookmarks, the first transaction will be ensured to run at least after
25+
* the database is as up-to-date as the latest transaction referenced by the supplied bookmarks.
26+
*
27+
* Within a session, bookmark propagation is carried out automatically.
28+
* Thus all transactions in a session including explicit and implicit transactions are ensured to be carried out one after another.
29+
*
30+
* To opt out of this mechanism for unrelated units of work, applications can use multiple sessions.
31+
*/
32+
public interface Bookmark
33+
{
34+
}

driver/src/main/java/org/neo4j/driver/internal/BookmarksHolder.java renamed to driver/src/main/java/org/neo4j/driver/internal/BookmarkHolder.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,23 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21-
public interface BookmarksHolder
21+
public interface BookmarkHolder
2222
{
23-
Bookmarks getBookmarks();
23+
InternalBookmark getBookmark();
2424

25-
void setBookmarks( Bookmarks bookmarks );
25+
void setBookmark( InternalBookmark bookmark );
2626

27-
String lastBookmark();
28-
29-
BookmarksHolder NO_OP = new BookmarksHolder()
27+
BookmarkHolder NO_OP = new BookmarkHolder()
3028
{
3129
@Override
32-
public Bookmarks getBookmarks()
33-
{
34-
return Bookmarks.empty();
35-
}
36-
37-
@Override
38-
public void setBookmarks( Bookmarks bookmarks )
30+
public InternalBookmark getBookmark()
3931
{
32+
return InternalBookmark.empty();
4033
}
4134

4235
@Override
43-
public String lastBookmark()
36+
public void setBookmark( InternalBookmark bookmark )
4437
{
45-
return null;
4638
}
4739
};
4840
}

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

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)