当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableRangeSet.of方法代码示例

本文整理汇总了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);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:21,代码来源:TypeTest.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:ConnectClientRequestTest.java

示例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());
    }
}
 
开发者ID:blerer,项目名称:horizondb,代码行数:74,代码来源:MemTimeSeriesTest.java

示例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());
    }
}
 
开发者ID:blerer,项目名称:horizondb,代码行数:66,代码来源:MemTimeSeriesTest.java

示例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)));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:6,代码来源:AbstractRangeRestrictedBaseType.java

示例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))));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:5,代码来源:BaseDecimalType.java

示例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())));
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:4,代码来源:Vlan.java

示例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())));
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:4,代码来源:Vlan.java

示例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())));
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:4,代码来源:Vlan.java

示例10: none

import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public static Vlan none() {
  return new Vlan(ImmutableRangeSet.of());
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:4,代码来源:Vlan.java

示例11: SampleRowsData

import com.google.common.collect.ImmutableRangeSet; //导入方法依赖的package包/类
public SampleRowsData() {
  super();
  rangeSet = ImmutableRangeSet.of();
  addlineField = false;
  outputRow = null;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:7,代码来源:SampleRowsData.java


注:本文中的com.google.common.collect.ImmutableRangeSet.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。