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


Java DataSize类代码示例

本文整理汇总了Java中io.airlift.units.DataSize的典型用法代码示例。如果您正苦于以下问题:Java DataSize类的具体用法?Java DataSize怎么用?Java DataSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataSize类属于io.airlift.units包,在下文中一共展示了DataSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefaults

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testDefaults()
{
    assertRecordedDefaults(recordDefaults(ApacheThriftClientConfig.class)
            .setTransport(FRAMED)
            .setProtocol(BINARY)
            .setConnectTimeout(new Duration(500, MILLISECONDS))
            .setRequestTimeout(new Duration(1, MINUTES))
            .setSocksProxy(null)
            .setMaxFrameSize(new DataSize(16, MEGABYTE))
            .setMaxStringSize(new DataSize(16, MEGABYTE))
            .setSslEnabled(false)
            .setTrustCertificate(null)
            .setKey(null)
            .setKeyPassword(null));
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:TestApacheThriftClientConfig.java

示例2: get

import io.airlift.units.DataSize; //导入依赖的package包/类
public synchronized CompletableFuture<BufferResult> get(TaskId outputId, long startingSequenceId, DataSize maxSize)
{
    requireNonNull(outputId, "outputId is null");
    checkArgument(maxSize.toBytes() > 0, "maxSize must be at least 1 byte");

    // if no buffers can be added, and the requested buffer does not exist, return a closed empty result
    // this can happen with limit queries
    BufferState state = this.state.get();
    if (state != FAILED && !state.canAddBuffers() && namedBuffers.get(outputId) == null) {
        return completedFuture(emptyResults(taskInstanceId, 0, true));
    }

    // return a future for data
    GetBufferResult getBufferResult = new GetBufferResult(outputId, startingSequenceId, maxSize);
    stateChangeListeners.add(getBufferResult);
    updateState();
    return getBufferResult.getFuture();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:SharedBuffer.java

示例3: testExplicitPropertyMappings

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testExplicitPropertyMappings()
{
    Map<String, String> properties = new ImmutableMap.Builder<String, String>()
            .put("query.low-memory-killer.enabled", "true")
            .put("query.low-memory-killer.delay", "20s")
            .put("query.max-memory", "2GB")
            .put("query.max-memory-per-node", "2GB")
            .build();

    MemoryManagerConfig expected = new MemoryManagerConfig()
            .setKillOnOutOfMemory(true)
            .setKillOnOutOfMemoryDelay(new Duration(20, SECONDS))
            .setMaxQueryMemory(new DataSize(2, GIGABYTE))
            .setMaxQueryMemoryPerNode(new DataSize(2, GIGABYTE));

    assertFullMapping(properties, expected);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:TestMemoryManagerConfig.java

示例4: toString

import io.airlift.units.DataSize; //导入依赖的package包/类
@Override
public String toString()
{
    ToStringHelper stringHelper = toStringHelper(this)
            .add("tableId", "tableId")
            .add("shardId", shardId)
            .add("shardUuid", shardUuid)
            .add("rowCount", rowCount)
            .add("compressedSize", DataSize.succinctBytes(compressedSize))
            .add("uncompressedSize", DataSize.succinctBytes(uncompressedSize));

    if (rangeStart.isPresent()) {
        stringHelper.add("rangeStart", rangeStart.getAsLong());
    }
    if (rangeEnd.isPresent()) {
        stringHelper.add("rangeEnd", rangeEnd.getAsLong());
    }
    return stringHelper.toString();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:ShardMetadata.java

示例5: run

import io.airlift.units.DataSize; //导入依赖的package包/类
@Override
public void run()
{
    try {
        stats.addQueuedTime(Duration.nanosSince(queuedTime));
        long start = System.nanoTime();

        backupStore.get().backupShard(uuid, source);
        stats.addCopyShardDataRate(new DataSize(source.length(), BYTE), Duration.nanosSince(start));
        stats.incrementBackupSuccess();
    }
    catch (Throwable t) {
        stats.incrementBackupFailure();
        throw Throwables.propagate(t);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:BackupManager.java

示例6: testNonTemporalCompactionSetSimple

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testNonTemporalCompactionSetSimple()
        throws Exception
{
    CompactionSetCreator compactionSetCreator = new FileCompactionSetCreator(new DataSize(1, KILOBYTE), MAX_SHARD_ROWS);

    // compact into one shard
    Set<ShardMetadata> inputShards = ImmutableSet.of(
            shardWithSize(100),
            shardWithSize(100),
            shardWithSize(100));

    Set<CompactionSet> compactionSets = compactionSetCreator.createCompactionSets(1L, inputShards);
    assertEquals(compactionSets.size(), 1);
    assertEquals(getOnlyElement(compactionSets).getShardsToCompact(), inputShards);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestCompactionSetCreator.java

示例7: testNonTemporalCompactionSet

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testNonTemporalCompactionSet()
        throws Exception
{
    CompactionSetCreator compactionSetCreator = new FileCompactionSetCreator(new DataSize(100, BYTE), MAX_SHARD_ROWS);
    long tableId = 1L;

    // compact into two shards
    List<ShardMetadata> inputShards = ImmutableList.of(
            shardWithSize(70),
            shardWithSize(20),
            shardWithSize(30),
            shardWithSize(120));

    Set<CompactionSet> compactionSets = compactionSetCreator.createCompactionSets(tableId, ImmutableSet.copyOf(inputShards));
    assertEquals(compactionSets.size(), 2);
    Set<CompactionSet> expected = ImmutableSet.of(
            new CompactionSet(tableId, ImmutableSet.of(inputShards.get(0), inputShards.get(2))),
            new CompactionSet(tableId, ImmutableSet.of(inputShards.get(1))));
    assertEquals(compactionSets, expected);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TestCompactionSetCreator.java

示例8: testTemporalCompactionNoCompactionAcrossDays

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testTemporalCompactionNoCompactionAcrossDays()
        throws Exception
{
    CompactionSetCreator compactionSetCreator = new TemporalCompactionSetCreator(new DataSize(100, BYTE), MAX_SHARD_ROWS, TIMESTAMP);
    long tableId = 1L;
    long day1 = Duration.ofDays(Duration.ofNanos(System.nanoTime()).toDays()).toMillis();
    long day2 = Duration.ofDays(Duration.ofMillis(day1).toDays() + 1).toMillis();

    // compact into two shards
    List<ShardMetadata> inputShards = ImmutableList.of(
            shardWithRange(10, day1, day1),
            shardWithRange(10, day2, day2),
            shardWithRange(10, day1, day1));

    Set<CompactionSet> actual = compactionSetCreator.createCompactionSets(tableId, ImmutableSet.copyOf(inputShards));
    assertEquals(actual.size(), 2);
    Set<CompactionSet> expected = ImmutableSet.of(
            new CompactionSet(tableId, ImmutableSet.of(inputShards.get(0), inputShards.get(2))),
            new CompactionSet(tableId, ImmutableSet.of(inputShards.get(1))));
    assertEquals(actual, expected);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:TestCompactionSetCreator.java

示例9: testMaxFileSize

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testMaxFileSize()
        throws Exception
{
    List<Long> columnIds = ImmutableList.of(3L, 7L);
    List<Type> columnTypes = ImmutableList.<Type>of(BIGINT, VARCHAR);

    List<Page> pages = rowPagesBuilder(columnTypes)
            .row(123, "hello")
            .row(456, "bye")
            .build();

    // Set maxFileSize to 1 byte, so adding any page makes the StoragePageSink full
    OrcStorageManager manager = createOrcStorageManager(20, new DataSize(1, BYTE));
    StoragePageSink sink = createStoragePageSink(manager, columnIds, columnTypes);
    sink.appendPages(pages);
    assertTrue(sink.isFull());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:TestOrcStorageManager.java

示例10: createOrcStorageManager

import io.airlift.units.DataSize; //导入依赖的package包/类
public static OrcStorageManager createOrcStorageManager(
        StorageService storageService,
        Optional<BackupStore> backupStore,
        ShardRecoveryManager recoveryManager,
        ShardRecorder shardRecorder,
        int maxShardRows,
        DataSize maxFileSize)
{
    return new OrcStorageManager(
            CURRENT_NODE,
            storageService,
            backupStore,
            SHARD_DELTA_CODEC,
            READER_ATTRIBUTES,
            new BackupManager(backupStore, 1),
            recoveryManager,
            shardRecorder,
            new TypeRegistry(),
            CONNECTOR_ID,
            DELETION_THREADS,
            SHARD_RECOVERY_TIMEOUT,
            maxShardRows,
            maxFileSize);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:TestOrcStorageManager.java

示例11: formatDataRate

import io.airlift.units.DataSize; //导入依赖的package包/类
public static String formatDataRate(DataSize dataSize, Duration duration, boolean longForm)
{
    double rate = dataSize.toBytes() / duration.getValue(SECONDS);
    if (Double.isNaN(rate) || Double.isInfinite(rate)) {
        rate = 0;
    }

    String rateString = formatDataSize(new DataSize(rate, BYTE), false);
    if (longForm) {
        if (!rateString.endsWith("B")) {
            rateString += "B";
        }
        rateString += "/s";
    }
    return rateString;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:FormatUtils.java

示例12: testMergeGap

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testMergeGap()
{
    List<DiskRange> consistent10ByteGap = ImmutableList.of(new DiskRange(100, 90), new DiskRange(200, 90), new DiskRange(300, 90));
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(0, BYTE), new DataSize(1, GIGABYTE)), consistent10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(9, BYTE), new DataSize(1, GIGABYTE)), consistent10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(1, GIGABYTE)), ImmutableList.of(new DiskRange(100, 290)));
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(100, BYTE), new DataSize(1, GIGABYTE)), ImmutableList.of(new DiskRange(100, 290)));

    List<DiskRange> middle10ByteGap = ImmutableList.of(new DiskRange(100, 80), new DiskRange(200, 90), new DiskRange(300, 80), new DiskRange(400, 90));
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(0, BYTE), new DataSize(1, GIGABYTE)), middle10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(9, BYTE), new DataSize(1, GIGABYTE)), middle10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(10, BYTE), new DataSize(1, GIGABYTE)),
            ImmutableList.of(new DiskRange(100, 80), new DiskRange(200, 180), new DiskRange(400, 90)));
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(100, BYTE), new DataSize(1, GIGABYTE)), ImmutableList.of(new DiskRange(100, 390)));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestOrcDataSourceUtils.java

示例13: testMergeMaxSize

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testMergeMaxSize()
{
    List<DiskRange> consistent10ByteGap = ImmutableList.of(new DiskRange(100, 90), new DiskRange(200, 90), new DiskRange(300, 90));
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(0, BYTE)), consistent10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(100, BYTE)), consistent10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(190, BYTE)),
            ImmutableList.of(new DiskRange(100, 190), new DiskRange(300, 90)));
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(200, BYTE)),
            ImmutableList.of(new DiskRange(100, 190), new DiskRange(300, 90)));
    assertEquals(mergeAdjacentDiskRanges(consistent10ByteGap, new DataSize(10, BYTE), new DataSize(290, BYTE)), ImmutableList.of(new DiskRange(100, 290)));

    List<DiskRange> middle10ByteGap = ImmutableList.of(new DiskRange(100, 80), new DiskRange(200, 90), new DiskRange(300, 80), new DiskRange(400, 90));
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(0, BYTE), new DataSize(1, GIGABYTE)), middle10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(9, BYTE), new DataSize(1, GIGABYTE)), middle10ByteGap);
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(10, BYTE), new DataSize(1, GIGABYTE)),
            ImmutableList.of(new DiskRange(100, 80), new DiskRange(200, 180), new DiskRange(400, 90)));
    assertEquals(mergeAdjacentDiskRanges(middle10ByteGap, new DataSize(100, BYTE), new DataSize(1, GIGABYTE)), ImmutableList.of(new DiskRange(100, 390)));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:TestOrcDataSourceUtils.java

