func (connection *RocksDbConnection) Get(options *proto.DbReadOptions, key []byte) ([]byte, error) { ro := ratgo.NewReadOptions() defer ro.Close() if options != nil { ro.SetFillCache(options.FillCache) ro.SetVerifyChecksums(options.VerifyChecksum) if options.Snapshot != nil { rocksdbSnapshot := options.Snapshot.Snapshot.(*ratgo.Snapshot) ro.SetSnapshot(rocksdbSnapshot) } } return connection.db.Get(ro, key) }
func (connection *RocksDbConnection) Gets(options *proto.DbReadOptions, keys [][]byte) ([][]byte, error) { ro := ratgo.NewReadOptions() defer ro.Close() if options != nil { ro.SetFillCache(options.FillCache) ro.SetVerifyChecksums(options.VerifyChecksum) if options.Snapshot != nil { rocksdbSnapshot := options.Snapshot.Snapshot.(*ratgo.Snapshot) ro.SetSnapshot(rocksdbSnapshot) } } results, errors := connection.db.MultiGet(ro, keys) for _, err := range errors { if err != nil { log.Error("Get Key:%v error, error", err) return nil, err } } return results, nil }
func (connection *RocksDbConnection) Iterate(options *proto.DbReadOptions, start []byte, end []byte, limit int) (proto.DbCursor, error) { ro := ratgo.NewReadOptions() if options != nil { ro.SetFillCache(options.FillCache) ro.SetVerifyChecksums(options.VerifyChecksum) } defer ro.Close() cursor := new(RocksDbCursor) cursor.start = start cursor.end = end if limit == 0 { cursor.limit = int(math.MaxInt32) } else { cursor.limit = limit } cursor.iter = connection.db.NewIterator(ro) cursor.isClosed = false if start != nil { cursor.iter.Seek(start) } return cursor, nil }