Search in sources :

Example 31 with NavigableMap

use of java.util.NavigableMap in project mapdb by jankotek.

the class TreeSubMapTest method testDescendingTailMapContents.

/**
     * headMap returns map with keys in requested range
     */
public void testDescendingTailMapContents() {
    NavigableMap map = dmap5();
    SortedMap sm = map.tailMap(m2);
    assertFalse(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertTrue(sm.containsKey(m4));
    assertTrue(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(m2, k);
    k = (Integer) (i.next());
    assertEquals(m3, k);
    k = (Integer) (i.next());
    assertEquals(m4, k);
    k = (Integer) (i.next());
    assertEquals(m5, k);
    assertFalse(i.hasNext());
    Iterator ei = sm.entrySet().iterator();
    Map.Entry e;
    e = (Map.Entry) (ei.next());
    assertEquals(m2, e.getKey());
    assertEquals("B", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(m3, e.getKey());
    assertEquals("C", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(m4, e.getKey());
    assertEquals("D", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(m5, e.getKey());
    assertEquals("E", e.getValue());
    assertFalse(i.hasNext());
    SortedMap ssm = sm.tailMap(m4);
    assertEquals(m4, ssm.firstKey());
    assertEquals(m5, ssm.lastKey());
    assertEquals("D", ssm.remove(m4));
    assertEquals(1, ssm.size());
    assertEquals(3, sm.size());
    assertEquals(4, map.size());
}
Also used : NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Example 32 with NavigableMap

use of java.util.NavigableMap in project mapdb by jankotek.

the class TreeSubMapTest method testSubMapContents.

/**
     * subMap returns map with keys in requested range
     */
public void testSubMapContents() {
    NavigableMap map = map5();
    SortedMap sm = map.subMap(two, four);
    assertEquals(two, sm.firstKey());
    assertEquals(three, sm.lastKey());
    assertEquals(2, sm.size());
    assertFalse(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertTrue(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(two, k);
    k = (Integer) (i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(two));
    assertEquals(4, map.size());
    assertEquals(1, sm.size());
    assertEquals(three, sm.firstKey());
    assertEquals(three, sm.lastKey());
    assertEquals("C", sm.remove(three));
    assertTrue(sm.isEmpty());
    assertEquals(3, map.size());
}
Also used : NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) Iterator(java.util.Iterator)

Example 33 with NavigableMap

use of java.util.NavigableMap in project mapdb by jankotek.

the class TreeSubMapTest method testLowerEntry.

/**
     * lowerEntry returns preceding entry.
     */
public void testLowerEntry() {
    NavigableMap map = map5();
    Map.Entry e1 = map.lowerEntry(three);
    assertEquals(two, e1.getKey());
    Map.Entry e2 = map.lowerEntry(six);
    assertEquals(five, e2.getKey());
    Map.Entry e3 = map.lowerEntry(one);
    assertNull(e3);
    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
Also used : NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Example 34 with NavigableMap

use of java.util.NavigableMap in project mapdb by jankotek.

the class TreeSubMapTest method testDescendingHeadMapContents.

/**
     * headMap returns map with keys in requested range
     */
public void testDescendingHeadMapContents() {
    NavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(m1, k);
    k = (Integer) (i.next());
    assertEquals(m2, k);
    k = (Integer) (i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}
Also used : NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) Iterator(java.util.Iterator)

Example 35 with NavigableMap

use of java.util.NavigableMap in project mapdb by jankotek.

the class TreeSubMapTest method testDescendingCeilingEntry.

/**
     * ceilingEntry returns next entry.
     */
public void testDescendingCeilingEntry() {
    NavigableMap map = dmap5();
    Map.Entry e1 = map.ceilingEntry(m3);
    assertEquals(m3, e1.getKey());
    Map.Entry e2 = map.ceilingEntry(zero);
    assertEquals(m1, e2.getKey());
    Map.Entry e3 = map.ceilingEntry(m5);
    assertEquals(m5, e3.getKey());
    Map.Entry e4 = map.ceilingEntry(m6);
    assertNull(e4);
}
Also used : NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Aggregations

NavigableMap (java.util.NavigableMap)173 Map (java.util.Map)85 TreeMap (java.util.TreeMap)62 SortedMap (java.util.SortedMap)35 ArrayList (java.util.ArrayList)34 List (java.util.List)27 HashMap (java.util.HashMap)21 Iterator (java.util.Iterator)21 Cell (org.apache.hadoop.hbase.Cell)20 Result (org.apache.hadoop.hbase.client.Result)19 Set (java.util.Set)14 Get (org.apache.hadoop.hbase.client.Get)14 IOException (java.io.IOException)12 KeyValue (org.apache.hadoop.hbase.KeyValue)11 Test (org.junit.Test)11 Put (org.apache.hadoop.hbase.client.Put)10 Entry (java.util.Map.Entry)9 Update (co.cask.cdap.data2.dataset2.lib.table.Update)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 TestSuite (junit.framework.TestSuite)7