CubeOTTest.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:datakernel 作者:
@Test
public void test() throws OTTransformException {
    LogFile logFile = new LogFile("file", 1);
    List<String> fields = asList("field1", "field2");
    LogDiff<CubeDiff> changesLeft = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 0, 10)),
            cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 20), 15)));

    LogDiff<CubeDiff> changesRight = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 0, 20)),
            cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 25), 30)));
    TransformResult<LogDiff<CubeDiff>> transform = logSystem.transform(changesLeft, changesRight);

    assertTrue(transform.hasConflict());
    assertEquals(ConflictResolution.RIGHT, transform.resolution);
    assertThat(transform.right, IsEmptyCollection.empty());

    LogDiff<CubeDiff> result = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 10, 20)),
            cubeDiff("key", addedChunks(changesRight.diffs), addedChunks(changesLeft.diffs)));

    assertEquals(1, transform.left.size());
    assertEquals(result, transform.left.get(0));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号