Examples of MemoryMappedFile


Examples of com.aelitis.azureus.core.diskmanager.MemoryMappedFile

      File fchan = new File( "e:\\fchan.bin" );
      File fmapd = new File( "e:\\fmapd.bin" );
   
      RandomAccessFile raf = new RandomAccessFile( fraf, "rw" );
      FileChannel fc = new RandomAccessFile( fchan, "rw" ).getChannel();
      MemoryMappedFile mmf = new MemoryMappedFile( fmapd );
      mmf.setAccessMode( MemoryMappedFile.MODE_READ_WRITE );
    
      long written = 0;
      long traf = 0;
      long tchan = 0;
      long tmmf = 0;
      int loop = 1;
     
      while( written < MAX_SIZE ) {
        System.out.print("|")if (loop % 80 == 0) System.out.println();
        refreshBuffers();
        long start_pos = new Float(RandomUtils.nextFloat()*(MAX_SIZE-BUFF_SIZE)).longValue();
///////////////////////////////////////////////////////
        long start = System.currentTimeMillis();
        //raf.seek( start_pos );  raf.write( raw );
        traf += System.currentTimeMillis() - start;
///////////////////////////////////////////////////////
        start = System.currentTimeMillis();
        //fc.write( dbb.buff, start_pos );
        tchan += System.currentTimeMillis() - start;
///////////////////////////////////////////////////////
        start = System.currentTimeMillis();
        mmf.write( dbb, 0, start_pos, dbb.limit(DirectByteBuffer.SS_OTHER) );
        tmmf += System.currentTimeMillis() - start;
///////////////////////////////////////////////////////
        written += raw.length;
        loop++;
      }
View Full Code Here

Examples of org.fusesource.hawtdb.internal.io.MemoryMappedFile

    @org.junit.Test
    public void basicOps() throws IOException {
        File file = new File("target/foo.data");
        file.delete();

        MemoryMappedFile mmf = new MemoryMappedFile(file, 1024*1024*100, false);
       
        int PAGE_SIZE = 1024*4;
        int LAST_PAGE = 100;
       
        byte expect[] = createData(PAGE_SIZE);
       
        mmf.write(0, expect);
        mmf.write(LAST_PAGE *PAGE_SIZE, expect);
       
        // Validate data on the first page.
        byte actual[] = new byte[PAGE_SIZE];
        mmf.read(0, actual);
        Assert.assertEquals('a', actual[0]);
        Assert.assertEquals('a', actual[26]);
        Assert.assertEquals('z', actual[26+25]);

        // Validate data on the 3rd page.
        actual = new byte[PAGE_SIZE];
        mmf.read(PAGE_SIZE*LAST_PAGE, actual);
        Assert.assertEquals('a', actual[0]);
        Assert.assertEquals('a', actual[26]);
        Assert.assertEquals('z', actual[26+25]);

        mmf.sync();
        mmf.close();

    }
View Full Code Here

Examples of xbird.util.nio.MemoryMappedFile

                    + docName));
        }
        this._nativeByteOrder = nativeByteOrder;
        final File segFile = new File(coll.getDirectory(), docName + DTM_SEGMENT_FILE_SUFFIX);
        try {
            this._mmfile = new MemoryMappedFile(segFile, PAGE_SHIFT, readOnly, nativeByteOrder);
        } catch (FileNotFoundException e) {
            throw new IllegalStateException("file not found: " + segFile.getAbsolutePath(), e);
        }
        this._pool = readOnly ? new ConcurrentLongCache<int[]>(CACHED_PAGES) : null;
    }
View Full Code Here

Examples of xbird.util.nio.MemoryMappedFile

                    + docName));
        }
        this._nativeByteOrder = nativeByteOrder;
        final File segFile = new File(coll.getDirectory(), docName + DTM_SEGMENT_FILE_SUFFIX);
        try {
            this._mmfile = new MemoryMappedFile(segFile, PAGE_SHIFT, readOnly, nativeByteOrder);
        } catch (FileNotFoundException e) {
            throw new IllegalStateException("file not found: " + segFile.getAbsolutePath(), e);
        }
        this._pool = readOnly ? new ConcurrentLongCache<int[]>(CACHED_PAGES) : null;
    }
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.