public void checksum()

in activeio-core/src/main/java/org/apache/activeio/journal/active/Record.java [161:189]


	public void checksum(DataInput in) throws IOException {
		if( SELECTED_CHECKSUM_ALGORITHIM==HASH_CHECKSUM_ALGORITHIM ) {

		    byte  buffer[] = new byte[1024];
			byte rc[] = new byte[8];
			for (int i = 0; i < payloadLength;) {
			    int l = Math.min(buffer.length, payloadLength-i);
				in.readFully(buffer,0,l);
				for (int j = 0; j < l; j++) {
					rc[j%8] ^= buffer[j];			
				}
				i+=l;
			}			
			checksum = (rc[0])|(rc[1]<<1)|(rc[2]<<2)|(rc[3]<<3)|(rc[4]<<4)|(rc[5]<<5)|(rc[6]<<6)|(rc[7]<<7) ;
			
		} else if( SELECTED_CHECKSUM_ALGORITHIM==CRC32_CHECKSUM_ALGORITHIM ) {
			byte  buffer[] = new byte[1024];
			CRC32 crc32 = new CRC32();
			for (int i = 0; i < payloadLength;) {
			    int l = Math.min(buffer.length, payloadLength-i);
				in.readFully(buffer,0,l);
				crc32.update(buffer,0,l);
				i+=l;
			}			
			checksum = crc32.getValue();
		} else {
		    checksum = 0L;
		}
    }