List of usage examples for com.google.common.collect TreeRangeSet asRanges
Set asRanges
To view the source code for com.google.common.collect TreeRangeSet asRanges.
Click Source Link
From source file:org.apache.calcite.adapter.druid.DruidDateTimeUtils.java
/** * Generates a list of {@link LocalInterval}s equivalent to a given * expression. Assumes that all the predicates in the input * reference a single column: the timestamp column. *///from www . j a v a 2s . com public static List<LocalInterval> createInterval(RelDataType type, RexNode e) { final List<Range<Calendar>> ranges = extractRanges(e, false); if (ranges == null) { // We did not succeed, bail out return null; } final TreeRangeSet condensedRanges = TreeRangeSet.create(); for (Range r : ranges) { condensedRanges.add(r); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Inferred ranges on interval : " + condensedRanges); } return toInterval(ImmutableList.<Range>copyOf(condensedRanges.asRanges())); }
From source file:org.onosproject.net.resource.DiscreteResourceSetSerializer.java
@Override public void write(Kryo kryo, Output output, DiscreteResourceSet object) { TreeRangeSet<Integer> rangeSet = TreeRangeSet.create(); object.values().stream().map(x -> x.valueAs(Object.class)).flatMap(Tools::stream) .map(x -> object.codec().encode(x)).map(Range::singleton) .map(x -> x.canonical(DiscreteDomain.integers())).forEach(rangeSet::add); List<ClosedOpenRange> ranges = rangeSet.asRanges().stream().map(ClosedOpenRange::of) .collect(Collectors.toList()); kryo.writeObject(output, ranges);//from ww w. ja v a 2s. c o m kryo.writeClassAndObject(output, object.codec()); kryo.writeObject(output, object.parent()); }