本文整理汇总了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);
}
示例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) }
};
}
示例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);
}
示例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);
}
}