|
| 1 | +/* |
| 2 | + * DISCLAIMER |
| 3 | + * |
| 4 | + * Copyright 2016 ArangoDB GmbH, Cologne, Germany |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + * Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | + */ |
| 20 | + |
| 21 | +package com.arangodb.example.document; |
| 22 | + |
| 23 | +import com.arangodb.entity.DocumentImportEntity; |
| 24 | +import com.arangodb.example.ExampleBase; |
| 25 | +import com.arangodb.model.DocumentImportOptions; |
| 26 | +import org.junit.Test; |
| 27 | +import org.slf4j.Logger; |
| 28 | +import org.slf4j.LoggerFactory; |
| 29 | + |
| 30 | +import java.util.List; |
| 31 | +import java.util.UUID; |
| 32 | +import java.util.concurrent.CompletableFuture; |
| 33 | +import java.util.concurrent.ExecutionException; |
| 34 | +import java.util.stream.Collectors; |
| 35 | +import java.util.stream.IntStream; |
| 36 | + |
| 37 | +/** |
| 38 | + * @author Mark Vollmary |
| 39 | + */ |
| 40 | +public class ImportDocumentExample extends ExampleBase { |
| 41 | + |
| 42 | + private static final Logger log = LoggerFactory.getLogger(ImportDocumentExample.class); |
| 43 | + |
| 44 | + @Test |
| 45 | + public void insertBean() { |
| 46 | + List<CompletableFuture<DocumentImportEntity>> completableFutures = |
| 47 | + IntStream.range(0, 100) |
| 48 | + .mapToObj(i -> IntStream.range(0, 500) |
| 49 | + .mapToObj(it -> new TestEntity(UUID.randomUUID().toString())).collect(Collectors.toList()) |
| 50 | + ) |
| 51 | + .map(p -> collection.importDocuments(p, new DocumentImportOptions())) |
| 52 | + .collect(Collectors.toList()); |
| 53 | + |
| 54 | + completableFutures.forEach(cf -> { |
| 55 | + try { |
| 56 | + log.info(String.valueOf(cf.get().getCreated())); |
| 57 | + } catch (InterruptedException | ExecutionException e) { |
| 58 | + e.printStackTrace(); |
| 59 | + } |
| 60 | + }); |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments