Package bm.core.zlib

Examples of bm.core.zlib.ZOutputStream


        if( currentRecord != null && currentRecord.isDirty() )
        {
//            log.debug( "flushing record: " + currentRecord );
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            SerializerOutputStream out;
            ZOutputStream zos = null;
            if( useCompression() )
            {
                log.debug( "Using compression" );
                zos = new ZOutputStream(
                        baos,
                        DeviceInfo.getDeviceInfo().getOptimalCompression()
                );
                out = new SerializerOutputStream( zos );
            }
            else
            {
                out = new SerializerOutputStream( baos );
            }
            try
            {
                open();
                currentRecord.serialize( out );
                out.flush();
                if( useCompression() )
                {
                    //noinspection ConstantConditions
                    zos.flush();
                    zos.close();
                }
                final byte[] data = baos.toByteArray();
                if( currentRecord.getRecordId() > 0 && currentRecord.getRecordId() < rs.getNextRecordID() )
                {
                    //log.debug( "flush: exsiting record " + currentRecord );
View Full Code Here


            throws IOException,
                   RSException,
                   SerializationException
    {
        System.out.println( "Writing index" );
        final ZOutputStream zos = new ZOutputStream(
                os,
                ZStream.Z_BEST_COMPRESSION
        );
        final SerializerOutputStream out = new SerializerOutputStream( zos );

        final int numRecords;
        try
        {
            index.getRecordStore().open();
        }
        catch( RecordStoreFullException e )
        {
            throw new RSException( 0, e );
        }
        final Store rs = index.getRecordStore();
        out.writeInt( index.getOrder() );
        out.writeByte( (byte) index.getType() );
        out.writeBoolean( index.isCaseSensitive() );
        numRecords = rs.getNumRecords();
        System.out.println( "Writing " + numRecords + " records" );
        out.writeInt( numRecords );
        for( int i = 1; i <= numRecords; i++ )
        {
            try
            {
                out.writeBlob( rs.getRecord( i ) );
            }
            catch( InvalidRecordIDException e )
            {
            }
        }
        out.flush();
        zos.flush();
        zos.close();
        System.out.println( "Done" );
    }
View Full Code Here

            throws IOException,
                   RSException,
                   SerializationException
    {
        System.out.println( "Writing index" );
        final ZOutputStream zos = new ZOutputStream(
                os,
                ZStream.Z_BEST_COMPRESSION
        );
        final SerializerOutputStream out = new SerializerOutputStream( zos );

        final int numRecords;
        try
        {
            index.getRecordStore().open();
        }
        catch( RecordStoreFullException e )
        {
            throw new RSException( 0, e );
        }
        final Store rs = index.getRecordStore();
        out.writeInt( index.getOrder() );
        out.writeByte( (byte) index.getType() );
        out.writeBoolean( index.isCaseSensitive() );
        numRecords = rs.getNumRecords();
        System.out.println( "Writing " + numRecords + " records" );
        out.writeInt( numRecords );
        for( int i = 1; i <= numRecords; i++ )
        {
            try
            {
                out.writeBlob( rs.getRecord( i ) );
            }
            catch( InvalidRecordIDException e )
            {
            }
        }
        out.flush();
        zos.flush();
        zos.close();
        System.out.println( "Done" );
    }
View Full Code Here

TOP

Related Classes of bm.core.zlib.ZOutputStream

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.