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


Java DataSize.toBytes方法代码示例

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


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

示例1: 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

示例2: ExchangeClient

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public ExchangeClient(
        BlockEncodingSerde blockEncodingSerde,
        DataSize maxBufferedBytes,
        DataSize maxResponseSize,
        int concurrentRequestMultiplier,
        Duration minErrorDuration,
        HttpClient httpClient,
        ScheduledExecutorService executor,
        SystemMemoryUsageListener systemMemoryUsageListener)
{
    this.blockEncodingSerde = blockEncodingSerde;
    this.maxBufferedBytes = maxBufferedBytes.toBytes();
    this.maxResponseSize = maxResponseSize;
    this.concurrentRequestMultiplier = concurrentRequestMultiplier;
    this.minErrorDuration = minErrorDuration;
    this.httpClient = httpClient;
    this.executor = executor;
    this.systemMemoryUsageListener = systemMemoryUsageListener;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:ExchangeClient.java

示例3: getPages

import io.airlift.units.DataSize; //导入方法依赖的package包/类
/**
 * @return at least one page if we have pages in buffer, empty list otherwise
 */
public synchronized List<Page> getPages(DataSize maxSize, long sequenceId)
{
    long maxBytes = maxSize.toBytes();
    List<Page> pages = new ArrayList<>();
    long bytes = 0;

    int listOffset = Ints.checkedCast(sequenceId - masterSequenceId.get());
    while (listOffset < masterBuffer.size()) {
        Page page = masterBuffer.get(listOffset++);
        bytes += page.getSizeInBytes();
        // break (and don't add) if this page would exceed the limit
        if (!pages.isEmpty() && bytes > maxBytes) {
            break;
        }
        pages.add(page);
    }
    return ImmutableList.copyOf(pages);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:PartitionBuffer.java

示例4: formatDataSize

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public static String formatDataSize(DataSize size, boolean longForm)
{
    double fractional = size.toBytes();
    String unit = null;
    if (fractional >= 1024) {
        fractional /= 1024;
        unit = "K";
    }
    if (fractional >= 1024) {
        fractional /= 1024;
        unit = "M";
    }
    if (fractional >= 1024) {
        fractional /= 1024;
        unit = "G";
    }
    if (fractional >= 1024) {
        fractional /= 1024;
        unit = "T";
    }
    if (fractional >= 1024) {
        fractional /= 1024;
        unit = "P";
    }

    if (unit == null) {
        unit = "B";
    }
    else if (longForm) {
        unit += "B";
    }

    return format("%s%s", getFormat(fractional).format(fractional), unit);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:35,代码来源:FormatUtils.java

示例5: RaptorPageSink

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public RaptorPageSink(
        PageSorter pageSorter,
        StorageManager storageManager,
        JsonCodec<ShardInfo> shardInfoCodec,
        long transactionId,
        List<Long> columnIds,
        List<Type> columnTypes,
        Optional<Long> sampleWeightColumnId,
        List<Long> sortColumnIds,
        List<SortOrder> sortOrders,
        DataSize maxBufferSize)
{
    this.pageSorter = requireNonNull(pageSorter, "pageSorter is null");
    this.columnTypes = ImmutableList.copyOf(requireNonNull(columnTypes, "columnTypes is null"));

    requireNonNull(storageManager, "storageManager is null");
    this.storagePageSink = storageManager.createStoragePageSink(transactionId, columnIds, columnTypes);
    this.shardInfoCodec = requireNonNull(shardInfoCodec, "shardInfoCodec is null");

    requireNonNull(sampleWeightColumnId, "sampleWeightColumnId is null");
    this.sampleWeightField = columnIds.indexOf(sampleWeightColumnId.orElse(-1L));

    this.sortFields = ImmutableList.copyOf(sortColumnIds.stream().map(columnIds::indexOf).collect(toList()));
    this.sortOrders = ImmutableList.copyOf(requireNonNull(sortOrders, "sortOrders is null"));

    // allow only Integer.MAX_VALUE rows to be buffered as that is the max rows we can sort
    this.pageBuffer = new PageBuffer(maxBufferSize.toBytes(), Integer.MAX_VALUE);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:29,代码来源:RaptorPageSink.java

示例6: dataRate

import io.airlift.units.DataSize; //导入方法依赖的package包/类
static DataSize dataRate(DataSize size, Duration duration)
{
    double rate = size.toBytes() / duration.getValue(SECONDS);
    if (Double.isNaN(rate) || Double.isInfinite(rate)) {
        rate = 0;
    }
    return new DataSize(rate, BYTE).convertToMostSuccinctDataSize();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:ShardRecoveryManager.java

示例7: TemporalCompactionSetCreator

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public TemporalCompactionSetCreator(DataSize maxShardSize, long maxShardRows, Type type)
{
    requireNonNull(maxShardSize, "maxShardSize is null");
    checkArgument(type.equals(DATE) || type.equals(TIMESTAMP), "type must be timestamp or date");

    this.maxShardSizeBytes = maxShardSize.toBytes();

    checkArgument(maxShardRows > 0, "maxShardRows must be > 0");
    this.maxShardRows = maxShardRows;
    this.type = requireNonNull(type, "type is null");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:TemporalCompactionSetCreator.java

示例8: wrapWithCacheIfTiny

import io.airlift.units.DataSize; //导入方法依赖的package包/类
private static OrcDataSource wrapWithCacheIfTiny(OrcDataSource dataSource, DataSize maxCacheSize)
{
    if (dataSource instanceof CachingOrcDataSource) {
        return dataSource;
    }
    if (dataSource.getSize() > maxCacheSize.toBytes()) {
        return dataSource;
    }
    DiskRange diskRange = new DiskRange(0, Ints.checkedCast(dataSource.getSize()));
    return new CachingOrcDataSource(dataSource, desiredOffset -> diskRange);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:OrcReader.java

示例9: mergeAdjacentDiskRanges

import io.airlift.units.DataSize; //导入方法依赖的package包/类
/**
 * Merge disk ranges that are closer than {@code maxMergeDistance}.
 */
public static List<DiskRange> mergeAdjacentDiskRanges(Iterable<DiskRange> diskRanges, DataSize maxMergeDistance, DataSize maxReadSize)
{
    // sort ranges by start offset
    List<DiskRange> ranges = newArrayList(diskRanges);
    Collections.sort(ranges, new Comparator<DiskRange>()
    {
        @Override
        public int compare(DiskRange o1, DiskRange o2)
        {
            return Long.compare(o1.getOffset(), o2.getOffset());
        }
    });

    // merge overlapping ranges
    long maxReadSizeBytes = maxReadSize.toBytes();
    long maxMergeDistanceBytes = maxMergeDistance.toBytes();
    ImmutableList.Builder<DiskRange> result = ImmutableList.builder();
    DiskRange last = ranges.get(0);
    for (int i = 1; i < ranges.size(); i++) {
        DiskRange current = ranges.get(i);
        DiskRange merged = last.span(current);
        if (merged.getLength() <= maxReadSizeBytes && last.getEnd() + maxMergeDistanceBytes >= current.getOffset()) {
            last = merged;
        }
        else {
            result.add(last);
            last = current;
        }
    }
    result.add(last);

    return result.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:37,代码来源:OrcDataSourceUtils.java

示例10: wrapWithCacheIfTinyStripes

import io.airlift.units.DataSize; //导入方法依赖的package包/类
@VisibleForTesting
static OrcDataSource wrapWithCacheIfTinyStripes(OrcDataSource dataSource, List<StripeInformation> stripes, DataSize maxMergeDistance, DataSize maxReadSize)
{
    if (dataSource instanceof CachingOrcDataSource) {
        return dataSource;
    }
    for (StripeInformation stripe : stripes) {
        if (stripe.getTotalLength() > maxReadSize.toBytes()) {
            return dataSource;
        }
    }
    return new CachingOrcDataSource(dataSource, createTinyStripesRangeFinder(stripes, maxMergeDistance, maxReadSize));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:OrcRecordReader.java

示例11: MemoryPool

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public MemoryPool(MemoryPoolId id, DataSize size)
{
    this.id = requireNonNull(id, "name is null");
    requireNonNull(size, "size is null");
    maxBytes = size.toBytes();
    freeBytes = size.toBytes();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:MemoryPool.java

示例12: toBytes

import io.airlift.units.DataSize; //导入方法依赖的package包/类
private static Long toBytes(DataSize dataSize)
{
    if (dataSize == null) {
        return null;
    }
    return dataSize.toBytes();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:TaskSystemTable.java

示例13: IndexSnapshotBuilder

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public IndexSnapshotBuilder(List<Type> outputTypes,
        List<Integer> keyOutputChannels,
        Optional<Integer> keyOutputHashChannel,
        DriverContext driverContext,
        DataSize maxMemoryInBytes,
        int expectedPositions)
{
    requireNonNull(outputTypes, "outputTypes is null");
    requireNonNull(keyOutputChannels, "keyOutputChannels is null");
    requireNonNull(keyOutputHashChannel, "keyOutputHashChannel is null");
    requireNonNull(driverContext, "driverContext is null");
    requireNonNull(maxMemoryInBytes, "maxMemoryInBytes is null");
    checkArgument(expectedPositions > 0, "expectedPositions must be greater than zero");

    this.outputTypes = ImmutableList.copyOf(outputTypes);
    this.expectedPositions = expectedPositions;
    this.keyOutputChannels = ImmutableList.copyOf(keyOutputChannels);
    this.keyOutputHashChannel = keyOutputHashChannel;
    this.maxMemoryInBytes = maxMemoryInBytes.toBytes();

    ImmutableList.Builder<Type> missingKeysTypes = ImmutableList.builder();
    ImmutableList.Builder<Integer> missingKeysChannels = ImmutableList.builder();
    for (int i = 0; i < keyOutputChannels.size(); i++) {
        Integer keyOutputChannel = keyOutputChannels.get(i);
        missingKeysTypes.add(outputTypes.get(keyOutputChannel));
        missingKeysChannels.add(i);
    }
    this.missingKeysTypes = missingKeysTypes.build();
    this.missingKeysChannels = missingKeysChannels.build();

    this.outputPagesIndex = new PagesIndex(outputTypes, expectedPositions);
    this.missingKeysIndex = new PagesIndex(missingKeysTypes.build(), expectedPositions);
    this.missingKeys = missingKeysIndex.createLookupSource(this.missingKeysChannels);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:35,代码来源:IndexSnapshotBuilder.java

示例14: InMemoryExchange

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public InMemoryExchange(List<Type> types, int bufferCount, DataSize maxBufferedBytes)
{
    this.types = ImmutableList.copyOf(requireNonNull(types, "types is null"));

    ImmutableList.Builder<Queue<PageReference>> buffers = ImmutableList.builder();
    for (int i = 0; i < bufferCount; i++) {
        buffers.add(new ConcurrentLinkedQueue<>());
    }
    this.buffers = buffers.build();

    checkArgument(maxBufferedBytes.toBytes() > 0, "maxBufferedBytes must be greater than zero");
    this.maxBufferedBytes = maxBufferedBytes.toBytes();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:InMemoryExchange.java

示例15: SharedBuffer

import io.airlift.units.DataSize; //导入方法依赖的package包/类
public SharedBuffer(TaskId taskId, String taskInstanceId, Executor executor, DataSize maxBufferSize, SystemMemoryUsageListener systemMemoryUsageListener)
{
    requireNonNull(taskId, "taskId is null");
    requireNonNull(executor, "executor is null");
    this.taskInstanceId = requireNonNull(taskInstanceId, "taskInstanceId is null");
    state = new StateMachine<>(taskId + "-buffer", executor, OPEN, TERMINAL_BUFFER_STATES);
    requireNonNull(maxBufferSize, "maxBufferSize is null");
    checkArgument(maxBufferSize.toBytes() > 0, "maxBufferSize must be at least 1");
    requireNonNull(systemMemoryUsageListener, "systemMemoryUsageListener is null");
    this.memoryManager = new SharedBufferMemoryManager(maxBufferSize.toBytes(), systemMemoryUsageListener);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:SharedBuffer.java


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