Skip to content

Commit 7a8d939

Browse files
committed
Change methods' signatures
1 parent 15959e5 commit 7a8d939

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

vertx-pg-client/src/main/java/examples/PgClientExamples.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
import io.vertx.core.Future;
2121
import io.vertx.core.Vertx;
22-
import io.vertx.core.buffer.Buffer;
23-
import io.vertx.core.buffer.impl.BufferImpl;
2422
import io.vertx.core.json.JsonObject;
2523
import io.vertx.core.net.PemTrustOptions;
2624
import io.vertx.docgen.Source;
@@ -738,7 +736,7 @@ public void batchReturning(SqlClient client) {
738736
public void importDataToDb(Vertx vertx, PgConnection client) {
739737
vertx.fileSystem().readFile("path/to/file")
740738
.flatMap(bufferAsyncResult -> {
741-
return client.copyFrom(
739+
return client.copyFromBytes(
742740
"COPY my_table FROM STDIN (FORMAT csv, HEADER)",
743741
bufferAsyncResult
744742
).execute();
@@ -749,12 +747,10 @@ public void importDataToDb(Vertx vertx, PgConnection client) {
749747
}
750748

751749
public void exportDataFromDb(Vertx vertx, PgConnection client) {
752-
Buffer buffer = new BufferImpl();
753750
String path = "path/to/file";
754-
client.copyTo("COPY my_table TO STDOUT (FORMAT csv, HEADER)", buffer)
755-
.andThen(res -> {
756-
vertx.fileSystem().writeFile("path/to/file.csv", buffer);
757-
}).onSuccess(res -> System.out.println("Data exported to " + path));
751+
client.copyToBytes("COPY my_table TO STDOUT (FORMAT csv, HEADER)").execute()
752+
.flatMap(buffer -> vertx.fileSystem().writeFile("path/to/file.csv", buffer))
753+
.onSuccess(res -> System.out.println("Data exported to " + path));
758754
}
759755

760756
public void pgBouncer(PgConnectOptions connectOptions) {

vertx-pg-client/src/main/java/io/vertx/pgclient/PgConnection.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static Future<PgConnection> connect(Vertx vertx, String connectionUri) {
111111
* @param from byte stream data will be fetched from
112112
* @return result set with single field {@code rowsWritten}
113113
*/
114-
Query<RowSet<Row>> copyFrom(String sql, Buffer from);
114+
Query<RowSet<Row>> copyFromBytes(String sql, Buffer from);
115115

116116
/**
117117
* Exports data from a database with decoding.
@@ -121,18 +121,17 @@ static Future<PgConnection> connect(Vertx vertx, String connectionUri) {
121121
* @param sql COPY command (example {@code COPY my_table TO STDOUT (FORMAT binary)})
122122
* @return decoded records
123123
*/
124-
Query<RowSet<Row>> copyTo(String sql);
124+
Query<RowSet<Row>> copyToRows(String sql);
125125

126126
/**
127127
* Exports data from a database as-is, without decoding.
128128
*
129129
* <p>Use this method when exporting opaque bytes, e.g. to a CSV file.
130130
*
131131
* @param sql COPY command (example {@code COPY my_table TO STDOUT (FORMAT csv)})
132-
* @param to bytes container data will be written to
133-
* @return async result
132+
* @return async result of bytes container data will be written to
134133
*/
135-
Future<Void> copyTo(String sql, Buffer to);
134+
Query<Buffer> copyToBytes(String sql);
136135

137136
/**
138137
* Send a request cancellation message to tell the server to cancel processing request in this connection.

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgConnectionImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ public PgConnection noticeHandler(Handler<PgNotice> handler) {
110110
}
111111

112112
@Override
113-
public Query<RowSet<Row>> copyFrom(String sql, Buffer from) {
113+
public Query<RowSet<Row>> copyFromBytes(String sql, Buffer from) {
114114
return null;
115115
}
116116

117117
@Override
118-
public Query<RowSet<Row>> copyTo(String sql) {
118+
public Query<RowSet<Row>> copyToRows(String sql) {
119119
return null;
120120
}
121121

122122
@Override
123-
public Future<Void> copyTo(String sql, Buffer to) {
124-
return Future.succeededFuture();
123+
public Query<Buffer> copyToBytes(String sql) {
124+
return null;
125125
}
126126

127127
@Override

vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionCopyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void testCopyToRows(TestContext ctx) {
1818
deleteFromTestTable(ctx, conn, () -> {
1919
insertIntoTestTable(ctx, conn, 10, () -> {
2020
PgConnection pgConn = (PgConnection) conn;
21-
pgConn.copyTo("COPY my_table TO STDOUT (FORMAT binary)")
21+
pgConn.copyToRows("COPY my_table TO STDOUT (FORMAT binary)")
2222
.execute()
2323
.onComplete(ctx.asyncAssertSuccess(result -> {
2424
for (int i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)