/** * Updates a record using a custom serializer. * * @param recid the recid for the record that is to be updated. * @param obj the new object for the record. * @param serializer a custom serializer * @throws IOException when one of the underlying I/O operations fails. */ public synchronized void update( long recid, Object obj, Serializer serializer ) throws IOException { checkIfClosed(); if ( recid <= 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } Location logRecid = new Location( recid ); Location physRecid = logMgr.fetch( logRecid ); byte[] data = serializer.serialize( obj ); if ( DEBUG ) { System.out.println( "BaseRecordManager.update() recid " + recid + " length " + data.length ); } Location newRecid = physMgr.update( physRecid, data, 0, data.length ); if ( !newRecid.equals( physRecid ) ) { logMgr.update( logRecid, newRecid ); } }
Location newRecid = physMgr.update( physRecid, data, 0, data.length );
Location newRecid = physMgr.update( physRecid, data, 0, data.length );
private <A> void update2(long logRecid, A obj, Serializer<A> serializer,byte[] insertBuffer, OpenByteArrayOutputStream insertBAO, SerializerOutput insertOut) throws IOException { logRecid = decompressRecid(logRecid); long physRecid = _logicMgr.fetch( logRecid ); if(physRecid == 0) throw new IOException("Can not update, recid does not exist: "+logRecid); insertBAO.reset(insertBuffer); serializer.serialize(insertOut, obj ); if(compress){ byte[] data = compress(insertBAO.getBuf(),insertBAO.size()); insertBAO.reset(insertBuffer); insertBAO.write(data); } if ( DEBUG ) { System.out.println( "BaseRecordManager.update() recid " + logRecid + " length " + insertBAO.size() ) ; } long newRecid = _physMgr.update( physRecid, insertBAO.getBuf(), 0, insertBAO.size() ); _logicMgr.update( logRecid, newRecid ); }