Package krati.io

Examples of krati.io.DataWriter


     * @throws IOException
     */
    public final void save(File file) throws IOException {
        _entryFile = file;
        Chronos c = new Chronos();
        DataWriter out = new FastDataWriter(file);

        try {
            out.open();

            // Save entry head
            out.writeLong(STORAGE_VERSION); // write the entry file version
            out.writeLong(_minScn);
            out.writeLong(_maxScn);
            out.writeInt(size());

            // Save entry body
            saveDataSection(out);

            // Save entry tail.
            out.writeLong(_minScn);
            out.writeLong(_maxScn);
        } finally {
            out.close();
        }
       
        if(_log.isInfoEnabled()) {
            _log.info("Saved entry: minScn=" + _minScn + " maxScn=" + _maxScn + " size=" + size() + " file=" + file.getName() + " in " + c.getElapsedTime());
        }
View Full Code Here


        RandomAccessFile raf = new RandomAccessFile(file, "rw");
       
        int fileLength = 1000;
        raf.setLength(fileLength);
       
        DataWriter writer = createDataWriter(file);
        writer.open();
       
        writer.writeInt(12345);
        writer.writeInt(54321);
        writer.writeInt(Integer.MAX_VALUE);
       
        writer.writeLong(0L);
        writer.writeLong(-123L);
        writer.writeLong(Long.MAX_VALUE);
       
        writer.writeShort((short)871);
        writer.writeShort((short)-23);
        writer.writeShort(Short.MAX_VALUE);
       
        DataReader reader = createDataReader(file);
        reader.open();
       
        int intValue;
        intValue = reader.readInt();
        assertEquals(12345, intValue);
       
        intValue = reader.readInt();
        assertEquals(54321, intValue);
       
        intValue = reader.readInt();
        assertEquals(Integer.MAX_VALUE, intValue);
       
        long longValue;
        longValue = reader.readLong();
        assertEquals(0L, longValue);
       
        longValue = reader.readLong();
        assertEquals(-123L, longValue);
       
        longValue = reader.readLong();
        assertEquals(Long.MAX_VALUE, longValue);
       
        short shortValue;
        shortValue = reader.readShort();
        assertEquals((short)871, shortValue);
       
        shortValue = reader.readShort();
        assertEquals((short)-23, shortValue);
       
        shortValue = reader.readShort();
        assertEquals(Short.MAX_VALUE, shortValue);
       
        writer.close();
        reader.close();
    }
View Full Code Here

            posList.add(position);
            valList.add(rand.nextInt());
            position = i * (long)MultiMappedWriter.BUFFER_SIZE;
        }
       
        DataWriter writer = createDataWriter(file);
        writer.open();
        for(int i = 0, cnt = posList.size(); i < cnt; i++) {
            writer.writeInt(posList.get(i), valList.get(i));
        }
        writer.flush();
        writer.close();
       
        DataReader reader = createDataReader(file);
        reader.open();
        for(int i = 0, cnt = posList.size(); i < cnt; i++) {
            position = posList.get(i);
View Full Code Here

            posList.add(position);
            valList.add(rand.nextInt());
            position = i * (long)MultiMappedReader.BUFFER_SIZE;
        }
       
        DataWriter writer = createDataWriter(file);
        writer.open();
        for(int i = 0, cnt = posList.size(); i < cnt; i++) {
            writer.writeInt(posList.get(i), valList.get(i));
        }
        writer.flush();
        writer.close();
       
        DataReader reader = createDataReader(file);
        reader.open();
        for(int i = 0, cnt = posList.size(); i < cnt; i++) {
            position = posList.get(i);
View Full Code Here

TOP

Related Classes of krati.io.DataWriter

Copyright © 2018 www.massapicom. 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.