func (cdb *Writer) Put(key, value []byte) error {
	if key == nil || value == nil {
		return fmt.Errorf("key or value can not be nil.")
	}
	entrySize := int64(16 + len(key) + len(value))

	// Record the entry in the hash table, to be written out at the end.
	cdb.hasher.Reset()
	cdb.hasher.Write(key)
	hash := cdb.hasher.Sum64()
	table := hash & 0xff

	entry := entry{hash: hash, offset: uint64(cdb.bufferedOffset)}
	cdb.entries[table] = append(cdb.entries[table], entry)

	// Write the key length, then value length, then key, then value.
	err := writeTuple(cdb.bufferedWriter, uint64(len(key)), uint64(len(value)))
	if err != nil {
		return err
	}

	_, err = cdb.bufferedWriter.Write(key)
	if err != nil {
		return err
	}

	_, err = cdb.bufferedWriter.Write(value)
	if err != nil {
		return err
	}

	cdb.bufferedOffset += entrySize
	cdb.estimatedFooterSize += 32
	return nil
}
// Put adds a key/value pair to the database.
Put adds a key/value pair to the database.
// Put adds a key / value pair to the database .
func (cdb *Writer) Put(key, value []byte) error {
	if key == nil || value == nil {
		return fmt.Errorf("key or value can not be nil.")
	}
	entrySize := int64(16 + len(key) + len(value))
	cdb.hasher.Reset()
	cdb.hasher.Write(key)
	hash := cdb.hasher.Sum64()
	table := hash & 0xff
	entry := entry{hash: hash, offset: uint64(cdb.bufferedOffset)}
	cdb.entries[table] = append(cdb.entries[table], entry)
	err := writeTuple(cdb.bufferedWriter, uint64(len(key)), uint64(len(value)))
	if err != nil {
		return err
	}
	_, err = cdb.bufferedWriter.Write(key)
	if err != nil {
		return err
	}
	_, err = cdb.bufferedWriter.Write(value)
	if err != nil {
		return err
	}
	cdb.bufferedOffset += entrySize
	cdb.estimatedFooterSize += 32
	return nil
}
func ( cdb * Writer ) Put ( key , value [ ] byte ) error { if key == nil || value == nil { return fmt . Errorf ( " " ) } entrySize := int64 ( 16 + len ( key ) + len ( value ) ) cdb . hasher . Reset ( ) cdb . hasher . Write ( key ) hash := cdb . hasher . Sum64 ( ) table := hash & 0xff entry := entry { hash : hash , offset : uint64 ( cdb . bufferedOffset ) } cdb . entries [ table ] = append ( cdb . entries [ table ] , entry ) err := writeTuple ( cdb . bufferedWriter , uint64 ( len ( key ) ) , uint64 ( len ( value ) ) ) if err != nil { return err } _ , err = cdb . bufferedWriter . Write ( key ) if err != nil { return err } _ , err = cdb . bufferedWriter . Write ( value ) if err != nil { return err } cdb . bufferedOffset += entrySize cdb . estimatedFooterSize += 32 return nil }
Put adds a key/value pair to the database.
Put adds a key / value pair to the database .
// Record the entry in the hash table, to be written out at the end. // Write the key length, then value length, then key, then value.