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


Java MappedByteBuffer.load方法代码示例

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


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

示例1: checkVersion

import java.nio.MappedByteBuffer; //导入方法依赖的package包/类
private boolean checkVersion(FileChannel channel) throws IOException
{
    if (channel.size() > 0)
    {
        channel.position(0);
        ByteBuffer buffer;

        if (useNIOMemoryMapping)
        {
            MappedByteBuffer mbb = channel.map(MapMode.READ_ONLY, 0, 8);
            mbb.load();
            buffer = mbb;
        }
        else
        {
            buffer = ByteBuffer.wrap(new byte[8]);
            channel.read(buffer);
            buffer.position(0);
        }

        buffer.position(0);
        long onDiskVersion = buffer.getLong();
        return (version == onDiskVersion);
    }
    return (version == 0);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:IndexInfo.java

示例2: createGoodBuffers

import java.nio.MappedByteBuffer; //导入方法依赖的package包/类
@DataProvider(name = "goodBuffers")
static Object[][] createGoodBuffers() throws Exception {
    FileChannel fc = FileChannel.open(bob);
    closeables.add(fc);
    MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
    mbb.load();

    return new Object[][] {
            { ByteBuffer.allocateDirect(0) },
            { ByteBuffer.allocateDirect(10) },
            { mbb },
            { fc.map(FileChannel.MapMode.READ_ONLY, 1, 11) }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:InvokeCleaner.java

示例3: updateFunctionCode

import java.nio.MappedByteBuffer; //导入方法依赖的package包/类
private FunctionEntry updateFunctionCode(final String functionName, final FileChannel fileChannel) throws IOException {
    final MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());
    buffer.load();
    final UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest()
            .withFunctionName(functionName)
            .withZipFile(buffer);
    final UpdateFunctionCodeResult result = awsLambdaClient.updateFunctionCode(request);
    return new FunctionEntry(result);
}
 
开发者ID:satr,项目名称:intellij-idea-plugin-connector-for-aws-lambda,代码行数:10,代码来源:ConnectorModel.java

示例4: writeStatusToFile

import java.nio.MappedByteBuffer; //导入方法依赖的package包/类
private void writeStatusToFile(FileChannel channel) throws IOException
{
    long size = getBufferSize();

    ByteBuffer buffer;
    if (useNIOMemoryMapping)
    {
        MappedByteBuffer mbb = channel.map(MapMode.READ_WRITE, 0, size);
        mbb.load();
        buffer = mbb;
    }
    else
    {
        channel.truncate(size);
        buffer = ByteBuffer.wrap(new byte[(int) size]);
    }

    buffer.position(0);

    buffer.putLong(version);
    CRC32 crc32 = new CRC32();
    crc32.update((int) (version >>> 32) & 0xFFFFFFFF);
    crc32.update((int) (version >>> 0) & 0xFFFFFFFF);

    buffer.putInt(indexEntries.size());
    crc32.update(indexEntries.size());

    for (IndexEntry entry : indexEntries.values())
    {
        String entryType = entry.getType().toString();
        writeString(buffer, crc32, entryType);

        writeString(buffer, crc32, entry.getName());

        writeString(buffer, crc32, entry.getParentName());

        String entryStatus = entry.getStatus().toString();
        writeString(buffer, crc32, entryStatus);

        writeString(buffer, crc32, entry.getMergeId());

        buffer.putLong(entry.getDocumentCount());
        crc32.update((int) (entry.getDocumentCount() >>> 32) & 0xFFFFFFFF);
        crc32.update((int) (entry.getDocumentCount() >>> 0) & 0xFFFFFFFF);

        buffer.putLong(entry.getDeletions());
        crc32.update((int) (entry.getDeletions() >>> 32) & 0xFFFFFFFF);
        crc32.update((int) (entry.getDeletions() >>> 0) & 0xFFFFFFFF);

        buffer.put(entry.isDeletOnlyNodes() ? (byte) 1 : (byte) 0);
        crc32.update(entry.isDeletOnlyNodes() ? new byte[] { (byte) 1 } : new byte[] { (byte) 0 });
    }
    buffer.putLong(crc32.getValue());

    if (useNIOMemoryMapping)
    {
        ((MappedByteBuffer) buffer).force();
    }
    else
    {
        buffer.rewind();
        channel.position(0);
        channel.write(buffer);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:66,代码来源:IndexInfo.java


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