Skip to content

Commit 9d007e4

Browse files
committed
docs: add warning regarding iterator buffer usage (fixes #258)
1 parent 2f17a33 commit 9d007e4

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

leveldb/db.go

+4
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) {
872872
// DB. And a nil Range.Limit is treated as a key after all keys in
873873
// the DB.
874874
//
875+
// WARNING: Any slice returned by interator (e.g. slice returned by calling
876+
// Iterator.Key() or Iterator.Key() methods), its content should not be modified
877+
// unless noted otherwise.
878+
//
875879
// The iterator must be released after use, by calling Release method.
876880
//
877881
// Also read Iterator documentation of the leveldb/iterator package.

leveldb/db_snapshot.go

+4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ func (snap *Snapshot) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)
142142
// DB. And a nil Range.Limit is treated as a key after all keys in
143143
// the DB.
144144
//
145+
// WARNING: Any slice returned by interator (e.g. slice returned by calling
146+
// Iterator.Key() or Iterator.Value() methods), its content should not be
147+
// modified unless noted otherwise.
148+
//
145149
// The iterator must be released after use, by calling Release method.
146150
// Releasing the snapshot doesn't mean releasing the iterator too, the
147151
// iterator would be still valid until released.

leveldb/db_transaction.go

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func (tr *Transaction) Has(key []byte, ro *opt.ReadOptions) (bool, error) {
6969
// DB. And a nil Range.Limit is treated as a key after all keys in
7070
// the DB.
7171
//
72+
// WARNING: Any slice returned by interator (e.g. slice returned by calling
73+
// Iterator.Key() or Iterator.Key() methods), its content should not be modified
74+
// unless noted otherwise.
75+
//
7276
// The iterator must be released after use, by calling Release method.
7377
//
7478
// Also read Iterator documentation of the leveldb/iterator package.

leveldb/memdb/memdb.go

+4
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ func (p *DB) Find(key []byte) (rkey, value []byte, err error) {
397397
// DB. And a nil Range.Limit is treated as a key after all keys in
398398
// the DB.
399399
//
400+
// WARNING: Any slice returned by interator (e.g. slice returned by calling
401+
// Iterator.Key() or Iterator.Key() methods), its content should not be modified
402+
// unless noted otherwise.
403+
//
400404
// The iterator must be released after use, by calling Release method.
401405
//
402406
// Also read Iterator documentation of the leveldb/iterator package.

leveldb/table/reader.go

+4
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,10 @@ func (r *Reader) getDataIterErr(dataBH blockHandle, slice *util.Range, verifyChe
787787
// table. And a nil Range.Limit is treated as a key after all keys in
788788
// the table.
789789
//
790+
// WARNING: Any slice returned by interator (e.g. slice returned by calling
791+
// Iterator.Key() or Iterator.Key() methods), its content should not be modified
792+
// unless noted otherwise.
793+
//
790794
// The returned iterator is not safe for concurrent use and should be released
791795
// after use.
792796
//

0 commit comments

Comments
 (0)