Package java.nio

Examples of java.nio.MappedByteBuffer.order()


                throw new IllegalStateException("map failed for page#" + page + " of file: "
                        + _filepath, ioe);
            }
        }
        if(_setAsLittleEndian) {// BIG_ENDIAN by the default
            buf.order(ByteOrder.LITTLE_ENDIAN);
        }
        return buf;
    }

    public int[] transferBuffer(final long pageOffset, final int aryLength) {
View Full Code Here


        for (int i = 1; ; i++) {
            try {
//                long startTime = System.nanoTime();
                @SuppressWarnings("UnnecessaryLocalVariable")
                MappedByteBuffer map = fileChannel.map(FileChannel.MapMode.READ_WRITE, start, size);
                map.order(ByteOrder.nativeOrder());
//                long time = System.nanoTime() - startTime;
//                System.out.printf("Took %,d us to map %,d MB%n", time / 1000, size / 1024 / 1024);
//                System.out.println("Map size: "+size);
                return map;
            } catch (IOException e) {
View Full Code Here

    int ptrOptionalHeader;

    /* The file we're reading from.*/
    MappedByteBuffer file = new FileInputStream(filename).getChannel().map(FileChannel.MapMode.READ_ONLY, 0, new File(filename).length());
    /* Set the file ordering to little endian */
    file.order(ByteOrder.LITTLE_ENDIAN);

    /* The start of the PE is pointed at by the 0x3c'th byte */
    peStart = file.getInt(PE_START);

    /* The first 4 bytes are the signature */
 
View Full Code Here

      if (Config.FORCE_GEODATA) //Force O/S to Loads this buffer's content into physical memory.
        //it is not guarantee, because the underlying operating system may have paged out some of the buffer's data
        geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size).load();
      else
        geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
      geo.order(ByteOrder.LITTLE_ENDIAN);

      if (size > 196608)
      {
        // Indexing geo files, so we will know where each block starts
        IntBuffer indexs = IntBuffer.allocate(65536);
View Full Code Here

     * @see #_replaceExpr(File, JTextField[], JTextField[])
     */
    public static File _replaceExpr(File src, JTextField[] regText, JTextField[] adjText, LogArea log, JProgressBar jpb) throws IOException {
        RandomAccessFile raf = new RandomAccessFile(src, "r");
        MappedByteBuffer map = raf.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, raf.length());
        map.order(ByteOrder.nativeOrder());
        StringBuffer strBuffer = new StringBuffer(Charset.defaultCharset().decode(map));
        for (int j = 0; j < regText.length; j++) {
            try {
                JTextField field = (JTextField) regText[j];
                if (!field.getText().equals("") && !field.getText().equals(regExprDefault)) {
View Full Code Here

  private void updateMmapIndex(File idx, long capacity, long writerIndex, long readerIndex) throws FileNotFoundException,
        IOException {
    RandomAccessFile raf = new RandomAccessFile(idx, "rw");
    MappedByteBuffer buffer = raf.getChannel().map(MapMode.READ_WRITE, 0, 24);

    buffer.order(ByteOrder.LITTLE_ENDIAN);

    if (capacity > 0) {
      buffer.putLong(0, capacity);
    }
View Full Code Here

                    if (MAX_MAPPED_MEMORY > 0) {
                        utilizeMemory(range.length());
                    }
                    mbb = mapWithSeveralAttempts(file.getPath(), fc, mode, range.position(), range.length());
                    // more "safe" variant, in Java-32, than fc.map(mode, range.position(), range.length());
                    mbb.order(byteOrder);
                    if (CACHE_MAPPINGS) {
                        br = UNSAFE_UNMAP_ON_EXCEEDING_MAX_MAPPED_MEMORY ?
                            new UnmappableRangeWeakReference(mbb, fileIndex, file.getPath(), range, reaped) :
                            new RangeWeakReference<ByteBuffer>(mbb, fileIndex, file.getPath(), range, reaped);
                        mappingCache.put(range, br);
View Full Code Here

            0, rawChannel.size());
      } catch (IOException e) {
        log.error("error mapping file", e);
        return;
      }
      capMappedFile.order(ByteOrder.BIG_ENDIAN);
      rawMappedFile.order(ByteOrder.BIG_ENDIAN);
      ByteBuffer cap = ByteBuffer.wrap(capMappedFile);
      ByteBuffer in = ByteBuffer.wrap(rawMappedFile);

      boolean serverMode = (cap.get() == (byte) 0x01);
View Full Code Here

      if(Config.FORCE_GEODATA) //Force O/S to Loads this buffer's content into physical memory.
        //it is not guarantee, because the underlying operating system may have paged out some of the buffer's data
        geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size).load();
      else
        geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
      geo.order(ByteOrder.LITTLE_ENDIAN);

      if(size > 196608)
      {
        // Indexing geo files, so we will know where each block starts
        IntBuffer indexs = IntBuffer.allocate(65536);
View Full Code Here

      int offset = 0;

      FileChannel channel = f.getChannel();
      MappedByteBuffer byteBuf = channel.map(FileChannel.MapMode.READ_ONLY, start, buf.length*4);
      if (bigEndian) {
        byteBuf.order(ByteOrder.BIG_ENDIAN);
      } else {
        byteBuf.order(ByteOrder.LITTLE_ENDIAN);
      }
      while (offset < buf.length) {
        if (components == 3) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.