github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/getter.cc (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 #include "getter.h" 12 #include "status.h" 13 14 namespace cockroach { 15 16 DBStatus IteratorGetter::Get(DBString* value) { 17 if (base == NULL) { 18 value->data = NULL; 19 value->len = 0; 20 } else { 21 *value = ToDBString(base->value()); 22 } 23 return kSuccess; 24 } 25 26 DBStatus DBGetter::Get(DBString* value) { 27 std::string tmp; 28 rocksdb::Status s = rep->Get(options, key, &tmp); 29 if (!s.ok()) { 30 if (s.IsNotFound()) { 31 // This mirrors the logic in rocksdb_get(). It doesn't seem like 32 // a good idea, but some code in engine_test.go depends on it. 33 value->data = NULL; 34 value->len = 0; 35 return kSuccess; 36 } 37 return ToDBStatus(s); 38 } 39 *value = ToDBString(tmp); 40 return kSuccess; 41 } 42 43 } // namespace cockroach