void validateBlock ( Row row ) { if ( ! row . getDatabase ( ) . isValidate ( ) ) { return ; } int rowHead = _rowHead ; int blobTail = _blobTail ; if ( rowHead < blobTail ) { throw new IllegalStateException ( this + " rowHead:" + rowHead + " blobTail:" + blobTail ) ; } int rowOffset = _rowHead ; byte [ ] buffer = _buffer ; while ( rowOffset < BLOCK_SIZE ) { int code = buffer [ rowOffset ] & CODE_MASK ; switch ( code ) { case INSERT : row . validate ( buffer , rowOffset , rowHead , blobTail ) ; break ; case INSERT_DEAD : case REMOVE : break ; default : throw new IllegalStateException ( this + " " + rowOffset + " " + code + " unknown code" ) ; } int len = getLength ( code , row ) ; if ( len < 0 || len + rowOffset > BLOCK_SIZE ) { throw new IllegalStateException ( this + " " + rowOffset + " code:" + code + " len:" + len + " invalid len" ) ; } rowOffset += len ; } }
Validate the block checking that row lengths and values are sensible .