Search in sources :

Example 1 with ValueStreamStore

use of com.palantir.atlasdb.performance.schema.generated.ValueStreamStore in project atlasdb by palantir.

the class StreamStoreBenchmarks method loadLargeStream.

@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 30, timeUnit = TimeUnit.SECONDS)
public void loadLargeStream(StreamingTable table) throws IOException {
    long id = table.getLargeStreamId();
    TransactionManager transactionManager = table.getTransactionManager();
    StreamTestTableFactory tables = StreamTestTableFactory.of();
    ValueStreamStore store = ValueStreamStore.of(transactionManager, tables);
    try (InputStream inputStream = transactionManager.runTaskThrowOnConflict(txn -> store.loadStream(txn, id))) {
        byte[] firstBytes = new byte[16];
        int read = inputStream.read(firstBytes);
        assertThat(read, is(16));
        assertArrayEquals(table.getLargeStreamFirstBytes(), firstBytes);
    }
}
Also used : TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) InputStream(java.io.InputStream) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore) Threads(org.openjdk.jmh.annotations.Threads) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with ValueStreamStore

use of com.palantir.atlasdb.performance.schema.generated.ValueStreamStore in project atlasdb by palantir.

the class StreamStoreBenchmarks method loadSmallStream.

@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 5, timeUnit = TimeUnit.SECONDS)
public void loadSmallStream(StreamingTable table) throws IOException {
    long id = table.getSmallStreamId();
    TransactionManager transactionManager = table.getTransactionManager();
    StreamTestTableFactory tables = StreamTestTableFactory.of();
    ValueStreamStore store = ValueStreamStore.of(transactionManager, tables);
    try (InputStream inputStream = transactionManager.runTaskThrowOnConflict(txn -> store.loadStream(txn, id));
        InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        BufferedReader bufferedReader = new BufferedReader(reader)) {
        String line = bufferedReader.readLine();
        assertThat(line, startsWith("bytes"));
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore) Threads(org.openjdk.jmh.annotations.Threads) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 3 with ValueStreamStore

use of com.palantir.atlasdb.performance.schema.generated.ValueStreamStore in project atlasdb by palantir.

the class StreamStoreBenchmarks method loadVeryLargeStream.

@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 30, timeUnit = TimeUnit.SECONDS)
public void loadVeryLargeStream(StreamingTable table) throws IOException {
    long id = table.getVeryLargeStreamId();
    TransactionManager transactionManager = table.getTransactionManager();
    StreamTestTableFactory tables = StreamTestTableFactory.of();
    ValueStreamStore store = ValueStreamStore.of(transactionManager, tables);
    try (InputStream inputStream = transactionManager.runTaskThrowOnConflict(txn -> store.loadStream(txn, id))) {
        byte[] firstBytes = new byte[16];
        int read = inputStream.read(firstBytes);
        assertThat(read, is(16));
        assertArrayEquals(table.getVeryLargeStreamFirstBytes(), firstBytes);
    }
}
Also used : TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) InputStream(java.io.InputStream) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore) Threads(org.openjdk.jmh.annotations.Threads) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 4 with ValueStreamStore

use of com.palantir.atlasdb.performance.schema.generated.ValueStreamStore in project atlasdb by palantir.

the class StreamingTable method storeStreamForRow.

private Long storeStreamForRow(byte[] data, String rowName) {
    StreamTestTableFactory tableFactory = StreamTestTableFactory.of();
    ValueStreamStore streamTestStreamStore = ValueStreamStore.of(getTransactionManager(), tableFactory);
    final Long streamId = streamTestStreamStore.storeStream(new ByteArrayInputStream(data)).getLhSide();
    getTransactionManager().runTaskThrowOnConflict(txn -> {
        KeyValueTable table = tableFactory.getKeyValueTable(txn);
        KeyValueTable.KeyValueRow row = KeyValueTable.KeyValueRow.of(rowName);
        KeyValueTable.StreamId id = KeyValueTable.StreamId.of(streamId);
        Multimap<Persistable, ColumnValue<?>> rows = ImmutableMultimap.of(row, id);
        txn.put(table.getTableRef(), ColumnValues.toCellValues(rows));
        return null;
    });
    return streamId;
}
Also used : Persistable(com.palantir.common.persist.Persistable) ByteArrayInputStream(java.io.ByteArrayInputStream) KeyValueTable(com.palantir.atlasdb.performance.schema.generated.KeyValueTable) ColumnValue(com.palantir.atlasdb.table.api.ColumnValue) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore)

Aggregations

StreamTestTableFactory (com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory)4 ValueStreamStore (com.palantir.atlasdb.performance.schema.generated.ValueStreamStore)4 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)3 InputStream (java.io.InputStream)3 Benchmark (org.openjdk.jmh.annotations.Benchmark)3 Measurement (org.openjdk.jmh.annotations.Measurement)3 Threads (org.openjdk.jmh.annotations.Threads)3 Warmup (org.openjdk.jmh.annotations.Warmup)3 KeyValueTable (com.palantir.atlasdb.performance.schema.generated.KeyValueTable)1 ColumnValue (com.palantir.atlasdb.table.api.ColumnValue)1 Persistable (com.palantir.common.persist.Persistable)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1