示例14: testIntegration

import io.airlift.units.DataSize; //导入依赖的package包/类
@Test
public void testIntegration()
        throws IOException
{
    // tiny file
    TestingOrcDataSource orcDataSource = new TestingOrcDataSource(
            new FileOrcDataSource(tempFile.getFile(), new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE)));
    doIntegration(orcDataSource, new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE));
    assertEquals(orcDataSource.getReadCount(), 1); // read entire file at once

    // tiny stripes
    orcDataSource = new TestingOrcDataSource(
            new FileOrcDataSource(tempFile.getFile(), new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE)));
    doIntegration(orcDataSource, new DataSize(400, Unit.KILOBYTE), new DataSize(400, Unit.KILOBYTE));
    assertEquals(orcDataSource.getReadCount(), 3); // footer, first few stripes, last few stripes
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestCachingOrcDataSource.java

示例15: IndexLookupSourceSupplier

import io.airlift.units.DataSize; //导入依赖的package包/类
public IndexLookupSourceSupplier(
        Set<Integer> lookupSourceInputChannels,
        List<Integer> keyOutputChannels,
        Optional<Integer> keyOutputHashChannel,
        List<Type> outputTypes,
        IndexBuildDriverFactoryProvider indexBuildDriverFactoryProvider,
        DataSize maxIndexMemorySize,
        IndexJoinLookupStats stats,
        boolean shareIndexLoading)
{
    this.outputTypes = ImmutableList.copyOf(requireNonNull(outputTypes, "outputTypes is null"));

    if (shareIndexLoading) {
        IndexLoader shared = new IndexLoader(lookupSourceInputChannels, keyOutputChannels, keyOutputHashChannel, outputTypes, indexBuildDriverFactoryProvider, 10_000, maxIndexMemorySize, stats);
        this.indexLoaderSupplier = () -> shared;
    }
    else {
        this.indexLoaderSupplier = () -> new IndexLoader(lookupSourceInputChannels, keyOutputChannels, keyOutputHashChannel, outputTypes, indexBuildDriverFactoryProvider, 10_000, maxIndexMemorySize, stats);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:IndexLookupSourceSupplier.java


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