Skip to content

Commit 712d12d

Browse files
laramielcopybara-github
authored andcommitted
Update tensorstore::Result with some tricks from absl::StatusOr
The main changes are: * The internal absl::Status is now in a union to do explicit initialization, which omits some double initialization paths, and the default constructor of the internal storage type is deleted. * More functions have lifetime annotations. absl::StatusOr has some lifetime-based template annotations which are not included here. * Some slight restructuring of construction and assignment. PiperOrigin-RevId: 808685870 Change-Id: I7b3709fe0201cbb3c538c04506a3c69745dbb127
1 parent 2df32d5 commit 712d12d

File tree

7 files changed

+380
-193
lines changed

7 files changed

+380
-193
lines changed

docs/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ def _python_type_to_xref(
362362
'object_type': 'class',
363363
'desc': 'C++ class',
364364
},
365+
'absl::Status::ok': {
366+
'url': 'https://abseil.io/docs/cpp/guides/status#checking-errors',
367+
'object_type': 'function',
368+
'desc': 'C++ class',
369+
},
365370
'absl::StatusOr': {
366371
'url': (
367372
'https://abseil.io/docs/cpp/guides/status#returning-a-status-or-a-value'
@@ -426,6 +431,11 @@ def _python_type_to_xref(
426431
'object_type': 'class',
427432
'desc': 'C++ class',
428433
},
434+
'std::move': {
435+
'url': 'https://en.cppreference.com/w/cpp/utility/move.html',
436+
'object_type': 'function',
437+
'desc': 'C++ function',
438+
},
429439
}
430440

431441
for code in [

tensorstore/kvstore/ocdbt/format/data_file_id_codec.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,26 @@
1414

1515
#include "tensorstore/kvstore/ocdbt/format/data_file_id_codec.h"
1616

17+
#include <stddef.h>
18+
#include <stdint.h>
19+
1720
#include <algorithm>
21+
#include <cassert>
22+
#include <cstring>
1823
#include <string_view>
24+
#include <utility>
1925
#include <vector>
2026

2127
#include "absl/container/flat_hash_map.h"
28+
#include "absl/log/absl_check.h"
29+
#include "absl/status/status.h"
30+
#include "absl/strings/str_format.h"
2231
#include "riegeli/bytes/reader.h"
2332
#include "riegeli/bytes/writer.h"
2433
#include "riegeli/varint/varint_reading.h"
2534
#include "riegeli/varint/varint_writing.h"
2635
#include "tensorstore/internal/ref_counted_string.h"
36+
#include "tensorstore/kvstore/ocdbt/format/codec_util.h"
2737
#include "tensorstore/kvstore/ocdbt/format/data_file_id.h"
2838

2939
namespace tensorstore {

tensorstore/util/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ tensorstore_cc_test(
523523

524524
tensorstore_cc_library(
525525
name = "result",
526+
srcs = ["result_impl.cc"],
526527
hdrs = [
527528
"result.h",
528529
"result_impl.h",
@@ -534,8 +535,7 @@ tensorstore_cc_library(
534535
"//tensorstore/internal/preprocessor:cat",
535536
"//tensorstore/internal/preprocessor:expand",
536537
"@abseil-cpp//absl/base:core_headers",
537-
"@abseil-cpp//absl/log:absl_check",
538-
"@abseil-cpp//absl/log:absl_log",
538+
"@abseil-cpp//absl/base:nullability",
539539
"@abseil-cpp//absl/meta:type_traits",
540540
"@abseil-cpp//absl/status",
541541
],

0 commit comments

Comments
 (0)