APISonar


com.google.common.io.Files.map

> com > google > common > io > Files > map
com APIs google APIs common APIs io APIs Files APIs map APIs

Example 1
public static MappedByteBufferHandler map(File file) throws IOException
  {
    MappedByteBuffer mappedByteBuffer = Files.map(file);
    return new MappedByteBufferHandler(mappedByteBuffer);
  }
Example 2
private static void corrupt(
      DataSegment segment
  ) throws IOException
  {
    final Map<String, Object> localLoadSpec = segment.getLoadSpec();
    final Path segmentPath = Paths.get(localLoadSpec.get("path").toString());

    final MappedByteBuffer buffer = Files.map(segmentPath.toFile(), FileChannel.MapMode.READ_WRITE);
    while (buffer.hasRemaining()) {
      buffer.put((byte) 0xFF);
    }
  }
Example 3
public static Slice mapFileReadOnly(File file)
            throws IOException
    {
        return Slice.toUnsafeSlice(Files.map(file));
    }
Example 4
public void setup() throws Exception
  {
    File dir = new File(dirPath);
    File compFile = new File(dir, file + "-" + strategy);
    rand = new Random();
    ByteBuffer buffer = Files.map(compFile);
    supplier = CompressedFloatsIndexedSupplier.fromByteBuffer(buffer, ByteOrder.nativeOrder(), null);
  }
Example 5
public void testUnmapDoesntCrashJVM() throws Exception
  {
    final File file = temporaryFolder.newFile("some_mmap_file");
    try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
      final byte[] data = new byte[4096];
      Arrays.fill(data, (byte) 0x5A);
      os.write(data);
    }
    final MappedByteBuffer mappedByteBuffer = Files.map(file);
    Assert.assertEquals((byte) 0x5A, mappedByteBuffer.get(0));
    ByteBufferUtils.unmap(mappedByteBuffer);
    ByteBufferUtils.unmap(mappedByteBuffer);
  }
Example 6
public FragmentData(FragmentMetaInfo fragmentMetaInfo, File fragmentDataFile) throws IOException {
        this.dictionaryMap = Maps.newConcurrentMap();
        this.fragmentMetaInfo = fragmentMetaInfo;
        this.fragmentDataFile = fragmentDataFile;
        this.dataBuffer = Files.map(fragmentDataFile, FileChannel.MapMode.READ_ONLY);
    }