Skip to content

Commit dc3240f

Browse files
committed
reverted batch threaded document import
1 parent fbb77c2 commit dc3240f

File tree

4 files changed

+0
-117
lines changed

4 files changed

+0
-117
lines changed

pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@
230230
<artifactId>httpcore</artifactId>
231231
<scope>provided</scope>
232232
</dependency>
233-
<dependency>
234-
<groupId>org.apache.commons</groupId>
235-
<artifactId>commons-collections4</artifactId>
236-
</dependency>
237233
<dependency>
238234
<groupId>commons-logging</groupId>
239235
<artifactId>commons-logging</artifactId>
@@ -279,11 +275,6 @@
279275
<artifactId>httpcore</artifactId>
280276
<version>4.4.11</version>
281277
</dependency>
282-
<dependency>
283-
<groupId>org.apache.commons</groupId>
284-
<artifactId>commons-collections4</artifactId>
285-
<version>4.4</version>
286-
</dependency>
287278
<dependency>
288279
<groupId>commons-codec</groupId>
289280
<artifactId>commons-codec</artifactId>

src/main/java/com/arangodb/ArangoCollection.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,6 @@ <T> MultiDocumentEntity<DocumentCreateEntity<T>> insertDocuments(
120120
*/
121121
DocumentImportEntity importDocuments(Collection<?> values, DocumentImportOptions options) throws ArangoDBException;
122122

123-
/**
124-
* Bulk imports the given values into the collection.
125-
*
126-
* @param values a list of Objects that will be stored as documents
127-
* @param options Additional options, can be null
128-
* @param batchSize Size for individual data batches of the original collection of values
129-
* @param numThreads Number of parallel import threads
130-
* @return list of information about the imported batches
131-
* @throws ArangoDBException
132-
*/
133-
Collection<DocumentImportEntity> importDocuments(
134-
Collection<?> values, DocumentImportOptions options, int batchSize, int numThreads)
135-
throws ArangoDBException;
136-
137123
/**
138124
* Bulk imports the given values into the collection.
139125
*

src/main/java/com/arangodb/internal/ArangoCollectionImpl.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,9 @@
2020

2121
package com.arangodb.internal;
2222

23-
import java.util.ArrayList;
2423
import java.util.Collection;
25-
import java.util.List;
26-
import java.util.concurrent.CompletableFuture;
27-
import java.util.concurrent.ExecutionException;
28-
import java.util.concurrent.ExecutorService;
29-
import java.util.concurrent.Executors;
3024

3125
import com.arangodb.entity.*;
32-
import org.apache.commons.collections4.ListUtils;
3326
import org.slf4j.Logger;
3427
import org.slf4j.LoggerFactory;
3528

@@ -89,35 +82,6 @@ public DocumentImportEntity importDocuments(final Collection<?> values, final Do
8982
return executor.execute(importDocumentsRequest(values, options), DocumentImportEntity.class);
9083
}
9184

92-
@Override
93-
public Collection<DocumentImportEntity> importDocuments(
94-
Collection<?> values, DocumentImportOptions options, int batchSize, int numThreads)
95-
throws ArangoDBException {
96-
List<? extends List<?>> batches = ListUtils.partition(new ArrayList<>(values), batchSize);
97-
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
98-
List<CompletableFuture<DocumentImportEntity>> completableFutureList = new ArrayList<>();
99-
for (List<?> batch : batches) {
100-
CompletableFuture<DocumentImportEntity> completableFuture = CompletableFuture.supplyAsync(() -> {
101-
DocumentImportEntity documentImportEntity = importDocuments(batch, options);
102-
return documentImportEntity;
103-
}, executorService);
104-
completableFutureList.add(completableFuture);
105-
}
106-
List<DocumentImportEntity> documentImportEntityList = new ArrayList<>();
107-
for (CompletableFuture<DocumentImportEntity> completableFuture : completableFutureList) {
108-
DocumentImportEntity documentImportEntity = null;
109-
try {
110-
documentImportEntity = completableFuture.get();
111-
} catch (InterruptedException | ExecutionException e) {
112-
executorService.shutdown();
113-
throw new ArangoDBException(e);
114-
}
115-
documentImportEntityList.add(documentImportEntity);
116-
}
117-
executorService.shutdown();
118-
return documentImportEntityList;
119-
}
120-
12185
@Override
12286
public DocumentImportEntity importDocuments(final String values) throws ArangoDBException {
12387
return importDocuments(values, new DocumentImportOptions());

src/test/java/com/arangodb/ArangoCollectionTest.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,64 +1918,6 @@ public void importDocumentsJsonFromToPrefix() {
19181918
}
19191919
}
19201920

1921-
@Test
1922-
public void importDocumentsBatchSizeNumThreads() {
1923-
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
1924-
for (int i = 1; i <= 100; i++) {
1925-
values.add(new BaseDocument(String.valueOf(i)));
1926-
}
1927-
int batchSize = 5;
1928-
int numThreads = 8;
1929-
final Collection<DocumentImportEntity> docsList = db.collection(COLLECTION_NAME)
1930-
.importDocuments(values, new DocumentImportOptions(), batchSize, numThreads);
1931-
assertThat(docsList.size(), is(values.size() / batchSize));
1932-
for (final DocumentImportEntity docs : docsList) {
1933-
assertThat(docs, is(notNullValue()));
1934-
assertThat(docs.getCreated(), is(batchSize));
1935-
assertThat(docs.getEmpty(), is(0));
1936-
assertThat(docs.getErrors(), is(0));
1937-
assertThat(docs.getIgnored(), is(0));
1938-
assertThat(docs.getUpdated(), is(0));
1939-
assertThat(docs.getDetails(), is(empty()));
1940-
}
1941-
}
1942-
1943-
@Test
1944-
public void importDocumentsBatchSizeNumThreadsIllegalBatchSize() {
1945-
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
1946-
for (int i = 1; i <= 10; i++) {
1947-
values.add(new BaseDocument(String.valueOf(i)));
1948-
}
1949-
1950-
int batchSize = 0;
1951-
int numThreads = 8;
1952-
1953-
try {
1954-
final Collection<DocumentImportEntity> docsList = db.collection(COLLECTION_NAME)
1955-
.importDocuments(values, new DocumentImportOptions(), batchSize, numThreads);
1956-
fail();
1957-
} catch (IllegalArgumentException e) {
1958-
}
1959-
}
1960-
1961-
@Test
1962-
public void importDocumentsBatchSizeNumThreadsIllegalNumThreads() {
1963-
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
1964-
for (int i = 1; i <= 10; i++) {
1965-
values.add(new BaseDocument(String.valueOf(i)));
1966-
}
1967-
1968-
int batchSize = 5;
1969-
int numThreads = 0;
1970-
1971-
try {
1972-
final Collection<DocumentImportEntity> docsList = db.collection(COLLECTION_NAME)
1973-
.importDocuments(values, new DocumentImportOptions(), batchSize, numThreads);
1974-
fail();
1975-
} catch (IllegalArgumentException e) {
1976-
}
1977-
}
1978-
19791921
@Test
19801922
public void deleteDocumentsByKey() {
19811923
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();

0 commit comments

Comments
 (0)