Search in sources :

Example 1 with Count

use of org.apache.beam.sdk.transforms.Count in project beam by apache.

the class TestStreamTest method testEarlyPanesOfWindow.

@Test
@Category({ ValidatesRunner.class, UsesTestStreamWithProcessingTime.class })
public void testEarlyPanesOfWindow() {
    TestStream<Long> source = TestStream.create(VarLongCoder.of()).addElements(TimestampedValue.of(1L, new Instant(1000L))).advanceProcessingTime(// Fire early pane
    Duration.standardMinutes(6)).addElements(TimestampedValue.of(2L, new Instant(2000L))).advanceProcessingTime(// Fire early pane
    Duration.standardMinutes(6)).addElements(TimestampedValue.of(3L, new Instant(3000L))).advanceProcessingTime(// Fire early pane
    Duration.standardMinutes(6)).advanceWatermarkToInfinity();
    PCollection<KV<String, Long>> sum = p.apply(source).apply(Window.<Long>into(FixedWindows.of(Duration.standardMinutes(30))).triggering(AfterWatermark.pastEndOfWindow().withEarlyFirings(AfterProcessingTime.pastFirstElementInPane().plusDelayOf(Duration.standardMinutes(5)))).accumulatingFiredPanes().withAllowedLateness(Duration.ZERO)).apply(MapElements.into(TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.longs())).via(v -> KV.of("key", v))).apply(Sum.longsPerKey());
    IntervalWindow window = new IntervalWindow(new Instant(0L), new Instant(0L).plus(Duration.standardMinutes(30)));
    PAssert.that(sum).inEarlyPane(window).satisfies(input -> {
        assertThat(StreamSupport.stream(input.spliterator(), false).count(), is(3L));
        return null;
    }).containsInAnyOrder(KV.of("key", 1L), KV.of("key", 3L), KV.of("key", 6L)).inOnTimePane(window).satisfies(input -> {
        assertThat(StreamSupport.stream(input.spliterator(), false).count(), is(1L));
        return null;
    }).containsInAnyOrder(KV.of("key", 6L));
    p.run().waitUntilFinish();
}
Also used : Count(org.apache.beam.sdk.transforms.Count) Window.into(org.apache.beam.sdk.transforms.windowing.Window.into) StateSpec(org.apache.beam.sdk.state.StateSpec) CoderUtils(org.apache.beam.sdk.util.CoderUtils) TimerSpecs(org.apache.beam.sdk.state.TimerSpecs) ValueState(org.apache.beam.sdk.state.ValueState) ClosingBehavior(org.apache.beam.sdk.transforms.windowing.Window.ClosingBehavior) PCollectionList(org.apache.beam.sdk.values.PCollectionList) Window(org.apache.beam.sdk.transforms.windowing.Window) GlobalWindow(org.apache.beam.sdk.transforms.windowing.GlobalWindow) TimestampedValue(org.apache.beam.sdk.values.TimestampedValue) Keys(org.apache.beam.sdk.transforms.Keys) Flatten(org.apache.beam.sdk.transforms.Flatten) MapElements(org.apache.beam.sdk.transforms.MapElements) Matchers.allOf(org.hamcrest.Matchers.allOf) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) Sum(org.apache.beam.sdk.transforms.Sum) VarLongCoder(org.apache.beam.sdk.coders.VarLongCoder) Category(org.junit.experimental.categories.Category) Serializable(java.io.Serializable) DefaultTrigger(org.apache.beam.sdk.transforms.windowing.DefaultTrigger) ParDo(org.apache.beam.sdk.transforms.ParDo) Timer(org.apache.beam.sdk.state.Timer) TypeDescriptors(org.apache.beam.sdk.values.TypeDescriptors) ImmutableList(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList) Matchers.is(org.hamcrest.Matchers.is) GlobalWindows(org.apache.beam.sdk.transforms.windowing.GlobalWindows) AfterPane(org.apache.beam.sdk.transforms.windowing.AfterPane) Values(org.apache.beam.sdk.transforms.Values) KV(org.apache.beam.sdk.values.KV) AfterWatermark(org.apache.beam.sdk.transforms.windowing.AfterWatermark) Combine(org.apache.beam.sdk.transforms.Combine) Duration(org.joda.time.Duration) RunWith(org.junit.runner.RunWith) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) TimerSpec(org.apache.beam.sdk.state.TimerSpec) Never(org.apache.beam.sdk.transforms.windowing.Never) StreamSupport(java.util.stream.StreamSupport) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ExpectedException(org.junit.rules.ExpectedException) DoFn(org.apache.beam.sdk.transforms.DoFn) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) GroupByKey(org.apache.beam.sdk.transforms.GroupByKey) WithKeys(org.apache.beam.sdk.transforms.WithKeys) FixedWindows(org.apache.beam.sdk.transforms.windowing.FixedWindows) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) PCollection(org.apache.beam.sdk.values.PCollection) StateSpecs(org.apache.beam.sdk.state.StateSpecs) Rule(org.junit.Rule) AfterProcessingTime(org.apache.beam.sdk.transforms.windowing.AfterProcessingTime) BoundedWindow(org.apache.beam.sdk.transforms.windowing.BoundedWindow) Instant(org.joda.time.Instant) VarIntCoder(org.apache.beam.sdk.coders.VarIntCoder) IntervalWindow(org.apache.beam.sdk.transforms.windowing.IntervalWindow) TimeDomain(org.apache.beam.sdk.state.TimeDomain) Instant(org.joda.time.Instant) KV(org.apache.beam.sdk.values.KV) IntervalWindow(org.apache.beam.sdk.transforms.windowing.IntervalWindow) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with Count

