Search in sources :

Example 1 with SnapshotSortQueue

use of com.alibaba.graphscope.groot.store.SnapshotSortQueue in project GraphScope by alibaba.

the class SnapshotSortQueueTest method testQueue.

@Test
void testQueue() throws InterruptedException {
    Configs configs = Configs.newBuilder().build();
    MetaService mockMetaService = mock(MetaService.class);
    when(mockMetaService.getQueueCount()).thenReturn(2);
    SnapshotSortQueue snapshotSortQueue = new SnapshotSortQueue(configs, mockMetaService);
    /**
     * Q1: 4, 5, 7, 7 Q0: 4, 5, 6, 7
     *
     * <p>(Q1, 4) (Q0, 4) (Q1, 5) (Q0, 5) (Q0, 6) (Q1, 7) (Q1, 7) (Q0, 7)
     */
    snapshotSortQueue.offerQueue(1, StoreDataBatch.newBuilder().snapshotId(4L).queueId(1).build());
    snapshotSortQueue.offerQueue(1, StoreDataBatch.newBuilder().snapshotId(5L).queueId(1).build());
    snapshotSortQueue.offerQueue(1, StoreDataBatch.newBuilder().snapshotId(7L).queueId(1).build());
    snapshotSortQueue.offerQueue(1, StoreDataBatch.newBuilder().snapshotId(7L).queueId(1).build());
    // For end snapshot 7
    snapshotSortQueue.offerQueue(1, StoreDataBatch.newBuilder().snapshotId(100L).queueId(1).build());
    snapshotSortQueue.offerQueue(0, StoreDataBatch.newBuilder().snapshotId(4L).queueId(0).build());
    snapshotSortQueue.offerQueue(0, StoreDataBatch.newBuilder().snapshotId(5L).queueId(0).build());
    snapshotSortQueue.offerQueue(0, StoreDataBatch.newBuilder().snapshotId(6L).queueId(0).build());
    snapshotSortQueue.offerQueue(0, StoreDataBatch.newBuilder().snapshotId(7L).queueId(0).build());
    StoreDataBatch entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 1);
    assertEquals(entry.getSnapshotId(), 4L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 0);
    assertEquals(entry.getSnapshotId(), 4L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 1);
    assertEquals(entry.getSnapshotId(), 5L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 0);
    assertEquals(entry.getSnapshotId(), 5L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 0);
    assertEquals(entry.getSnapshotId(), 6L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 1);
    assertEquals(entry.getSnapshotId(), 7L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 1);
    assertEquals(entry.getSnapshotId(), 7L);
    entry = snapshotSortQueue.poll();
    assertEquals(entry.getQueueId(), 0);
    assertEquals(entry.getSnapshotId(), 7L);
}
Also used : MetaService(com.alibaba.graphscope.groot.meta.MetaService) SnapshotSortQueue(com.alibaba.graphscope.groot.store.SnapshotSortQueue) Configs(com.alibaba.maxgraph.common.config.Configs) StoreDataBatch(com.alibaba.graphscope.groot.operation.StoreDataBatch) Test(org.junit.jupiter.api.Test)

Aggregations

MetaService (com.alibaba.graphscope.groot.meta.MetaService)1 StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)1 SnapshotSortQueue (com.alibaba.graphscope.groot.store.SnapshotSortQueue)1 Configs (com.alibaba.maxgraph.common.config.Configs)1 Test (org.junit.jupiter.api.Test)1