本文整理汇总了Java中com.google.common.collect.ImmutableRangeSet.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableRangeSet.of方法的具体用法?Java ImmutableRangeSet.of怎么用?Java ImmutableRangeSet.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableRangeSet
的用法示例。
在下文中一共展示了ImmutableRangeSet.of方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exceptionTest
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
@Test
public void exceptionTest() {
final UnresolvedNumber min = UnresolvedNumber.min();
final UnresolvedNumber max = UnresolvedNumber.max();
final EnumPair enumPair = EnumPairBuilder.create("enum1", 1).setDescription("description")
.setReference("reference").setUnknownSchemaNodes(mock(UnknownSchemaNode.class)).build();
final RangeSet<Integer> rangeset = ImmutableRangeSet.of(Range.closed(1, 2));
final InvalidRangeConstraintException invalidRangeConstraintException = new InvalidRangeConstraintException(
rangeset, "error msg", "other important messages");
assertSame(rangeset, invalidRangeConstraintException.getOffendingRanges());
final InvalidBitDefinitionException invalidBitDefinitionException = new InvalidBitDefinitionException(
BIT_A, "error msg", "other important messages");
assertEquals(invalidBitDefinitionException.getOffendingBit(), BIT_A);
final InvalidEnumDefinitionException invalidEnumDefinitionException = new InvalidEnumDefinitionException(
enumPair, "error msg", "other important messages");
assertEquals(invalidEnumDefinitionException.getOffendingEnum(), enumPair);
}
示例2: toRequestFailureTest
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
@Test
public void toRequestFailureTest() throws Exception {
final RequestException exception = new DeadTransactionException(ImmutableRangeSet.of());
final ConnectClientFailure failure = OBJECT.toRequestFailure(exception);
Assert.assertNotNull(failure);
}
示例3: testReadWithOnlySecondOneOfTwoBlocksHit
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
@Test
public void testReadWithOnlySecondOneOfTwoBlocksHit() throws Exception {
Configuration configuration = Configuration.newBuilder().build();
RecordTypeDefinition recordTypeDefinition = RecordTypeDefinition.newBuilder("exchangeState")
.addField("timestampInMillis",
FieldType.MILLISECONDS_TIMESTAMP)
.addField("status", FieldType.BYTE)
.build();
DatabaseDefinition databaseDefinition = new DatabaseDefinition("test");
TimeSeriesDefinition def = databaseDefinition.newTimeSeriesDefinitionBuilder("test")
.timeUnit(TimeUnit.NANOSECONDS)
.addRecordType(recordTypeDefinition)
.blockSize(35)
.build();
SlabAllocator allocator = new SlabAllocator(configuration.getMemTimeSeriesSize());
MemTimeSeries memTimeSeries = new MemTimeSeries(configuration, def);
DataBlock block = new DataBlockBuilder(def).newRecord("exchangeState")
.setTimestampInNanos(0,
TIME_IN_NANOS + 12000700)
.setTimestampInMillis(1, TIME_IN_MILLIS + 12)
.setByte(2, 3)
.newRecord("exchangeState")
.setTimestampInNanos(0,
TIME_IN_NANOS + 13000900)
.setTimestampInMillis(1, TIME_IN_MILLIS + 13)
.setByte(2, 3)
.newRecord("exchangeState")
.setTimestampInNanos(0,
TIME_IN_NANOS + 13004400)
.setTimestampInMillis(1, TIME_IN_MILLIS + 13)
.setByte(2, 1)
.build();
memTimeSeries = memTimeSeries.write(allocator, block, newFuture());
assertEquals(1, memTimeSeries.getNumberOfBlocks());
block = new DataBlockBuilder(def).newRecord("exchangeState")
.setTimestampInNanos(0, TIME_IN_NANOS + 13006400)
.setTimestampInMillis(1, TIME_IN_MILLIS + 14)
.setByte(2, 2)
.build();
memTimeSeries = memTimeSeries.write(allocator, block, newFuture());
assertEquals(2, memTimeSeries.getNumberOfBlocks());
assertEquals(TIME_IN_NANOS + 13006400, memTimeSeries.getGreatestTimestamp());
Field from = NANOSECONDS_TIMESTAMP.newField().setTimestampInNanos(TIME_IN_NANOS + 13006000);
Field to = NANOSECONDS_TIMESTAMP.newField().setTimestampInNanos(TIME_IN_NANOS + 14000000);
RangeSet<Field> rangeSet = ImmutableRangeSet.of(Range.closed(from, to));
try (ResourceIterator<BinaryTimeSeriesRecord> readIterator = new BinaryTimeSeriesRecordIterator(def, memTimeSeries.iterator(rangeSet))) {
assertTrue(readIterator.hasNext());
Record actual = readIterator.next();
assertFalse(actual.isDelta());
assertEquals(TIME_IN_NANOS + 13006400, actual.getTimestampInNanos(0));
assertEquals(TIME_IN_MILLIS + 14, actual.getTimestampInMillis(1));
assertEquals(2, actual.getByte(2));
assertFalse(readIterator.hasNext());
}
}
示例4: testReadWithNoBlocksHit
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
@Test
public void testReadWithNoBlocksHit() throws Exception {
Configuration configuration = Configuration.newBuilder().build();
RecordTypeDefinition recordTypeDefinition = RecordTypeDefinition.newBuilder("exchangeState")
.addField("timestampInMillis",
FieldType.MILLISECONDS_TIMESTAMP)
.addField("status", FieldType.BYTE)
.build();
DatabaseDefinition databaseDefinition = new DatabaseDefinition("test");
TimeSeriesDefinition def = databaseDefinition.newTimeSeriesDefinitionBuilder("test")
.timeUnit(TimeUnit.NANOSECONDS)
.addRecordType(recordTypeDefinition)
.blockSize(35)
.build();
SlabAllocator allocator = new SlabAllocator(configuration.getMemTimeSeriesSize());
MemTimeSeries memTimeSeries = new MemTimeSeries(configuration, def);
DataBlock block = new DataBlockBuilder(def).newRecord("exchangeState")
.setTimestampInNanos(0, TIME_IN_NANOS + 12000700)
.setTimestampInMillis(1, TIME_IN_MILLIS + 12)
.setByte(2, 3)
.newRecord("exchangeState")
.setTimestampInNanos(0, TIME_IN_NANOS + 13000900)
.setTimestampInMillis(1, TIME_IN_MILLIS + 13)
.setByte(2, 3)
.newRecord("exchangeState")
.setTimestampInNanos(0, TIME_IN_NANOS + 13004400)
.setTimestampInMillis(1, TIME_IN_MILLIS + 13)
.setByte(2, 1)
.build();
memTimeSeries = memTimeSeries.write(allocator, block, newFuture());
assertEquals(1, memTimeSeries.getNumberOfBlocks());
block = new DataBlockBuilder(def).newRecord("exchangeState")
.setTimestampInNanos(0, TIME_IN_NANOS + 13006400)
.setTimestampInMillis(1, TIME_IN_MILLIS + 14)
.setByte(2, 2)
.build();
memTimeSeries = memTimeSeries.write(allocator, block, newFuture());
assertEquals(2, memTimeSeries.getNumberOfBlocks());
assertEquals(TIME_IN_NANOS + 13006400, memTimeSeries.getGreatestTimestamp());
Field from = FieldType.NANOSECONDS_TIMESTAMP.newField();
from.setTimestampInNanos(TIME_IN_NANOS + 14000000);
Field to = FieldType.NANOSECONDS_TIMESTAMP.newField();
to.setTimestampInNanos(TIME_IN_NANOS + 15000000);
RangeSet<Field> rangeSet = ImmutableRangeSet.of(Range.closed(from, to));
try (ResourceIterator<BinaryTimeSeriesRecord> readIterator = new BinaryTimeSeriesRecordIterator(def, memTimeSeries.iterator(rangeSet))) {
assertFalse(readIterator.hasNext());
}
}
示例5: AbstractRangeRestrictedBaseType
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
AbstractRangeRestrictedBaseType(final QName qname, final N minValue, final N maxValue) {
super(qname);
this.rangeConstraint = new ResolvedRangeConstraint<>(BUILTIN_CONSTRAINT, ImmutableRangeSet.of(
Range.closed(minValue, maxValue)));
}
示例6: createRangeConstraint
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
private static RangeConstraint<BigDecimal> createRangeConstraint(final String min, final String max) {
return new ResolvedRangeConstraint<>(BUILTIN_CONSTRAINT, ImmutableRangeSet.of(
Range.closed(new BigDecimal(min), new BigDecimal(max))));
}
示例7: singleton
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public static Vlan singleton(int id) {
return new Vlan(ImmutableRangeSet.of(Range.singleton(id).canonical(integers())));
}
示例8: range
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public static Vlan range(int lowerBound, int upperBound) {
return new Vlan(ImmutableRangeSet.of(Range.closed(lowerBound, upperBound).canonical(integers())));
}
示例9: any
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public static Vlan any() {
return new Vlan(ImmutableRangeSet.of(Range.closed(Vlan.MINIMUM_VLAN_ID, Vlan.MAXIMUM_VLAN_ID).canonical(integers())));
}
示例10: none
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public static Vlan none() {
return new Vlan(ImmutableRangeSet.of());
}
示例11: SampleRowsData
import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public SampleRowsData() {
super();
rangeSet = ImmutableRangeSet.of();
addlineField = false;
outputRow = null;
}