This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
threadPool.submit() -> { | |
Spliterator<T> spliterator = EsSpliterator.from(index, query, batchSize, documentClass, slices) | |
StreamSupport.stream(spliterator, true) | |
.forEach(batch -> handle(batch)); | |
}.get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spliterator<Collection<Foo>> fooSpliterator = EsSpliterator.from(index, query, batchSize, Foo.class, 2); | |
StreamSupport.stream(fooSpliterator, true) | |
.forEach(fooBatch -> handle(fooBatch)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Slice id 0, max slices 2 | |
Iterator<Collection<Foo>> fooIterator1 = new EsIterator<>(index, query, batchSize, Foo.class, 0, 2); | |
// Slice id 1, max slices 2 | |
Iterator<Collection<Foo>> fooIterator2 = new EsIterator<>(index, query, batchSize, Foo.class, 1, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterator<Collection<Foo>> fooIterator = new EsIterator<>(index, query, batchSize, Foo.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EsSpliterator<T> implements Spliterator<Collection<T>> { | |
private final List<EsIterator<T>> iterators = new ArrayList<>(); | |
// constructor omitted | |
private static <T> EsSpliterator<T> from(String index, QueryBuilder query, int batchSize, Class<T> documentClass, int maxSlices) { | |
List<EsIterator<T>> iterators = IntStream.range(0, maxSlices) | |
.mapToObj(i -> new EsIterator<>(index, query, batchSize, documentClass, i, maxSlices)) | |
.collect(toList()); | |
return new EsSpliterator<>(iterators); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public record Product(ProductId id, String name, String description, Images images, Attributes attributes) { | |
public Product { | |
Objects.requireNonNull(id); | |
// ... | |
} | |
}; | |
var product = new Product(new ProductId(1), "Nimbus 2000", "Fastest broom on the market", new Images(), new Attributes()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public record ProductId(long id){ | |
public ProductId { | |
Require.that(id > 0); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var point1 = new Point(0, 3); | |
var point2 = new Point(0, 3); | |
var point3 = new Point(3, 0); | |
point1.equals(point2); // true | |
point1.equals(point3); // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public record Point(int x, int y) {}; | |
var point = new Point(1, 2); | |
point.x(); // 1 | |
point.y(); // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestExtension implements BeforeAllCallback { | |
private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create("TestExtension"); | |
private static final String TEST_CONTEXT_PLACEHOLDER = "testContext"; | |
@Override | |
public void beforeAll(final ExtensionContext extensionContext) throws Exception { | |
if (TestExtensionInitializer.INSTANCE.initialize()) { | |
var testContext = TestContext.init(); | |
extensionContext.getRoot() |