Search in sources :

Example 1 with BlockGetter

use of com.palantir.atlasdb.stream.BlockGetter in project atlasdb by palantir.

the class StreamTestWithHashStreamStore method makeStreamUsingTransaction.

private InputStream makeStreamUsingTransaction(Transaction parent, Long id, StreamMetadata metadata) {
    BiConsumer<Long, OutputStream> singleBlockLoader = (index, destination) -> loadSingleBlockToOutputStream(parent, id, index, destination);
    BlockGetter pageRefresher = new BlockLoader(singleBlockLoader, BLOCK_SIZE_IN_BYTES);
    long totalBlocks = getNumberOfBlocksFromMetadata(metadata);
    int blocksInMemory = getNumberOfBlocksThatFitInMemory();
    try {
        return BlockConsumingInputStream.create(pageRefresher, totalBlocks, blocksInMemory);
    } catch (IOException e) {
        throw Throwables.throwUncheckedException(e);
    }
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Arrays(java.util.Arrays) ByteArrayIOStream(com.palantir.util.ByteArrayIOStream) BufferedInputStream(java.io.BufferedInputStream) Throwables(com.palantir.common.base.Throwables) LoggerFactory(org.slf4j.LoggerFactory) Collections2(com.google.common.collect.Collections2) Generated(javax.annotation.Generated) HashMultimap(com.google.common.collect.HashMultimap) AssertUtils(com.palantir.util.AssertUtils) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) ImmutableSet(com.google.common.collect.ImmutableSet) TempFileUtils(com.palantir.util.file.TempFileUtils) ImmutableMap(com.google.common.collect.ImmutableMap) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Collection(java.util.Collection) Set(java.util.Set) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) FileNotFoundException(java.io.FileNotFoundException) Sets(com.google.common.collect.Sets) CountingInputStream(com.google.common.io.CountingInputStream) ByteString(com.google.protobuf.ByteString) List(java.util.List) BlockConsumingInputStream(com.palantir.atlasdb.stream.BlockConsumingInputStream) TxTask(com.palantir.atlasdb.transaction.impl.TxTask) BlockGetter(com.palantir.atlasdb.stream.BlockGetter) Transaction(com.palantir.atlasdb.transaction.api.Transaction) Entry(java.util.Map.Entry) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) StreamMetadata(com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata) StreamCleanedException(com.palantir.atlasdb.stream.StreamCleanedException) MessageDigest(java.security.MessageDigest) TransactionFailedRetriableException(com.palantir.atlasdb.transaction.api.TransactionFailedRetriableException) Multimap(com.google.common.collect.Multimap) LZ4CompressingInputStream(com.palantir.common.compression.LZ4CompressingInputStream) LZ4BlockInputStream(net.jpountz.lz4.LZ4BlockInputStream) Multimaps(com.google.common.collect.Multimaps) Lists(com.google.common.collect.Lists) Status(com.palantir.atlasdb.protos.generated.StreamPersistence.Status) BiConsumer(java.util.function.BiConsumer) BlockLoader(com.palantir.atlasdb.stream.BlockLoader) PersistentStreamStore(com.palantir.atlasdb.stream.PersistentStreamStore) Builder(com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata.Builder) Sha256Hash(com.palantir.util.crypto.Sha256Hash) OutputStream(java.io.OutputStream) Functions(com.google.common.base.Functions) ConcatenatedInputStream(com.palantir.common.io.ConcatenatedInputStream) Logger(org.slf4j.Logger) FileOutputStream(java.io.FileOutputStream) SetView(com.google.common.collect.Sets.SetView) IOException(java.io.IOException) DeleteOnCloseFileInputStream(com.palantir.util.file.DeleteOnCloseFileInputStream) Maps(com.google.common.collect.Maps) Ints(com.google.common.primitives.Ints) File(java.io.File) Pair(com.palantir.util.Pair) TimeUnit(java.util.concurrent.TimeUnit) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) AbstractPersistentStreamStore(com.palantir.atlasdb.stream.AbstractPersistentStreamStore) DigestInputStream(java.security.DigestInputStream) Preconditions(com.google.common.base.Preconditions) CheckForNull(javax.annotation.CheckForNull) InputStream(java.io.InputStream) BlockGetter(com.palantir.atlasdb.stream.BlockGetter) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BlockLoader(com.palantir.atlasdb.stream.BlockLoader) IOException(java.io.IOException)

Aggregations

Functions (com.google.common.base.Functions)1 Preconditions (com.google.common.base.Preconditions)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Collections2 (com.google.common.collect.Collections2)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Multimaps (com.google.common.collect.Multimaps)1 Sets (com.google.common.collect.Sets)1 SetView (com.google.common.collect.Sets.SetView)1 ByteStreams (com.google.common.io.ByteStreams)1 CountingInputStream (com.google.common.io.CountingInputStream)1 Ints (com.google.common.primitives.Ints)1 ByteString (com.google.protobuf.ByteString)1 Cell (com.palantir.atlasdb.keyvalue.api.Cell)1 Status (com.palantir.atlasdb.protos.generated.StreamPersistence.Status)1 StreamMetadata (com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata)1