@Override public CompletableFuture<byte[]> readBytes(BlobId blobId) { return metricFactory .runPublishingTimerMetric(READ_BYTES_TIMER_NAME, blobStoreImpl.readBytes(blobId)); }
private CompletableFuture<Pair<BlobType, BlobId>> saveEntry(Pair<BlobType, InputStream> entry) { return blobStore.save(entry.getRight()) .thenApply(blobId -> Pair.of(entry.getLeft(), blobId)); }
@Override public InputStream read(BlobId blobId) { return metricFactory .runPublishingTimerMetric(READ_TIMER_NAME, () -> blobStoreImpl.read(blobId)); } }
@Test void readBytesShouldReturnSplitSavedDataByChunk() { String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE); BlobId blobId = testee.save(longString.getBytes(StandardCharsets.UTF_8)).join(); byte[] bytes = testee.readBytes(blobId).join(); assertThat(new String(bytes, StandardCharsets.UTF_8)).isEqualTo(longString); }
private CompletableFuture<Pair<BlobType, BlobId>> saveEntry(Pair<BlobType, InputStream> entry) { return blobStore.save(entry.getRight()) .thenApply(blobId -> Pair.of(entry.getLeft(), blobId)); }
private CompletionStage<Optional<Attachment>> retrievePayload(Optional<DAOAttachment> daoAttachmentOptional) { if (!daoAttachmentOptional.isPresent()) { return CompletableFuture.completedFuture(Optional.empty()); } DAOAttachment daoAttachment = daoAttachmentOptional.get(); return blobStore.readBytes(daoAttachment.getBlobId()) .thenApply(bytes -> Optional.of(daoAttachment.toAttachment(bytes))); }
@Test default void readShouldThrowWhenNoExistingStream() { assertThatThrownBy(() -> testee().read(blobIdFactory().from("unknown"))) .isInstanceOf(ObjectStoreException.class); }
@Override public CompletableFuture<BlobId> save(InputStream data) { return metricFactory .runPublishingTimerMetric(SAVE_INPUT_STREAM_TIMER_NAME, blobStoreImpl.save(data)); }
@Override public CompletableFuture<T> read(I blobIds) { CompletableFuture<Stream<Pair<BlobType, byte[]>>> binaries = FluentFutureStream.of(blobIds.asMap() .entrySet() .stream() .map(entry -> blobStore.readBytes(entry.getValue()) .thenApply(bytes -> Pair.of(entry.getKey(), bytes)))) .completableFuture(); return binaries.thenApply(decoder::decode); } }
@Override public CompletableFuture<BlobId> save(byte[] data) { return metricFactory .runPublishingTimerMetric(SAVE_BYTES_TIMER_NAME, blobStoreImpl.save(data)); }
@Override public CompletableFuture<T> read(I blobIds) { CompletableFuture<Stream<Pair<BlobType, byte[]>>> binaries = FluentFutureStream.of(blobIds.asMap() .entrySet() .stream() .map(entry -> blobStore.readBytes(entry.getValue()) .thenApply(bytes -> Pair.of(entry.getKey(), bytes)))) .completableFuture(); return binaries.thenApply(decoder::decode); } }