Ejemplo n.º 1
0
/* Validates the codec footer previously written by WriteFooter(). */
func CheckFooter(in ChecksumIndexInput) (cs int64, err error) {
	if err = validateFooter(in); err == nil {
		cs = in.Checksum()
		var cs2 int64
		if cs2, err = in.ReadLong(); err == nil {
			if cs != cs2 {
				return 0, errors.New(fmt.Sprintf(
					"checksum failed (hardware problem?): expected=%v actual=%v (resource=%v)",
					util.ItoHex(cs2), util.ItoHex(cs), in))
			}
			if in.FilePointer() != in.Length() {
				return 0, errors.New(fmt.Sprintf(
					"did not read all bytes from file: read %v vs size %v (resource: %v)",
					in.FilePointer(), in.Length(), in))
			}
		}
	}
	return
}
Ejemplo n.º 2
0
func (d *RAMDirectory) LockID() string {
	return fmt.Sprintf("lucene-%v", util.ItoHex(int64(uintptr(unsafe.Pointer(&d)))))
}