Package bm.core.io

Examples of bm.core.io.SerializerInputStream


                   RSException, IOException
    {
        final Log log = Util.log;

        ZInputStream zis = null;
        SerializerInputStream in = null;
        try
        {
            zis = new ZInputStream( is );
            in = new SerializerInputStream( zis );

            final int       order           = in.readInt(); // ToDo: should do something with this?
            final byte      type            = in.readByte();
            final boolean   caseSensitive   = in.readBoolean();
            Store rs = null;
            boolean burstMode = Store.isBurstMode();
            try
            {
                System.gc();
                Store.safeDeleteRecordStore( name );
                Store.setBurstMode( !ControlledTask.isBackgroundTask() );
                rs = Store.get( name, 1 );
                rs.open( true );
                log.debug( "created recordstore" );
                final int size = in.readInt();
                log.debug( "index size (entries): " + size );
                if( size > 0 )
                {
                    final ProgressEvent event = new ProgressEvent();
                    event.setAnimate( false );
                    event.setCurrentValue( 0 );
                    event.setMaxValue( new Integer( size ) );
                    event.dispatch();
                    for( int j = 0; j < size; j++ )
                    {
                        log.debug( "record: " + j );
                        final byte[] data = in.readBlob();
                        int rid = rs.addRecord( data, 0, data.length );
                        log.debug( "record added (" + rid + "): " + data.length + " bytes" );
                        event.increment();
                        event.dispatch();
                        if( j == 0 && rid != 1 )
                        {
                            ErrorLog.addError(
                                    "DbTool",
                                    "processIndex",
                                    null,
                                    "Old not erased, recordId is not 1 (" + rid + ")",
                                    null
                            );
                            log.error( "RecordId is not 1!!!!" );
                            throw new IOException( "Old not erased" );
                        }
                        if( j % 100 == 0 )
                        {
                            System.gc();
                        }
                    }
                }
                System.gc();
                log.debug( "index " + name + " finished" );
            }
            finally
            {
                try{ if( rs != null ) rs.close(); }catch( Exception e ){}
                Store.setBurstMode( burstMode );
            }
        }
        finally
        {
            try{ if( in != null ) in.close(); }catch( Exception e ){}
            try{ if( zis != null ) in.close(); }catch( Exception e ){}
        }
    }
View Full Code Here


            rs = RecordStore.openRecordStore( "sys_devinfo", true );
            final byte[] data = rs.getRecord( 1 );
            if( data != null )
            {
                final ByteArrayInputStream bais = new ByteArrayInputStream( data );
                final SerializerInputStream in = new SerializerInputStream( bais );
                final DeviceInfo deviceInfo = new DeviceInfo();
                deviceInfo.deserialize( in );
                DeviceInfo.setDeviceInfo( deviceInfo );
            }
        }
View Full Code Here

            assertEquals( 1, rs.getNumRecords() );
            final byte[] data = rs.getRecord( info.recordId.intValue() );
            assertNotNull( data );
            assertEquals( 33, data.length );
            final ByteArrayInputStream bais = new ByteArrayInputStream( data );
            final SerializerInputStream in = new SerializerInputStream( bais );
            final StoreInfo info2 = new StoreInfo( "test2" );
            info2.deserialize( in );
            assertTrue( info.equals( info2 ) );
        }
        catch( Exception e )
View Full Code Here

        final SerializerOutputStream out = new SerializerOutputStream( baos );
        info.serialize( out );

        final StoreInfo info2 = new StoreInfo( "test2" );
        final ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
        final SerializerInputStream in = new SerializerInputStream( bais );
        info2.deserialize( in );

        assertTrue( info.equals( info2 ) );
    }
View Full Code Here

TOP

Related Classes of bm.core.io.SerializerInputStream

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.