Пример #1
0
  /** goal get shard range 10,14, 15,19, 20,22 */
  @Test
  public void testGetRange7() {
    int offset = 10;
    int limit = 5;
    Long finish = 21l;
    long total = 23;
    Sharding d = new Sharding();
    d.setLimit(offset, limit, finish);
    d.setCounts(total);
    int shards = d.getShards();
    assertEquals(3, shards);

    long[] l3 = {9l, 13l};
    long[] r3 = d.getRange(0);
    assertEquals(l3[0], r3[0]);
    assertEquals(l3[1], r3[1]);

    long[] l4 = {14l, 18l};
    long[] r4 = d.getRange(1);
    assertEquals(l4[0], r4[0]);
    assertEquals(l4[1], r4[1]);

    long[] l5 = {19, 20l};
    long[] r5 = d.getRange(2);
    assertEquals(l5[0], r5[0]);
    assertEquals(l5[1], r5[1]);
  }
Пример #2
0
  /** goal get shard range 10,14, 15,19, 20,22 */
  @Test
  public void testGetRange3() {
    int offset = 11;
    int limit = 5;
    Long finish = null;
    long total = 23;
    Sharding d = new Sharding();
    d.setLimit(offset, limit, finish);
    d.setCounts(total);
    int shards = d.getShards();

    assertEquals(3, shards);

    long[] l3 = {10l, 14l};
    long[] r3 = d.getRange(0);
    assertEquals(l3[0], r3[0]);
    assertEquals(l3[1], r3[1]);

    long[] l4 = {15l, 19l};
    long[] r4 = d.getRange(1);
    assertEquals(l4[0], r4[0]);
    assertEquals(l4[1], r4[1]);

    long[] l5 = {20l, 22l};
    long[] r5 = d.getRange(2);
    assertEquals(l5[0], r5[0]);
    assertEquals(l5[1], r5[1]);
  }
Пример #3
0
 /** goal get shard range 2,3 */
 @Test
 public void testGetRange6() {
   int offset = 3;
   int limit = 5;
   Long finish = null;
   long total = 4;
   Sharding d = new Sharding();
   d.setLimit(offset, limit, finish);
   d.setCounts(total);
   int shards = d.getShards();
   assertEquals(1, shards);
   long[] l3 = {2l, 3l};
   long[] r3 = d.getRange(0);
   assertEquals(l3[0], r3[0]);
   assertEquals(l3[1], r3[1]);
 }