use of org.apache.beam.sdk.transforms.Count in project beam by apache.

the class CreateStreamTest method testInStreamingModeCountByKey.

@Test
public void testInStreamingModeCountByKey() throws Exception {
    Instant instant = new Instant(0);
    CreateStream<KV<Integer, Long>> kvSource = CreateStream.of(KvCoder.of(VarIntCoder.of(), VarLongCoder.of()), batchDuration()).emptyBatch().advanceWatermarkForNextBatch(instant).nextBatch(TimestampedValue.of(KV.of(1, 100L), instant.plus(Duration.standardSeconds(3L))), TimestampedValue.of(KV.of(1, 300L), instant.plus(Duration.standardSeconds(4L)))).advanceWatermarkForNextBatch(instant.plus(Duration.standardSeconds(7L))).nextBatch(TimestampedValue.of(KV.of(1, 400L), instant.plus(Duration.standardSeconds(8L)))).advanceNextBatchWatermarkToInfinity();
    PCollection<KV<Integer, Long>> output = p.apply("create kv Source", kvSource).apply("window input", Window.<KV<Integer, Long>>into(FixedWindows.of(Duration.standardSeconds(3L))).withAllowedLateness(Duration.ZERO)).apply(Count.perKey());
    PAssert.that("Wrong count value ", output).satisfies((SerializableFunction<Iterable<KV<Integer, Long>>, Void>) input -> {
        for (KV<Integer, Long> element : input) {
            if (element.getKey() == 1) {
                Long countValue = element.getValue();
                assertNotEquals("Count Value is 0 !!!", 0L, countValue.longValue());
            } else {
                fail("Unknown key in the output PCollection");
            }
        }
        return null;
    });
    p.run();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Count(org.apache.beam.sdk.transforms.Count) SerializableFunction(org.apache.beam.sdk.transforms.SerializableFunction) PCollectionList(org.apache.beam.sdk.values.PCollectionList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CreateStream(org.apache.beam.runners.spark.io.CreateStream) Window(org.apache.beam.sdk.transforms.windowing.Window) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) GlobalWindow(org.apache.beam.sdk.transforms.windowing.GlobalWindow) Assert.fail(org.junit.Assert.fail) TimestampedValue(org.apache.beam.sdk.values.TimestampedValue) Flatten(org.apache.beam.sdk.transforms.Flatten) KvCoder(org.apache.beam.sdk.coders.KvCoder) Matchers.allOf(org.hamcrest.Matchers.allOf) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) Sum(org.apache.beam.sdk.transforms.Sum) VarLongCoder(org.apache.beam.sdk.coders.VarLongCoder) Category(org.junit.experimental.categories.Category) Serializable(java.io.Serializable) DefaultTrigger(org.apache.beam.sdk.transforms.windowing.DefaultTrigger) ParDo(org.apache.beam.sdk.transforms.ParDo) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) AfterPane(org.apache.beam.sdk.transforms.windowing.AfterPane) SparkPipelineOptions(org.apache.beam.runners.spark.SparkPipelineOptions) Values(org.apache.beam.sdk.transforms.Values) KV(org.apache.beam.sdk.values.KV) StreamingTest(org.apache.beam.runners.spark.StreamingTest) AfterWatermark(org.apache.beam.sdk.transforms.windowing.AfterWatermark) Combine(org.apache.beam.sdk.transforms.Combine) Duration(org.joda.time.Duration) TupleTagList(org.apache.beam.sdk.values.TupleTagList) ReuseSparkContextRule(org.apache.beam.runners.spark.ReuseSparkContextRule) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) TupleTag(org.apache.beam.sdk.values.TupleTag) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Never(org.apache.beam.sdk.transforms.windowing.Never) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ExpectedException(org.junit.rules.ExpectedException) DoFn(org.apache.beam.sdk.transforms.DoFn) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) GroupByKey(org.apache.beam.sdk.transforms.GroupByKey) WithKeys(org.apache.beam.sdk.transforms.WithKeys) PAssert(org.apache.beam.sdk.testing.PAssert) FixedWindows(org.apache.beam.sdk.transforms.windowing.FixedWindows) IOException(java.io.IOException) Test(org.junit.Test) PCollection(org.apache.beam.sdk.values.PCollection) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Rule(org.junit.Rule) AfterProcessingTime(org.apache.beam.sdk.transforms.windowing.AfterProcessingTime) BoundedWindow(org.apache.beam.sdk.transforms.windowing.BoundedWindow) Instant(org.joda.time.Instant) VarIntCoder(org.apache.beam.sdk.coders.VarIntCoder) IntervalWindow(org.apache.beam.sdk.transforms.windowing.IntervalWindow) Instant(org.joda.time.Instant) KV(org.apache.beam.sdk.values.KV) StreamingTest(org.apache.beam.runners.spark.StreamingTest) Test(org.junit.Test)

