use of org.apache.samza.table.ReadWriteUpdateTable in project samza by apache.
the class TestLocalTableWrite method testDeleteAll.
@Test
public void testDeleteAll() throws Exception {
ReadWriteUpdateTable table = createTable(false);
table.deleteAll(Collections.emptyList());
table.deleteAllAsync(Collections.emptyList()).get();
verify(kvStore, times(2)).deleteAll(any());
Assert.assertEquals(2, numDeleteAlls.getCount());
Assert.assertTrue(deleteAllNs.getSnapshot().getAverage() > 0);
Assert.assertEquals(0, putNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, putAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, flushNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, numPuts.getCount());
Assert.assertEquals(0, numPutAlls.getCount());
Assert.assertEquals(0, numDeletes.getCount());
Assert.assertEquals(0, numFlushes.getCount());
Assert.assertEquals(0, putCallbackNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteCallbackNs.getSnapshot().getAverage(), 0.001);
}
use of org.apache.samza.table.ReadWriteUpdateTable in project samza by apache.
the class TestLocalTableWrite method testPut.
@Test
public void testPut() throws Exception {
ReadWriteUpdateTable table = createTable(false);
table.put("k1", "v1");
table.putAsync("k2", "v2").get();
table.putAsync("k3", null).get();
verify(kvStore, times(2)).put(any(), any());
verify(kvStore, times(1)).delete(any());
Assert.assertEquals(2, numPuts.getCount());
Assert.assertEquals(1, numDeletes.getCount());
Assert.assertTrue(putNs.getSnapshot().getAverage() > 0);
Assert.assertTrue(deleteNs.getSnapshot().getAverage() > 0);
Assert.assertEquals(0, putAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, flushNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, numPutAlls.getCount());
Assert.assertEquals(0, numDeleteAlls.getCount());
Assert.assertEquals(0, numFlushes.getCount());
Assert.assertEquals(0, putCallbackNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteCallbackNs.getSnapshot().getAverage(), 0.001);
}
use of org.apache.samza.table.ReadWriteUpdateTable in project samza by apache.
the class TestLocalTableWrite method testDelete.
@Test
public void testDelete() throws Exception {
ReadWriteUpdateTable table = createTable(false);
table.delete("");
table.deleteAsync("").get();
verify(kvStore, times(2)).delete(any());
Assert.assertEquals(2, numDeletes.getCount());
Assert.assertTrue(deleteNs.getSnapshot().getAverage() > 0);
Assert.assertEquals(0, putNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, putAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, flushNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, numPuts.getCount());
Assert.assertEquals(0, numPutAlls.getCount());
Assert.assertEquals(0, numDeleteAlls.getCount());
Assert.assertEquals(0, numFlushes.getCount());
Assert.assertEquals(0, putCallbackNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, deleteCallbackNs.getSnapshot().getAverage(), 0.001);
}
use of org.apache.samza.table.ReadWriteUpdateTable in project samza by apache.
the class TestLocalTableRead method testGet.
@Test
public void testGet() throws Exception {
ReadWriteUpdateTable table = createTable(false);
Assert.assertEquals("v1", table.get("k1"));
Assert.assertEquals("v2", table.getAsync("k2").get());
Assert.assertNull(table.get("k3"));
verify(kvStore, times(3)).get(any());
Assert.assertEquals(3, numGets.getCount());
Assert.assertEquals(1, numMissedLookups.getCount());
Assert.assertTrue(getNs.getSnapshot().getAverage() > 0);
Assert.assertEquals(0, numGetAlls.getCount());
Assert.assertEquals(0, getAllNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, getCallbackNs.getSnapshot().getAverage(), 0.001);
}
use of org.apache.samza.table.ReadWriteUpdateTable in project samza by apache.
the class TestLocalTableRead method testGetAll.
@Test
public void testGetAll() throws Exception {
ReadWriteUpdateTable table = createTable(false);
Assert.assertEquals(values, table.getAll(keys));
Assert.assertEquals(values, table.getAllAsync(keys).get());
verify(kvStore, times(2)).getAll(any());
Assert.assertEquals(Collections.emptyMap(), table.getAll(Collections.emptyList()));
Assert.assertEquals(2, numMissedLookups.getCount());
Assert.assertEquals(3, numGetAlls.getCount());
Assert.assertTrue(getAllNs.getSnapshot().getAverage() > 0);
Assert.assertEquals(0, numGets.getCount());
Assert.assertEquals(0, getNs.getSnapshot().getAverage(), 0.001);
Assert.assertEquals(0, getCallbackNs.getSnapshot().getAverage(), 0.001);
}
Aggregations