本文整理匯總了Java中com.google.common.collect.RangeSet.span方法的典型用法代碼示例。如果您正苦於以下問題:Java RangeSet.span方法的具體用法?Java RangeSet.span怎麽用?Java RangeSet.span使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.RangeSet
的用法示例。
在下文中一共展示了RangeSet.span方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
/**
* Returns the records of this time series that belong to the specified time ranges and are accepted by the
* specified filter.
*
* @param timeRanges the time ranges for which the data must be read
* @throws IOException if an I/O problem occurs
* @throws HorizonDBException if another problem occurs
*/
public ResourceIterator<Record> read(RangeSet<Field> timeRanges,
Filter<String> recordTypeFilter,
Filter<Record> filter) throws IOException, HorizonDBException {
Range<Field> span = timeRanges.span();
final Range<Field> from = this.definition.getPartitionTimeRange(span.lowerEndpoint());
final Range<Field> to;
if (from.contains(span.upperEndpoint())) {
to = from;
} else {
to = this.definition.getPartitionTimeRange(span.upperEndpoint());
}
KeyValueIterator<PartitionId, TimeSeriesPartition> rangeForRead =
this.partitionManager.getRangeForRead(toPartitionId(from), toPartitionId(to), this.definition);
return new PartitionRecordIterator(timeRanges, rangeForRead, recordTypeFilter, filter);
}
示例2: calculateRangeConstraint
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
final RangeConstraint<N> calculateRangeConstraint(final RangeConstraint<N> baseRangeConstraint) {
if (ranges == null) {
return baseRangeConstraint;
}
// Run through alternatives and resolve them against the base type
final RangeSet<N> baseRangeSet = baseRangeConstraint.getAllowedRanges();
Verify.verify(!baseRangeSet.isEmpty(), "Base type %s does not define constraints", getBaseType());
final Range<N> baseRange = baseRangeSet.span();
final List<ValueRange> resolvedRanges = ensureResolvedRanges(ranges, baseRange);
// Next up, ensure the of boundaries match base constraints
final RangeSet<N> typedRanges = ensureTypedRanges(resolvedRanges, baseRange.lowerEndpoint().getClass());
// Now verify if new ranges are strict subset of base ranges
if (!baseRangeSet.enclosesAll(typedRanges)) {
throw new InvalidRangeConstraintException(typedRanges,
"Range constraint %s is not a subset of parent constraint %s", typedRanges, baseRangeSet);
}
return new ResolvedRangeConstraint<>(constraint, typedRanges);
}
示例3: testTypedefPatternsResolving
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
@Test
public void testTypedefPatternsResolving() {
final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
"string-leaf"));
assertTrue(stringleaf.getType() instanceof StringTypeDefinition);
final StringTypeDefinition type = (StringTypeDefinition) stringleaf.getType();
final QName typeQName = type.getQName();
assertEquals("string-ext4", typeQName.getLocalName());
assertEquals(BAR, typeQName.getModule());
assertEquals(Optional.empty(), type.getUnits());
assertEquals(Optional.empty(), type.getDefaultValue());
List<PatternConstraint> patterns = type.getPatternConstraints();
assertEquals(1, patterns.size());
PatternConstraint pattern = patterns.iterator().next();
assertEquals("^[e-z]*$", pattern.getJavaPatternString());
assertEquals(1, type.getLengthConstraint().get().getAllowedRanges().asRanges().size());
final StringTypeDefinition baseType1 = type.getBaseType();
final QName baseType1QName = baseType1.getQName();
assertEquals("string-ext3", baseType1QName.getLocalName());
assertEquals(BAR, baseType1QName.getModule());
assertEquals(Optional.empty(), baseType1.getUnits());
assertEquals(Optional.empty(), baseType1.getDefaultValue());
patterns = baseType1.getPatternConstraints();
assertEquals(1, patterns.size());
pattern = patterns.iterator().next();
assertEquals("^[b-u]*$", pattern.getJavaPatternString());
assertEquals(1, baseType1.getLengthConstraint().get().getAllowedRanges().asRanges().size());
final StringTypeDefinition baseType2 = baseType1.getBaseType();
final QName baseType2QName = baseType2.getQName();
assertEquals("string-ext2", baseType2QName.getLocalName());
assertEquals(BAR, baseType2QName.getModule());
assertEquals(Optional.empty(), baseType2.getUnits());
assertEquals(Optional.empty(), baseType2.getDefaultValue());
assertTrue(baseType2.getPatternConstraints().isEmpty());
final RangeSet<Integer> baseType2Lengths = baseType2.getLengthConstraint().get().getAllowedRanges();
assertEquals(1, baseType2Lengths.asRanges().size());
Range<Integer> length = baseType2Lengths.span();
assertEquals(6, length.lowerEndpoint().intValue());
assertEquals(10, length.upperEndpoint().intValue());
final StringTypeDefinition baseType3 = baseType2.getBaseType();
assertEquals(QName.create(BAR, "string-ext1"), baseType3.getQName());
assertEquals(Optional.empty(), baseType3.getUnits());
assertEquals(Optional.empty(), baseType3.getDefaultValue());
patterns = baseType3.getPatternConstraints();
assertEquals(1, patterns.size());
pattern = patterns.iterator().next();
assertEquals("^[a-k]*$", pattern.getJavaPatternString());
final RangeSet<Integer> baseType3Lengths = baseType3.getLengthConstraint().get().getAllowedRanges();
assertEquals(1, baseType3Lengths.asRanges().size());
length = baseType3Lengths.span();
assertEquals(5, length.lowerEndpoint().intValue());
assertEquals(11, length.upperEndpoint().intValue());
assertEquals(BaseTypes.stringType(), baseType3.getBaseType());
}
示例4: testTypedefLengthsResolving
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
@Test
public void testTypedefLengthsResolving() {
final LeafSchemaNode lengthLeaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
"length-leaf"));
final StringTypeDefinition type = (StringTypeDefinition) lengthLeaf.getType();
assertEquals(QName.create(FOO, "string-ext2"), type.getQName());
assertEquals(Optional.empty(), type.getUnits());
assertEquals(Optional.empty(), type.getDefaultValue());
assertTrue(type.getPatternConstraints().isEmpty());
final RangeSet<Integer> typeLengths = type.getLengthConstraint().get().getAllowedRanges();
assertEquals(1, typeLengths.asRanges().size());
Range<Integer> length = typeLengths.span();
assertEquals(7, length.lowerEndpoint().intValue());
assertEquals(10, length.upperEndpoint().intValue());
final StringTypeDefinition baseType1 = type.getBaseType();
assertEquals(QName.create(BAR, "string-ext2"), baseType1.getQName());
assertEquals(Optional.empty(), baseType1.getUnits());
assertEquals(Optional.empty(), baseType1.getDefaultValue());
assertTrue(baseType1.getPatternConstraints().isEmpty());
final RangeSet<Integer> baseType2Lengths = baseType1.getLengthConstraint().get().getAllowedRanges();
assertEquals(1, baseType2Lengths.asRanges().size());
length = baseType2Lengths.span();
assertEquals(6, length.lowerEndpoint().intValue());
assertEquals(10, length.upperEndpoint().intValue());
final StringTypeDefinition baseType2 = baseType1.getBaseType();
assertEquals(QName.create(BAR, "string-ext1"), baseType2.getQName());
assertEquals(Optional.empty(), baseType2.getUnits());
assertEquals(Optional.empty(), baseType2.getDefaultValue());
final List<PatternConstraint> patterns = baseType2.getPatternConstraints();
assertEquals(1, patterns.size());
final PatternConstraint pattern = patterns.iterator().next();
assertEquals("^[a-k]*$", pattern.getJavaPatternString());
final RangeSet<Integer> baseType3Lengths = baseType2.getLengthConstraint().get().getAllowedRanges();
assertEquals(1, baseType3Lengths.asRanges().size());
length = baseType3Lengths.span();
assertEquals(5, length.lowerEndpoint().intValue());
assertEquals(11, length.upperEndpoint().intValue());
assertEquals(BaseTypes.stringType(), baseType2.getBaseType());
}