Example 3 with Count

use of org.apache.beam.sdk.transforms.Count in project beam by apache.

the class JdbcIOTest method testCustomFluentBackOffConfiguration.

@Test
public void testCustomFluentBackOffConfiguration() throws Exception {
    String tableName = DatabaseTestHelper.getTestTableName("UT_FLUENT_BACKOFF");
    DatabaseTestHelper.createTable(DATA_SOURCE, tableName);
    // lock table
    Connection connection = DATA_SOURCE.getConnection();
    Statement lockStatement = connection.createStatement();
    lockStatement.execute("ALTER TABLE " + tableName + " LOCKSIZE TABLE");
    lockStatement.execute("LOCK TABLE " + tableName + " IN EXCLUSIVE MODE");
    // start a first transaction
    connection.setAutoCommit(false);
    PreparedStatement insertStatement = connection.prepareStatement("insert into " + tableName + " values(?, ?)");
    insertStatement.setInt(1, 1);
    insertStatement.setString(2, "TEST");
    insertStatement.execute();
    pipeline.apply(Create.of(Collections.singletonList(KV.of(1, "TEST")))).apply(JdbcIO.<KV<Integer, String>>write().withDataSourceConfiguration(DATA_SOURCE_CONFIGURATION).withStatement(String.format("insert into %s values(?, ?)", tableName)).withRetryStrategy((JdbcIO.RetryStrategy) e -> {
        return "40XL1".equals(e.getSQLState());
    }).withRetryConfiguration(JdbcIO.RetryConfiguration.create(2, null, Duration.standardSeconds(1))).withPreparedStatementSetter((element, statement) -> {
        statement.setInt(1, element.getKey());
        statement.setString(2, element.getValue());
    }));
    PipelineExecutionException exception = assertThrows(PipelineExecutionException.class, () -> {
        pipeline.run().waitUntilFinish();
    });
    // Finally commit the original connection, now that the pipeline has failed due to deadlock.
    connection.commit();
    assertThat(exception.getMessage(), containsString("java.sql.BatchUpdateException: A lock could not be obtained within the time requested"));
    // Verify that pipeline retried the write twice, but encountered a deadlock every time.
    expectedLogs.verifyLogRecords(new TypeSafeMatcher<Iterable<LogRecord>>() {

        @Override
        public void describeTo(Description description) {
        }

        @Override
        protected boolean matchesSafely(Iterable<LogRecord> logRecords) {
            int count = 0;
            for (LogRecord logRecord : logRecords) {
                if (logRecord.getMessage().contains("Deadlock detected, retrying")) {
                    count += 1;
                }
            }
            // Max retries will be 2 + the original deadlock error.
            return count == 3;
        }
    });
    // Since the pipeline was unable to write, only the row from insertStatement was written.
    assertRowCount(DATA_SOURCE, tableName, 1);
}
Also used : Count(org.apache.beam.sdk.transforms.Count) ExpectedLogs(org.apache.beam.sdk.testing.ExpectedLogs) Arrays(java.util.Arrays) PipelineExecutionException(org.apache.beam.sdk.Pipeline.PipelineExecutionException) SerializableCoder(org.apache.beam.sdk.coders.SerializableCoder) Connection(java.sql.Connection) Time(java.sql.Time) Matchers.not(org.hamcrest.Matchers.not) SerializableFunction(org.apache.beam.sdk.transforms.SerializableFunction) Array(java.sql.Array) PoolableDataSourceProvider(org.apache.beam.sdk.io.jdbc.JdbcIO.PoolableDataSourceProvider) BigDecimal(java.math.BigDecimal) Matchers.closeTo(org.hamcrest.Matchers.closeTo) Create(org.apache.beam.sdk.transforms.Create) Wait(org.apache.beam.sdk.transforms.Wait) PoolingDataSource(org.apache.commons.dbcp2.PoolingDataSource) RoundingMode(java.math.RoundingMode) KvCoder(org.apache.beam.sdk.coders.KvCoder) NULL(java.sql.JDBCType.NULL) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) FieldType(org.apache.beam.sdk.schemas.Schema.FieldType) UUID(java.util.UUID) PreparedStatement(java.sql.PreparedStatement) LogRecord(java.util.logging.LogRecord) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) StandardCharsets(java.nio.charset.StandardCharsets) Serializable(java.io.Serializable) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Matchers.any(org.mockito.Matchers.any) List(java.util.List) PartitioningFn(org.apache.beam.sdk.io.jdbc.JdbcUtil.PartitioningFn) ParDo(org.apache.beam.sdk.transforms.ParDo) SerializableUtils(org.apache.beam.sdk.util.SerializableUtils) Assert.assertFalse(org.junit.Assert.assertFalse) TypeDescriptors(org.apache.beam.sdk.values.TypeDescriptors) ISOChronology(org.joda.time.chrono.ISOChronology) TestStream(org.apache.beam.sdk.testing.TestStream) ImmutableList(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList) DatabaseTestHelper.assertRowCount(org.apache.beam.sdk.io.common.DatabaseTestHelper.assertRowCount) Matchers.containsString(org.hamcrest.Matchers.containsString) Mockito.mock(org.mockito.Mockito.mock) KV(org.apache.beam.sdk.values.KV) TypeDescriptor(org.apache.beam.sdk.values.TypeDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertThrows(org.junit.Assert.assertThrows) Duration(org.joda.time.Duration) RunWith(org.junit.runner.RunWith) NUMERIC(java.sql.JDBCType.NUMERIC) ArrayList(java.util.ArrayList) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) FixedPrecisionNumeric(org.apache.beam.sdk.io.jdbc.LogicalTypes.FixedPrecisionNumeric) Assert.assertSame(org.junit.Assert.assertSame) JDBCType(java.sql.JDBCType) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) Charset(java.nio.charset.Charset) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) DataSource(javax.sql.DataSource) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Row(org.apache.beam.sdk.values.Row) ExpectedException(org.junit.rules.ExpectedException) Select(org.apache.beam.sdk.schemas.transforms.Select) Description(org.hamcrest.Description) PAssert(org.apache.beam.sdk.testing.PAssert) TestRow(org.apache.beam.sdk.io.common.TestRow) DataSourceConfiguration(org.apache.beam.sdk.io.jdbc.JdbcIO.DataSourceConfiguration) DateTime(org.joda.time.DateTime) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) JUnit4(org.junit.runners.JUnit4) PCollection(org.apache.beam.sdk.values.PCollection) Schema(org.apache.beam.sdk.schemas.Schema) Mockito.verify(org.mockito.Mockito.verify) Date(java.sql.Date) LocalDate(org.joda.time.LocalDate) Rule(org.junit.Rule) Instant(org.joda.time.Instant) Statement(java.sql.Statement) VarIntCoder(org.apache.beam.sdk.coders.VarIntCoder) Collections(java.util.Collections) DatabaseTestHelper(org.apache.beam.sdk.io.common.DatabaseTestHelper) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Description(org.hamcrest.Description) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) KV(org.apache.beam.sdk.values.KV) LogRecord(java.util.logging.LogRecord) PipelineExecutionException(org.apache.beam.sdk.Pipeline.PipelineExecutionException) Test(org.junit.Test)

