Skip to content

Commit 4a5d7d8

Browse files
author
Achim Brandt
committed
Merge pull request #31 from jan-zajic/batch-perf
Batch driver performance fix
2 parents 3f07d58 + e555b87 commit 4a5d7d8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/com/arangodb/impl/InternalBatchDriverImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,26 @@ public class InternalBatchDriverImpl extends BaseArangoDriverImpl {
5151

5252
public DefaultEntity executeBatch(List<BatchPart> callStack, String defaultDataBase) throws ArangoException {
5353

54-
String body = "";
54+
StringBuilder body = new StringBuilder();
5555

5656
Map<String, InvocationObject> resolver = new HashMap<String, InvocationObject>();
5757

5858
for (BatchPart bp : callStack) {
59-
body += "--" + delimiter + newline;
60-
body += "Content-Type: application/x-arango-batchpart" + newline;
61-
body += "Content-Id: " + bp.getId() + newline + newline;
62-
body += bp.getMethod() + " " + bp.getUrl() + " " + "HTTP/1.1" + newline;
63-
body += "Host: " + this.configure.getArangoHost().getHost() + newline + newline;
64-
body += bp.getBody() == null ? "" : bp.getBody() + newline + newline;
59+
body.append("--").append(delimiter).append(newline);
60+
body.append("Content-Type: application/x-arango-batchpart").append(newline);
61+
body.append("Content-Id: ").append(bp.getId()).append(newline).append(newline);
62+
body.append(bp.getMethod()).append(" ").append(bp.getUrl()).append(" ").append("HTTP/1.1").append(newline);
63+
body.append("Host: ").append(this.configure.getArangoHost().getHost()).append(newline).append(newline);
64+
body.append(bp.getBody() == null ? "" : bp.getBody()).append(newline).append(newline);
6565
resolver.put(bp.getId(), bp.getInvocationObject());
6666
}
67-
body += "--" + delimiter + "--";
67+
body.append("--").append(delimiter).append("--");
6868

6969
Map<String, Object> headers = new HashMap<String, Object>();
7070
headers.put("Content-Type", "multipart/form-data; boundary=" + delimiter);
7171

7272
HttpResponseEntity res = httpManager.doPostWithHeaders(createEndpointUrl(defaultDataBase, "/_api/batch"), null,
73-
null, headers, body);
73+
null, headers, body.toString());
7474

7575
String data = res.getText();
7676
res.setContentType("application/json");

0 commit comments

Comments
 (0)