Search in sources :

Example 1 with TableImpl

use of org.apache.samza.operators.TableImpl in project samza by apache.

the class StreamApplicationDescriptorImpl method getTable.

@Override
public <K, V> Table<KV<K, V>> getTable(TableDescriptor<K, V, ?> tableDescriptor) {
    addTableDescriptor(tableDescriptor);
    if (tableDescriptor instanceof LocalTableDescriptor) {
        LocalTableDescriptor localTableDescriptor = (LocalTableDescriptor) tableDescriptor;
        getOrCreateTableSerdes(localTableDescriptor.getTableId(), localTableDescriptor.getSerde());
    }
    return new TableImpl(tableDescriptor);
}
Also used : LocalTableDescriptor(org.apache.samza.table.descriptors.LocalTableDescriptor) TableImpl(org.apache.samza.operators.TableImpl)

Example 2 with TableImpl

use of org.apache.samza.operators.TableImpl in project samza by apache.

the class TestStreamApplicationDescriptorImpl method testGetTable.

@Test
public void testGetTable() throws Exception {
    Config mockConfig = getConfig();
    String tableId = "t1";
    BaseTableDescriptor mockTableDescriptor = mock(BaseTableDescriptor.class);
    when(mockTableDescriptor.getTableId()).thenReturn(tableId);
    AtomicReference<TableImpl> table = new AtomicReference<>();
    StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
        table.set((TableImpl) appDesc.getTable(mockTableDescriptor));
    }, mockConfig);
    assertEquals(tableId, table.get().getTableId());
}
Also used : ApplicationConfig(org.apache.samza.config.ApplicationConfig) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) TableImpl(org.apache.samza.operators.TableImpl) AtomicReference(java.util.concurrent.atomic.AtomicReference) BaseTableDescriptor(org.apache.samza.table.descriptors.BaseTableDescriptor) Test(org.junit.Test)

Aggregations

TableImpl (org.apache.samza.operators.TableImpl)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ApplicationConfig (org.apache.samza.config.ApplicationConfig)1 Config (org.apache.samza.config.Config)1 MapConfig (org.apache.samza.config.MapConfig)1 BaseTableDescriptor (org.apache.samza.table.descriptors.BaseTableDescriptor)1 LocalTableDescriptor (org.apache.samza.table.descriptors.LocalTableDescriptor)1 Test (org.junit.Test)1