Example 4 with Count

use of org.apache.beam.sdk.transforms.Count in project beam by apache.

the class SnsIOIT method testWriteThenRead.

@Test
public void testWriteThenRead() {
    ITOptions opts = env.options();
    int rows = opts.getNumberOfRows();
    // Write test dataset to SNS
    pipelineWrite.apply("Generate Sequence", GenerateSequence.from(0).to(rows)).apply("Prepare TestRows", ParDo.of(new DeterministicallyConstructTestRowFn())).apply("Write to SNS", SnsIO.<TestRow>write().withTopicArn(resources.snsTopic).withPublishRequestBuilder(r -> PublishRequest.builder().message(r.name())));
    // Read test dataset from SQS.
    PCollection<String> output = pipelineRead.apply("Read from SQS", SqsIO.read().withQueueUrl(resources.sqsQueue).withMaxNumRecords(rows)).apply("Extract message", MapElements.into(strings()).via(SnsIOIT::extractMessage));
    PAssert.thatSingleton(output.apply("Count All", Count.globally())).isEqualTo((long) rows);
    PAssert.that(output.apply(Combine.globally(new HashingFn()).withoutDefaults())).containsInAnyOrder(getExpectedHashForRowCount(rows));
    pipelineWrite.run();
    pipelineRead.run();
}
Also used : Count(org.apache.beam.sdk.transforms.Count) Combine(org.apache.beam.sdk.transforms.Combine) RunWith(org.junit.runner.RunWith) PublishRequest(software.amazon.awssdk.services.sns.model.PublishRequest) IOITHelper.executeWithRetry(org.apache.beam.sdk.io.common.IOITHelper.executeWithRetry) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) TypeDescriptors.strings(org.apache.beam.sdk.values.TypeDescriptors.strings) Timeout(org.junit.rules.Timeout) TestRow.getExpectedHashForRowCount(org.apache.beam.sdk.io.common.TestRow.getExpectedHashForRowCount) ClassRule(org.junit.ClassRule) SqsIO(org.apache.beam.sdk.io.aws2.sqs.SqsIO) Service(org.testcontainers.containers.localstack.LocalStackContainer.Service) MapElements(org.apache.beam.sdk.transforms.MapElements) SNS(org.testcontainers.containers.localstack.LocalStackContainer.Service.SNS) HashingFn(org.apache.beam.sdk.io.common.HashingFn) DeterministicallyConstructTestRowFn(org.apache.beam.sdk.io.common.TestRow.DeterministicallyConstructTestRowFn) PAssert(org.apache.beam.sdk.testing.PAssert) TestRow(org.apache.beam.sdk.io.common.TestRow) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ITEnvironment(org.apache.beam.sdk.io.aws2.ITEnvironment) SqsClient(software.amazon.awssdk.services.sqs.SqsClient) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) GenerateSequence(org.apache.beam.sdk.io.GenerateSequence) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) PCollection(org.apache.beam.sdk.values.PCollection) Serializable(java.io.Serializable) Rule(org.junit.Rule) ExternalResource(org.junit.rules.ExternalResource) ParDo(org.apache.beam.sdk.transforms.ParDo) SnsClient(software.amazon.awssdk.services.sns.SnsClient) SqsMessage(org.apache.beam.sdk.io.aws2.sqs.SqsMessage) SQS(org.testcontainers.containers.localstack.LocalStackContainer.Service.SQS) DeterministicallyConstructTestRowFn(org.apache.beam.sdk.io.common.TestRow.DeterministicallyConstructTestRowFn) HashingFn(org.apache.beam.sdk.io.common.HashingFn) Test(org.junit.Test)

