Esempio n. 1
0
  /** testNullPartitionId */
  public void testNullPartitionId() {
    assertFalse(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID));
    pset.add(HStoreConstants.NULL_PARTITION_ID);
    assertTrue(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID));
    for (Integer p : pset) {
      assertEquals(HStoreConstants.NULL_PARTITION_ID, p.intValue());
    }

    int num_elements = rand.nextInt(NUM_PARTITIONS);
    for (int i = 0; i < num_elements; i++) {
      int p = rand.nextInt(NUM_PARTITIONS);
      pset.add(p);
    } // FOR
    assertTrue(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID));
    boolean found_null = false;
    for (Integer p : pset) {
      // System.err.println(p);
      if (p.intValue() == HStoreConstants.NULL_PARTITION_ID) {
        found_null = true;
      } else {
        assertNotSame(HStoreConstants.NULL_PARTITION_ID, p.intValue());
      }
    }
    assertTrue(pset.toString(), found_null);

    pset.remove(HStoreConstants.NULL_PARTITION_ID);
    assertFalse(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID));
  }
Esempio n. 2
0
  /** testToString */
  public void testToString() {
    for (int p = 0; p < NUM_PARTITIONS; p++) {
      assertFalse(pset.toString(), pset.contains(p));
      pset.add(p);
      String s = pset.toString();
      assertTrue(p + "->" + s, s.contains(Integer.toString(p)));
    } // FOR

    int p = HStoreConstants.NULL_PARTITION_ID;
    pset.add(p);
    String s = pset.toString();
    assertTrue(p + "->" + s, s.contains(Integer.toString(p)));
    System.err.println(s);
  }
Esempio n. 3
0
  /** testIsEmptyNull */
  public void testIsEmptyNull() {
    assertTrue(pset.toString(), pset.isEmpty());
    assertTrue(set.toString(), set.isEmpty());

    pset.add(HStoreConstants.NULL_PARTITION_ID);
    set.add(HStoreConstants.NULL_PARTITION_ID);
    assertFalse(pset.toString(), pset.isEmpty());
    assertTrue(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID));
    assertFalse(set.toString(), set.isEmpty());
    assertTrue(set.toString(), set.contains(HStoreConstants.NULL_PARTITION_ID));
    assertEquals(set.size(), pset.size());

    pset.clear();
    set.clear();
    assertTrue(pset.toString(), pset.isEmpty());
    assertTrue(set.toString(), set.isEmpty());
    assertEquals(set.size(), pset.size());
  }
Esempio n. 4
0
  /** testIsEmpty */
  public void testIsEmpty() {
    assertTrue(pset.toString(), pset.isEmpty());
    assertTrue(set.toString(), set.isEmpty());

    for (int p = 0; p < NUM_PARTITIONS; p++) {
      assertFalse(pset.toString(), pset.contains(p));
      assertFalse(set.toString(), set.contains(p));

      pset.add(p);
      set.add(p);
      assertFalse(pset.toString(), pset.isEmpty());
      assertTrue(pset.toString(), pset.contains(p));
      assertFalse(set.toString(), set.isEmpty());
      assertTrue(set.toString(), set.contains(p));
      assertEquals(set.size(), pset.size());
    } // FOR

    pset.clear();
    set.clear();
    assertTrue(pset.toString(), pset.isEmpty());
    assertTrue(set.toString(), set.isEmpty());
    assertEquals(set.size(), pset.size());
  }
Esempio n. 5
0
  /** testIterator */
  public void testIterator() {
    assertTrue(pset.isEmpty());
    int num_elements = rand.nextInt(NUM_PARTITIONS * 3);
    for (int i = 0; i < num_elements; i++) {
      int p = rand.nextInt(NUM_PARTITIONS);
      pset.add(p);
      set.add(p);
    } // FOR
    assertFalse(pset.isEmpty());
    assertEquals(set.size(), pset.size());

    int cnt = 0;
    for (Integer p : pset) {
      //            System.err.println(cnt + " - " + p);
      assertNotNull(pset.toString(), p);
      assertTrue(p.toString(), set.contains(p));
      cnt++;
    }
    assertEquals(set.size(), cnt);
  }