-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Multiple bookmarks #376
Multiple bookmarks #376
Conversation
fa8f752
to
5dd44ca
Compare
5dd44ca
to
d27a29a
Compare
while ( iterator.hasNext() ) | ||
{ | ||
String bookmark = iterator.next(); | ||
long value = bookmarkValue( bookmark ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value might be null for the following case:
bookmarks = new String[]{aBookmark, null, null};
} | ||
|
||
@Override | ||
public Session session( Collection<String> bookmarks ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Five methods can be merged in to two
public Session session( String... bookmark )
public Session session( AccessMode mode, String... bookmark )
return maxValue; | ||
} | ||
|
||
public Map<String,Value> asParameters() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe asBeginTransactionParameters()
?
Previously it was possible to only supply a single bookmark when creating a new session. However there is a use-case to be able to supply multiple bookmarks when multiple worker threads execute write queries and then reader should be able to observe all those writes. To achieve this driver now exposed session creation methods that take an iterable of bookmarks. It was chosen to add additional `Driver#session()` overloads with `Iterable<String>` instead of extending single-bookmark methods with varargs because: * this maintains backwards compatibility for pre-existing methods * addition of varargs would make API look strange because call or `Driver#session()` and call of `Driver#session(String... bookmarks)` without params is essentially the same thing * invocation of vararg methods with single `null` argument can be confusing * varargs are more suitable for manual params listing Driver will now send: ``` { bookmark: "max", bookmarks: ["one", "two", "max"] } ``` instead of simple: ``` { bookmark: "max" } ``` this is done to maintain backwards compatibility with databases that only support single bookmark. It forces driver to parse and compare bookmarks which violates the fact that bookmarks are opaque. This is done only to maintain backwards compatibility and should not be copied. Code doing this will eventually be removed.
d27a29a
to
f186165
Compare
return maxValue == null; | ||
} | ||
|
||
public String asString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method name is confusing in a way that I would question why only return one bookmark rather than all of them back (like toString method).
Maybe change to names like asSingleString()
, or maxBookmarkAsString
, or singleBookmarkAsString
?
} | ||
|
||
@Test | ||
public void bookmarkFromIterable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a test for
Bookmark bookmark = Bookmark.from( asList(
null, "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ) );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* improve method naming in `Bookmark` * handle `null` bookmark in given `Iterable`
LGTM |
Previously it was possible to only supply a single bookmark when creating a new session. However there is a use-case to be able to supply multiple bookmarks when multiple worker threads execute write queries and then reader should be able to observe all those writes. To achieve this driver now exposed session creation methods that take an iterable of bookmarks.
It was chosen to add additional
Driver#session()
overloads withIterable<String>
instead of extending single-bookmark methods with varargs because:Driver#session()
and call ofDriver#session(String... bookmarks)
without params is essentially the same thingnull
argument can be confusingDriver will now send:
instead of simple:
this is done to maintain backwards compatibility with databases that only support single bookmark. It forces driver to parse and compare bookmarks which violates the fact that bookmarks are opaque. This is done only to maintain backwards compatibility and should not be copied. Code doing this will eventually be removed.
Related Bolt server PR: neo4j/neo4j#9404