Example 5 with Count

use of org.apache.beam.sdk.transforms.Count in project beam by apache.

the class DynamoDBIOIT method runRead.

/**
 * Read test dataset from DynamoDB.
 */
private void runRead() {
    int rows = env.options().getNumberOfRows();
    PCollection<Map<String, AttributeValue>> records = pipelineRead.apply("Read from DynamoDB", DynamoDBIO.read().withScanRequestFn(in -> buildScanRequest()).items()).apply("Flatten result", Flatten.iterables());
    PAssert.thatSingleton(records.apply("Count All", Count.globally())).isEqualTo((long) rows);
    PCollection<String> consolidatedHashcode = records.apply(MapElements.into(strings()).via(record -> record.get(COL_NAME).s())).apply("Hash records", Combine.globally(new HashingFn()).withoutDefaults());
    PAssert.that(consolidatedHashcode).containsInAnyOrder(getExpectedHashForRowCount(rows));
    pipelineRead.run().waitUntilFinish();
}
Also used : Count(org.apache.beam.sdk.transforms.Count) KV(org.apache.beam.sdk.values.KV) Default(org.apache.beam.sdk.options.Default) Combine(org.apache.beam.sdk.transforms.Combine) RunWith(org.junit.runner.RunWith) ImmutableMap(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap) Description(org.apache.beam.sdk.options.Description) ProvisionedThroughput(software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput) Map(java.util.Map) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) CreateTableRequest(software.amazon.awssdk.services.dynamodb.model.CreateTableRequest) ScanRequest(software.amazon.awssdk.services.dynamodb.model.ScanRequest) TypeDescriptors.strings(org.apache.beam.sdk.values.TypeDescriptors.strings) WriteRequest(software.amazon.awssdk.services.dynamodb.model.WriteRequest) TestRow.getExpectedHashForRowCount(org.apache.beam.sdk.io.common.TestRow.getExpectedHashForRowCount) PutRequest(software.amazon.awssdk.services.dynamodb.model.PutRequest) ClassRule(org.junit.ClassRule) ScalarAttributeType(software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType) Flatten(org.apache.beam.sdk.transforms.Flatten) MapElements(org.apache.beam.sdk.transforms.MapElements) DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) HashingFn(org.apache.beam.sdk.io.common.HashingFn) DeterministicallyConstructTestRowFn(org.apache.beam.sdk.io.common.TestRow.DeterministicallyConstructTestRowFn) TableStatus(software.amazon.awssdk.services.dynamodb.model.TableStatus) PAssert(org.apache.beam.sdk.testing.PAssert) TestRow(org.apache.beam.sdk.io.common.TestRow) KeyType(software.amazon.awssdk.services.dynamodb.model.KeyType) ITEnvironment(org.apache.beam.sdk.io.aws2.ITEnvironment) GenerateSequence(org.apache.beam.sdk.io.GenerateSequence) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) AttributeDefinition(software.amazon.awssdk.services.dynamodb.model.AttributeDefinition) PCollection(org.apache.beam.sdk.values.PCollection) Rule(org.junit.Rule) ExternalResource(org.junit.rules.ExternalResource) KeySchemaElement(software.amazon.awssdk.services.dynamodb.model.KeySchemaElement) ParDo(org.apache.beam.sdk.transforms.ParDo) AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) DYNAMODB(org.testcontainers.containers.localstack.LocalStackContainer.Service.DYNAMODB) ImmutableMap(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap) Map(java.util.Map) HashingFn(org.apache.beam.sdk.io.common.HashingFn)

Aggregations

Count (org.apache.beam.sdk.transforms.Count)7 PCollection (org.apache.beam.sdk.values.PCollection)7 Rule (org.junit.Rule)7 Test (org.junit.Test)7 ParDo (org.apache.beam.sdk.transforms.ParDo)6 KV (org.apache.beam.sdk.values.KV)6 PAssert (org.apache.beam.sdk.testing.PAssert)5 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)5 Combine (org.apache.beam.sdk.transforms.Combine)5 RunWith (org.junit.runner.RunWith)5 JUnit4 (org.junit.runners.JUnit4)5 Serializable (java.io.Serializable)4 StringUtf8Coder (org.apache.beam.sdk.coders.StringUtf8Coder)4 VarIntCoder (org.apache.beam.sdk.coders.VarIntCoder)4 TestRow (org.apache.beam.sdk.io.common.TestRow)4 Flatten (org.apache.beam.sdk.transforms.Flatten)4 Duration (org.joda.time.Duration)4 Instant (org.joda.time.Instant)4 ClassRule (org.junit.ClassRule)4 GenerateSequence (org.apache.beam.sdk.io.GenerateSequence)3