Java Code Examples for java.util.NavigableSet#ceiling()

The following examples show how to use java.util.NavigableSet#ceiling() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionWindowAssigner.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeWindows(TimeWindow newWindow, NavigableSet<TimeWindow> sortedWindows, MergeCallback<TimeWindow> callback) {
	TimeWindow ceiling = sortedWindows.ceiling(newWindow);
	TimeWindow floor = sortedWindows.floor(newWindow);

	Collection<TimeWindow> mergedWindows = new HashSet<>();
	TimeWindow mergeResult = newWindow;
	if (ceiling != null) {
		mergeResult = mergeWindow(mergeResult, ceiling, mergedWindows);
	}
	if (floor != null) {
		mergeResult = mergeWindow(mergeResult, floor, mergedWindows);
	}
	if (!mergedWindows.isEmpty()) {
		// merge happens, add newWindow into the collection as well.
		mergedWindows.add(newWindow);
		callback.merge(mergeResult, mergedWindows);
	}
}
 
Example 2
Source File: FilesystemValueChecker.java    From bazel with Apache License 2.0 6 votes vote down vote up
private static boolean shouldCheckTreeArtifact(
    @Nullable NavigableSet<PathFragment> knownModifiedOutputFiles, Artifact treeArtifact) {
  // If null, everything needs to be checked.
  if (knownModifiedOutputFiles == null) {
    return true;
  }

  // Here we do the following to see whether a TreeArtifact is modified:
  // 1. Sort the set of modified file paths in lexicographical order using TreeSet.
  // 2. Get the first modified output file path that is greater than or equal to the exec path of
  //    the TreeArtifact to check.
  // 3. Check whether the returned file path contains the exec path of the TreeArtifact as a
  //    prefix path.
  PathFragment artifactExecPath = treeArtifact.getExecPath();
  PathFragment headPath = knownModifiedOutputFiles.ceiling(artifactExecPath);

  return headPath != null && headPath.startsWith(artifactExecPath);
}
 
Example 3
Source File: SessionWindowAssigner.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeWindows(TimeWindow newWindow, NavigableSet<TimeWindow> sortedWindows, MergeCallback<TimeWindow> callback) {
	TimeWindow ceiling = sortedWindows.ceiling(newWindow);
	TimeWindow floor = sortedWindows.floor(newWindow);

	Collection<TimeWindow> mergedWindows = new HashSet<>();
	TimeWindow mergeResult = newWindow;
	if (ceiling != null) {
		mergeResult = mergeWindow(mergeResult, ceiling, mergedWindows);
	}
	if (floor != null) {
		mergeResult = mergeWindow(mergeResult, floor, mergedWindows);
	}
	if (!mergedWindows.isEmpty()) {
		// merge happens, add newWindow into the collection as well.
		mergedWindows.add(newWindow);
		callback.merge(mergeResult, mergedWindows);
	}
}
 
Example 4
Source File: TreeSubSetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 5
Source File: ConcurrentSkipListSubSetTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 6
Source File: ConcurrentSkipListSubSetTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 7
Source File: TreeSubSetTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 8
Source File: TreeSubSetTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 9
Source File: StringUtils.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Expand a name if it is an unambiguous prefix of an entry in the given set of names
 * @param names the reference set of names
 * @param prefix the name prefix
 * @return the input name, or an unambiguous expansion of it
 */
public static String expandPrefix(NavigableSet<String> names, String prefix) {
  String name = prefix;
  if (!names.contains(name)) {
    // Try a search for unambiguous prefix
    final String closest = names.ceiling(prefix);
    if (closest != null && closest.startsWith(prefix)) {
      final String higher = names.higher(closest);
      if (higher == null || !higher.startsWith(prefix)) {
        name = closest;
      }
    }
  }
  return name;
}
 
Example 10
Source File: ConcurrentSkipListSubSetJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 11
Source File: ConcurrentSkipListSubSetJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 12
Source File: ConcurrentSkipListSubSetJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 13
Source File: ConcurrentSkipListSubSetJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 14
Source File: BTreeMapSubSetTest.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 15
Source File: BTreeSet2Test.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 16
Source File: ConcurrentSkipListSubSetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 17
Source File: ConcurrentSkipListSubSetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testCeiling() {
    NavigableSet q = set5();
    Object e1 = q.ceiling(three);
    assertEquals(three, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(one, e2);

    Object e3 = q.ceiling(five);
    assertEquals(five, e3);

    Object e4 = q.ceiling(six);
    assertNull(e4);
}
 
Example 18
Source File: TreeSubSetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ceiling returns next element
 */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);

    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);

    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);

    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
 
Example 19
Source File: InMemoryQueueDAO.java    From emodb with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ByteBuffer findMinRecord(UUID dataId, @Nullable ByteBuffer from) {
    NavigableSet<ByteBuffer> records = _records.get(dataId);
    return from == null ? (records.isEmpty() ? null : records.first()) : records.ceiling(from);
}