Skip to content

Commit 1110bdd

Browse files
author
Zhen Li
committed
Renamed result#summary to result#consume
1 parent 32e3b66 commit 1110bdd

File tree

75 files changed

+307
-304
lines changed

Some content is hidden

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

75 files changed

+307
-304
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @see Session
3737
* @see Transaction
3838
* @see StatementResult
39-
* @see StatementResult#summary()
39+
* @see StatementResult#consume()
4040
* @see ResultSummary
4141
* @since 1.0
4242
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ public interface StatementResult extends Iterator<Record>
147147
*
148148
* @return a summary for the whole query result.
149149
*/
150-
ResultSummary summary();
150+
ResultSummary consume();
151151
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
* <ul>
4444
* <li>Read from or discard a result, for instance via
45-
* {@link StatementResult#next()} or {@link StatementResult#summary()} </li>
45+
* {@link StatementResult#next()} or {@link StatementResult#consume()} </li>
4646
* <li>Explicitly commit/rollback a transaction using blocking {@link Transaction#close()} </li>
4747
* <li>Close a session using blocking {@link Session#close()}</li>
4848
* </ul>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*
5252
* <ul>
5353
* <li>Read from or discard a result, for instance via
54-
* {@link StatementResultCursor#nextAsync()}, {@link StatementResultCursor#summaryAsync()}</li>
54+
* {@link StatementResultCursor#nextAsync()}, {@link StatementResultCursor#consumeAsync()}</li>
5555
* <li>Explicitly commit/rollback a transaction using {@link AsyncTransaction#commitAsync()}, {@link AsyncTransaction#rollbackAsync()}</li>
5656
* <li>Close a session using {@link AsyncSession#closeAsync()}</li>
5757
* </ul>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public interface StatementResultCursor
8080
* @return a {@link CompletionStage} completed with a summary for the whole query result. Stage can also be
8181
* completed exceptionally if query execution fails.
8282
*/
83-
CompletionStage<ResultSummary> summaryAsync();
83+
CompletionStage<ResultSummary> consumeAsync();
8484

8585
/**
8686
* Asynchronously navigate to and retrieve the next {@link Record} in this result. Returned stage can contain

driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ public TransactionNestingException( String message )
2727
{
2828
super( message );
2929
}
30+
31+
public TransactionNestingException()
32+
{
33+
this( "You cannot run another query or begin a new transaction in the same session before you've fully consumed the previous run result." );
34+
}
3035
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
public interface FailableCursor
2424
{
2525
/**
26-
* Dispose this cursor by discarding all unconsumed records and returning failure if there is any to run and/or pulls.
26+
* Discarding all unconsumed records and returning failure if there is any to run and/or pulls.
2727
*/
28-
CompletionStage<Throwable> consumeAsync();
28+
CompletionStage<Throwable> discardAllFailureAsync();
2929

3030
/**
3131
* Pulling all unconsumed records into memory and returning failure if there is any to run and/or pulls.
3232
*/
33-
CompletionStage<Throwable> failureAsync();
33+
CompletionStage<Throwable> pullAllFailureAsync();
3434
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public <T> List<T> list( Function<Record, T> mapFunction )
112112
}
113113

114114
@Override
115-
public ResultSummary summary()
115+
public ResultSummary consume()
116116
{
117-
return blockingGet( cursor.summaryAsync() );
117+
return blockingGet( cursor.consumeAsync() );
118118
}
119119

120120
@Override

driver/src/main/java/org/neo4j/driver/internal/async/NetworkSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public CompletionStage<Void> closeAsync()
197197
if ( cursor != null )
198198
{
199199
// there exists a cursor with potentially unconsumed error, try to extract and propagate it
200-
return cursor.consumeAsync();
200+
return cursor.discardAllFailureAsync();
201201
}
202202
// no result cursor exists so no error exists
203203
return completedWithNull();
@@ -255,7 +255,7 @@ private CompletionStage<Connection> acquireConnection( AccessMode mode )
255255
return completedWithNull();
256256
}
257257
// make sure previous result is fully consumed and connection is released back to the pool
258-
return cursor.failureAsync();
258+
return cursor.pullAllFailureAsync();
259259
} ).thenCompose( error ->
260260
{
261261
if ( error == null )

driver/src/main/java/org/neo4j/driver/internal/async/ResultCursorsHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ private static CompletionStage<Throwable> retrieveFailure( CompletionStage<? ext
7474
{
7575
return cursorStage
7676
.exceptionally( cursor -> null )
77-
.thenCompose( cursor -> cursor == null ? completedWithNull() : cursor.consumeAsync() );
77+
.thenCompose( cursor -> cursor == null ? completedWithNull() : cursor.discardAllFailureAsync() );
7878
}
7979
}

driver/src/main/java/org/neo4j/driver/internal/cursor/AsyncStatementResultCursorImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public List<String> keys()
4949
}
5050

5151
@Override
52-
public CompletionStage<ResultSummary> summaryAsync()
52+
public CompletionStage<ResultSummary> consumeAsync()
5353
{
54-
return pullAllHandler.summaryAsync();
54+
return pullAllHandler.consumeAsync();
5555
}
5656

5757
@Override
@@ -95,7 +95,7 @@ public CompletionStage<ResultSummary> forEachAsync( Consumer<Record> action )
9595
{
9696
CompletableFuture<Void> resultFuture = new CompletableFuture<>();
9797
internalForEachAsync( action, resultFuture );
98-
return resultFuture.thenCompose( ignore -> summaryAsync() );
98+
return resultFuture.thenCompose( ignore -> consumeAsync() );
9999
}
100100

101101
@Override
@@ -111,18 +111,17 @@ public <T> CompletionStage<List<T>> listAsync( Function<Record,T> mapFunction )
111111
}
112112

113113
@Override
114-
public CompletionStage<Throwable> consumeAsync()
114+
public CompletionStage<Throwable> discardAllFailureAsync()
115115
{
116-
return summaryAsync().handle( ( summary, error ) -> error );
116+
return consumeAsync().handle( ( summary, error ) -> error );
117117
}
118118

119119
@Override
120-
public CompletionStage<Throwable> failureAsync()
120+
public CompletionStage<Throwable> pullAllFailureAsync()
121121
{
122-
return pullAllHandler.failureAsync();
122+
return pullAllHandler.pullAllFailureAsync();
123123
}
124124

125-
126125
private void internalForEachAsync( Consumer<Record> action, CompletableFuture<Void> resultFuture )
127126
{
128127
CompletionStage<Record> recordFuture = nextAsync();

driver/src/main/java/org/neo4j/driver/internal/cursor/DisposableAsyncStatementResultCursor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public List<String> keys()
4848
}
4949

5050
@Override
51-
public CompletionStage<ResultSummary> summaryAsync()
51+
public CompletionStage<ResultSummary> consumeAsync()
5252
{
5353
isDisposed = true;
54-
return delegate.summaryAsync();
54+
return delegate.consumeAsync();
5555
}
5656

5757
@Override
@@ -91,18 +91,18 @@ public <T> CompletionStage<List<T>> listAsync( Function<Record,T> mapFunction )
9191
}
9292

9393
@Override
94-
public CompletionStage<Throwable> consumeAsync()
94+
public CompletionStage<Throwable> discardAllFailureAsync()
9595
{
9696
isDisposed = true;
97-
return delegate.consumeAsync();
97+
return delegate.discardAllFailureAsync();
9898
}
9999

100100
@Override
101-
public CompletionStage<Throwable> failureAsync()
101+
public CompletionStage<Throwable> pullAllFailureAsync()
102102
{
103103
// This one does not dispose the result so that a user could still visit the buffered result after this method call.
104104
// This also does not assert not disposed so that this method can be called after summary.
105-
return delegate.failureAsync();
105+
return delegate.pullAllFailureAsync();
106106
}
107107

108108
private <T> CompletableFuture<T> assertNotDisposed()

driver/src/main/java/org/neo4j/driver/internal/cursor/RxStatementResultCursorImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,21 @@ public void cancel()
9898
}
9999

100100
@Override
101-
public CompletionStage<Throwable> consumeAsync()
101+
public CompletionStage<Throwable> discardAllFailureAsync()
102102
{
103103
// calling this method will enforce discarding record stream and finish running cypher query
104104
return summaryAsync().thenApply( summary -> (Throwable) null ).exceptionally( error -> error );
105105
}
106106

107107
@Override
108-
public CompletionStage<Throwable> failureAsync()
108+
public CompletionStage<Throwable> pullAllFailureAsync()
109109
{
110110
if ( isRecordConsumerInstalled() && !isDone() )
111111
{
112-
throw new TransactionNestingException(
113-
"You cannot run another query or begin a new transaction in the same session before you've fully consumed the previous run result." );
112+
return CompletableFuture.completedFuture( new TransactionNestingException() );
114113
}
115114
// It is safe to discard records as either the streaming has not started at all, or the streaming is fully finished.
116-
return consumeAsync();
115+
return discardAllFailureAsync();
117116
}
118117

119118
@Override

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ public synchronized CompletionStage<Record> nextAsync()
178178
return peekAsync().thenApply( ignore -> dequeueRecord() );
179179
}
180180

181-
public synchronized CompletionStage<ResultSummary> summaryAsync()
181+
public synchronized CompletionStage<ResultSummary> consumeAsync()
182182
{
183183
ignoreRecords = true;
184184
records.clear();
185-
return failureAsync().thenApply( error ->
185+
return pullAllFailureAsync().thenApply( error ->
186186
{
187187
if ( error != null )
188188
{
@@ -194,7 +194,7 @@ public synchronized CompletionStage<ResultSummary> summaryAsync()
194194

195195
public synchronized <T> CompletionStage<List<T>> listAsync( Function<Record,T> mapFunction )
196196
{
197-
return failureAsync().thenApply( error ->
197+
return pullAllFailureAsync().thenApply( error ->
198198
{
199199
if ( error != null )
200200
{
@@ -210,7 +210,7 @@ public void prePopulateRecords()
210210
connection.writeAndFlush( PullAllMessage.PULL_ALL, this );
211211
}
212212

213-
public synchronized CompletionStage<Throwable> failureAsync()
213+
public synchronized CompletionStage<Throwable> pullAllFailureAsync()
214214
{
215215
if ( failure != null )
216216
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828

2929
public interface PullAllResponseHandler extends ResponseHandler
3030
{
31-
CompletionStage<ResultSummary> summaryAsync();
31+
CompletionStage<ResultSummary> consumeAsync();
3232

3333
CompletionStage<Record> nextAsync();
3434

3535
CompletionStage<Record> peekAsync();
3636

3737
<T> CompletionStage<List<T>> listAsync( Function<Record, T> mapFunction );
3838

39-
CompletionStage<Throwable> failureAsync();
39+
CompletionStage<Throwable> pullAllFailureAsync();
4040

4141
void prePopulateRecords();
4242
}

driver/src/main/java/org/neo4j/driver/internal/handlers/pulln/AutoPullResponseHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public synchronized CompletionStage<Record> nextAsync()
137137
return peekAsync().thenApply( ignore -> dequeueRecord() );
138138
}
139139

140-
public synchronized CompletionStage<ResultSummary> summaryAsync()
140+
public synchronized CompletionStage<ResultSummary> consumeAsync()
141141
{
142142
records.clear();
143143
if ( isDone() )
@@ -162,7 +162,7 @@ public synchronized <T> CompletionStage<List<T>> listAsync( Function<Record,T> m
162162
}
163163

164164
@Override
165-
public synchronized CompletionStage<Throwable> failureAsync()
165+
public synchronized CompletionStage<Throwable> pullAllFailureAsync()
166166
{
167167
return pullAllAsync().handle( ( ignore, error ) -> error );
168168
}

driver/src/main/java/org/neo4j/driver/internal/reactive/InternalRxStatementResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ synchronized CompletionStage<RxStatementResultCursor> initCursorFuture()
112112
}
113113

114114
@Override
115-
public Publisher<ResultSummary> summary()
115+
public Publisher<ResultSummary> consume()
116116
{
117117
return Mono.create( sink -> getCursorFuture().whenComplete( ( cursor, completionError ) -> {
118118
if ( cursor != null )

driver/src/main/java/org/neo4j/driver/internal/util/ServerVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static ServerVersion version( Driver driver )
6464
{
6565
try ( Session session = driver.session() )
6666
{
67-
String versionString = session.readTransaction( tx -> tx.run( "RETURN 1" ).summary().server().version() );
67+
String versionString = session.readTransaction( tx -> tx.run( "RETURN 1" ).consume().server().version() );
6868
return version( versionString );
6969
}
7070
}

driver/src/main/java/org/neo4j/driver/reactive/RxStatementResult.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ public interface RxStatementResult
4545
* <p>
4646
* When this publisher is {@linkplain Publisher#subscribe(Subscriber) subscribed}, the query statement is sent to the server and executed.
4747
* This method does not start the record streaming nor publish query execution error.
48-
* To retrieve the execution result, either {@link #records()} or {@link #summary()} can be used.
48+
* To retrieve the execution result, either {@link #records()} or {@link #consume()} can be used.
4949
* {@link #records()} starts record streaming and reports query execution error.
50-
* {@link #summary()} skips record streaming and directly reports query execution error.
50+
* {@link #consume()} skips record streaming and directly reports query execution error.
5151
* <p>
5252
* Consuming of execution result ensures the resources (such as network connections) used by this result is freed correctly.
5353
* Consuming the keys without consuming the execution result will result in resource leak.
5454
* To avoid the resource leak, {@link RxSession#close()} (and/or {@link RxTransaction#commit()} and {@link RxTransaction#rollback()}) shall be invoked
5555
* and subscribed to enforce the result resources created in the {@link RxSession} (and/or {@link RxTransaction}) to be freed correctly.
5656
* <p>
5757
* This publisher can be subscribed many times. The keys published stays the same as the keys are buffered.
58-
* If this publisher is subscribed after the publisher of {@link #records()} or {@link #summary()},
58+
* If this publisher is subscribed after the publisher of {@link #records()} or {@link #consume()},
5959
* then the buffered keys will be returned.
6060
* @return a cold publisher of keys.
6161
*/
@@ -83,7 +83,7 @@ public interface RxStatementResult
8383
* This publisher can only be subscribed by one {@link Subscriber} once.
8484
* <p>
8585
* If this publisher is subscribed after {@link #keys()}, then the publish of records is carried out after the arrival of keys.
86-
* If this publisher is subscribed after {@link #summary()}, then the publish of records is already cancelled
86+
* If this publisher is subscribed after {@link #consume()}, then the publish of records is already cancelled
8787
* and an empty publisher of zero record will be return.
8888
* @return a cold unicast publisher of records.
8989
*/
@@ -104,5 +104,5 @@ public interface RxStatementResult
104104
* This method can be subscribed multiple times. When the {@linkplain ResultSummary summary} arrives, it will be buffered locally for all subsequent calls.
105105
* @return a cold publisher of result summary which only arrives after all records.
106106
*/
107-
Publisher<ResultSummary> summary();
107+
Publisher<ResultSummary> consume();
108108
}

driver/src/test/java/org/neo4j/driver/integration/BookmarkIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void bookmarkRemainsAfterSuccessfulSessionRun()
166166
Bookmark bookmark = session.lastBookmark();
167167
assertBookmarkContainsSingleValue( bookmark );
168168

169-
session.run( "RETURN 1" ).summary();
169+
session.run( "RETURN 1" ).consume();
170170

171171
assertEquals( bookmark, session.lastBookmark() );
172172
}
@@ -181,7 +181,7 @@ void bookmarkRemainsAfterFailedSessionRun()
181181
Bookmark bookmark = session.lastBookmark();
182182
assertBookmarkContainsSingleValue( bookmark );
183183

184-
assertThrows( ClientException.class, () -> session.run( "RETURN" ).summary() );
184+
assertThrows( ClientException.class, () -> session.run( "RETURN" ).consume() );
185185
assertEquals( bookmark, session.lastBookmark() );
186186
}
187187

driver/src/test/java/org/neo4j/driver/integration/ConnectionHandlingIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void connectionUsedForSessionRunReturnedToThePoolWhenResultConsumed()
116116
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
117117
verify( connection1, never() ).release();
118118

119-
result.summary();
119+
result.consume();
120120

121121
Connection connection2 = connectionPool.lastAcquiredConnectionSpy;
122122
assertSame( connection1, connection2 );
@@ -131,7 +131,7 @@ void connectionUsedForSessionRunReturnedToThePoolWhenResultSummaryObtained()
131131
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
132132
verify( connection1, never() ).release();
133133

134-
ResultSummary summary = result.summary();
134+
ResultSummary summary = result.consume();
135135

136136
assertEquals( 5, summary.counters().nodesCreated() );
137137
Connection connection2 = connectionPool.lastAcquiredConnectionSpy;
@@ -201,7 +201,7 @@ void connectionUsedForSessionRunReturnedToThePoolWhenServerErrorDuringResultFetc
201201
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
202202
verify( connection1, never() ).release();
203203

204-
assertThrows( ClientException.class, result::summary );
204+
assertThrows( ClientException.class, result::consume );
205205

206206
Connection connection2 = connectionPool.lastAcquiredConnectionSpy;
207207
assertSame( connection1, connection2 );
@@ -355,7 +355,7 @@ void resultSummaryShouldReleaseConnectionUsedBySessionRun() throws Throwable
355355
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
356356
assertNull( connection1 );
357357

358-
StepVerifier.create( Mono.from( res.summary() ) ).expectNextCount( 1 ).verifyComplete();
358+
StepVerifier.create( Mono.from( res.consume() ) ).expectNextCount( 1 ).verifyComplete();
359359

360360
Connection connection2 = connectionPool.lastAcquiredConnectionSpy;
361361
assertNotSame( connection1, connection2 );

driver/src/test/java/org/neo4j/driver/integration/ConnectionPoolIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private static void startAndCloseTransactions( Driver driver, int txCount )
173173
{
174174
for ( StatementResult result : results )
175175
{
176-
result.summary();
176+
result.consume();
177177
}
178178
for ( Transaction tx : transactions )
179179
{

0 commit comments

Comments
 (0)