gpt4 book ai didi

com.yahoo.memory.WritableMemory.map()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 22:15:05 25 4
gpt4 key购买 nike

本文整理了Java中com.yahoo.memory.WritableMemory.map()方法的一些代码示例,展示了WritableMemory.map()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WritableMemory.map()方法的具体详情如下:
包路径:com.yahoo.memory.WritableMemory
类名称:WritableMemory
方法名:map

WritableMemory.map介绍

[英]Maps the entire given file into native-ordered Memory for write operations (including those > 2GB). Calling this method is equivalent to calling #map(File,long,long,ByteOrder).

Note: Always qualify this method with the class name, e.g., WritableMemory.map(...).
[中]将整个给定文件映射到本机有序内存中,以进行写入操作(包括大于2GB的操作)。调用这个方法相当于调用#map(File,long,long,ByteOrder)。
注意:始终使用类名限定此方法,例如WritableMemory。地图(…)。

代码示例

代码示例来源:origin: DataSketches/sketches-core

static void byteArrToFile(byte[] byteArr, String fileName) throws Exception {
 String userDir = System.getProperty("user.dir");
 String fullPathName = userDir + "/src/test/resources/" + fileName;
 File file = new File(fullPathName);
 if (file.exists()) { Files.delete(file.toPath()); }
 assertTrue(file.createNewFile());
 assertTrue(file.setWritable(true, false));
 assertTrue(file.isFile());
 try (WritableMapHandle wmh
   = WritableMemory.map(file, 0, byteArr.length, ByteOrder.nativeOrder())) {
  WritableMemory wmem = wmh.get();
  wmem.putByteArray(0, byteArr, 0, byteArr.length);
  wmh.force();
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: DataSketches/memory

/**
 * Maps the entire given file into native-ordered Memory for write operations
 * (including those > 2GB). Calling this method is equivalent to calling
 * {@link #map(File, long, long, ByteOrder) map(file, 0, file.length(), ByteOrder.nativeOrder())}.
 *
 * <p><b>Note:</b> Always qualify this method with the class name, e.g.,
 * <i>WritableMemory.map(...)</i>.
 * @param file the given file to map
 * @return WritableMapHandle for managing the mapped Memory.
 * Please read Javadocs for {@link Handle}.
 * @throws IOException file not found or a RuntimeException.
 */
public static WritableMapHandle map(final File file) throws IOException {
 return map(file, 0, file.length(), nativeOrder);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com