Search in sources :

Example 96 with NavigableSet

use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.

the class EmptyNavigableSet method testHeadSet.

/**
     * Tests the headSet() method.
     */
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testHeadSet(String description, NavigableSet navigableSet) {
    assertThrows(() -> {
        NavigableSet ns = navigableSet.headSet(null, false);
    }, NullPointerException.class, description + ": Must throw NullPointerException for null element");
    assertThrows(() -> {
        NavigableSet ns = navigableSet.headSet(new Object(), true);
    }, ClassCastException.class, description + ": Must throw ClassCastException for non-Comparable element");
    NavigableSet ns = navigableSet.headSet("1", false);
    assertEmptyNavigableSet(ns, description + ": Returned value is not empty navigable set.");
}
Also used : NavigableSet(java.util.NavigableSet) Test(org.testng.annotations.Test)

Example 97 with NavigableSet

use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.

the class EmptyNavigableSet method testTailSetRanges.

@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testTailSetRanges(String description, NavigableSet navigableSet) {
    NavigableSet subSet = navigableSet.tailSet(BigInteger.ONE, true);
    // same subset
    subSet.tailSet(BigInteger.ONE, true);
    // slightly smaller
    NavigableSet ns = subSet.tailSet(BigInteger.ONE, false);
    // slight exapansion
    assertThrows(() -> {
        ns.tailSet(BigInteger.ONE, true);
    }, IllegalArgumentException.class, description + ": Expansion should not be allowed");
    // much smaller
    subSet.tailSet(isDescending(subSet) ? BigInteger.ZERO : BigInteger.TEN, false);
}
Also used : NavigableSet(java.util.NavigableSet) Test(org.testng.annotations.Test)

Example 98 with NavigableSet

use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.

the class EmptyNavigableSet method testheadSetRanges.

@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testheadSetRanges(String description, NavigableSet navigableSet) {
    NavigableSet subSet = navigableSet.headSet(BigInteger.ONE, true);
    // same subset
    subSet.headSet(BigInteger.ONE, true);
    // slightly smaller
    NavigableSet ns = subSet.headSet(BigInteger.ONE, false);
    // slight exapansion
    assertThrows(() -> {
        ns.headSet(BigInteger.ONE, true);
    }, IllegalArgumentException.class, description + ": Expansion should not be allowed");
    // much smaller
    subSet.headSet(isDescending(subSet) ? BigInteger.TEN : BigInteger.ZERO, true);
}
Also used : NavigableSet(java.util.NavigableSet) Test(org.testng.annotations.Test)

Example 99 with NavigableSet

use of java.util.NavigableSet in project voltdb by VoltDB.

the class PrepareShutdown method executePlanFragment.

@Override
public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, SystemProcedureExecutionContext context) {
    if (fragmentId == PF_prepareShutdown) {
        super.run(context);
        VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
        if (context.isLowestSiteId()) {
            VoltDB.instance().setShuttingdown(true);
            t.addRow(m_stat.getMzxid());
            if (LOG.isDebugEnabled()) {
                LOG.debug("@PrepareShutdown returning sigil " + ll(m_stat.getMzxid()));
            }
        }
        return new DependencyPair.TableDependencyPair(DEP_prepareShutdown, t);
    } else if (fragmentId == PF_prepareShutdownAggregate) {
        NavigableSet<Long> uniqueTxnIds = new TreeSet<>();
        for (VoltTable t : dependencies.get(DEP_prepareShutdown)) {
            while (t.advanceRow()) {
                uniqueTxnIds.add(t.getLong(0));
            }
        }
        VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
        for (long zktxnid : uniqueTxnIds) {
            t.addRow(zktxnid);
        }
        return new DependencyPair.TableDependencyPair(DEP_prepareShutdonwAggregate, t);
    } else {
        VoltDB.crashLocalVoltDB("Received unrecognized plan fragment id " + fragmentId + " in PrepareShutdown", false, null);
    }
    throw new RuntimeException("Should not reach this code");
}
Also used : NavigableSet(java.util.NavigableSet) VoltTable(org.voltdb.VoltTable) DependencyPair(org.voltdb.DependencyPair)

Example 100 with NavigableSet

use of java.util.NavigableSet in project voltdb by VoltDB.

the class TestCOWSortedMap method testKeySetDescendingIteratorOrder.

/**
     * descending iterator of key set is inverse ordered
     */
public void testKeySetDescendingIteratorOrder() {
    COWSortedMap map = map5();
    NavigableSet s = map.navigableKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer) i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer) i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator)

Aggregations

NavigableSet (java.util.NavigableSet)195 Iterator (java.util.Iterator)36 SortedSet (java.util.SortedSet)25 Map (java.util.Map)11 TreeSet (java.util.TreeSet)9 HashMap (java.util.HashMap)7 TimeRange (org.apache.hadoop.hbase.io.TimeRange)6 Set (java.util.Set)5 TestSuite (junit.framework.TestSuite)5 Scan (org.apache.hadoop.hbase.client.Scan)5 Test (org.testng.annotations.Test)5 List (java.util.List)4 TreeMap (java.util.TreeMap)4 ByteString (com.google.protobuf.ByteString)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Get (org.apache.hadoop.hbase.client.Get)3 GwtIncompatible (com.google.common.annotations.GwtIncompatible)2 SampleElements (com.google.common.collect.testing.SampleElements)2 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)2