protected void write ( WriteableLogRecord logRecord ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "write" , new Object [ ] { logRecord , this } ) ; // Retrieve the data stored within this data item. This will either come from // the cached in memory copy or retrieved from disk. byte [ ] data = this . getData ( ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Writing '" + data . length + "' bytes " + RLSUtils . toHexString ( data , RLSUtils . MAX_DISPLAY_BYTES ) ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Writing length field" ) ; logRecord . putInt ( data . length ) ; // If this data item is using the file backed storage method then we need // record details of the mapped storage buffer and offset within that buffer // where the data has been placed. If this is the first write call then the // information would currently be cached in memory. After this call has // executed further access will require the getData method to go to disk. // If this is a subsequent write call then the getData method will retrieve // the information from the current mapped byte buffer and position and // write it to the new mapped byte buffer and position. It will then cache // the new location details. if ( _storageMode == MultiScopeRecoveryLog . FILE_BACKED ) { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Updaing data location references" ) ; _filePosition = logRecord . position ( ) ; _logRecord = logRecord ; _data = null ; } if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Writing data field" ) ; logRecord . put ( data ) ; if ( ! _written ) { // This is the first time since creation of this object or reset of its internal // data (SingleData class only, setData method) that the write method has been // called. We know that the parent recoverable unit section is accounting for // this data items payload in its unwritten data size. Accordingly we need to // direct it to update this value. _rus . payloadWritten ( _dataSize + HEADER_SIZE ) ; } _written = true ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" ) ; }
Instructs this DataItem to write its data to the given WriteableLogRecord . The write involves writing the length of the data as an int followed by the data itself . The data is written at the log record s current position .