@Name(value="arrow::Result<arrow::util::optional<arrow::dataset::KeyValuePartitioning::Key> >") @NoOffset @Properties(inherit=arrow_dataset.class) public class KeyOptionalResult extends Pointer
T
or a Status object
explaining why such a value is not present. The type T
must be
copy-constructible and/or move-constructible.
The state of a Result object may be determined by calling ok() or
status(). The ok() method returns true if the object contains a valid value.
The status() method returns the internal Status object. A Result object
that contains a valid value will return an OK Status for a call to status().
A value of type T
may be extracted from a Result object through a call
to ValueOrDie(). This function should only be called if a call to ok()
returns true. Sample usage:
arrow::Result<Foo> result = CalculateFoo();
if (result.ok()) {
Foo foo = result.ValueOrDie();
foo.DoSomethingCool();
} else {
ARROW_LOG(ERROR) << result.status();
}
If T
is a move-only type, like std::unique_ptr<>
, then the value should
only be extracted after invoking std::move()
on the Result object.
Sample usage:
arrow::Result<std::unique_ptr<Foo>> result = CalculateFoo();
if (result.ok()) {
std::unique_ptr<Foo> foo = std::move(result).ValueOrDie();
foo->DoSomethingCool();
} else {
ARROW_LOG(ERROR) << result.status();
}
Result is provided for the convenience of implementing functions that
return some value but may fail during execution. For instance, consider a
function with the following signature:
arrow::Status CalculateFoo(int *output);
This function may instead be written as:
arrow::Result<int> CalculateFoo();
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
KeyOptionalResult()
Constructs a Result object that contains a non-OK status.
|
KeyOptionalResult(KeyOptional value)
Constructs a Result object that contains
value . |
KeyOptionalResult(KeyOptionalResult other)
Copy constructor.
|
KeyOptionalResult(long size)
Native array allocator.
|
KeyOptionalResult(Pointer p)
Pointer cast constructor.
|
KeyOptionalResult(Status status)
Constructs a Result object with the given non-OK Status object.
|
Modifier and Type | Method and Description |
---|---|
KeyOptional |
access() |
boolean |
Equals(KeyOptionalResult other)
Compare to another Result.
|
KeyOptionalResult |
getPointer(long i) |
KeyOptional |
MoveValueUnsafe() |
KeyOptional |
multiply() |
boolean |
ok()
Indicates whether the object contains a
T value. |
KeyOptionalResult |
position(long position) |
KeyOptionalResult |
put(KeyOptionalResult other)
Copy-assignment operator.
|
Status |
status()
Gets the stored status object, or an OK status if a
T value is stored. |
KeyOptional |
ValueOrDie()
Gets a mutable reference to the stored
T value. |
KeyOptional |
ValueUnsafe()
Cast the internally stored value to produce a new result or propagate the stored
error.
|
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public KeyOptionalResult(Pointer p)
Pointer(Pointer)
.public KeyOptionalResult(long size)
Pointer.position(long)
.public KeyOptionalResult()
explicit
to prevent attempts to return {}
from a function with a return type of, for example,
Result<std::vector<int>>
. While return {}
seems like it would return
an empty vector, it will actually invoke the default constructor of
Result.public KeyOptionalResult(@Const @ByRef Status status)
status
must
not be an OK status, otherwise this constructor will abort.
This constructor is not declared explicit so that a function with a return
type of Result<T>
can return a Status object, and the status will be
implicitly converted to the appropriate return type as a matter of
convenience.status
- The non-OK Status object to initialize to.public KeyOptionalResult(@ByRef(value=true) KeyOptional value)
value
. The resulting object
is considered to have an OK status. The wrapped element can be accessed
with ValueOrDie().
This constructor is made implicit so that a function with a return type of
Result<T>
can return an object of type T
, implicitly converting
it to a Result<T>
object.value
- The value to initialize to.public KeyOptionalResult(@Const @ByRef KeyOptionalResult other)
Result
object results in a compilation error.other
- The value to copy from.public KeyOptionalResult position(long position)
public KeyOptionalResult getPointer(long i)
getPointer
in class Pointer
@ByRef @Name(value="operator =") @NoException(value=true) public KeyOptionalResult put(@Const @ByRef KeyOptionalResult other)
other
- The Result object to copy.@Cast(value="bool") public boolean Equals(@Const @ByRef KeyOptionalResult other)
@Cast(value="const bool") public boolean ok()
T
value. Generally instead
of accessing this directly you will want to use ASSIGN_OR_RAISE defined
below.@Const @ByRef public Status status()
T
value is stored.
/**
/** @return The stored non-OK status object, or an OK status if this object
/** has a value.@ByRef public KeyOptional ValueOrDie()
T
value.
This method should only be called if this Result object's status is OK
(i.e. a call to ok() returns true), otherwise this call will abort.T
value.@ByRef @Name(value="operator *") public KeyOptional multiply()
@Name(value="operator ->") public KeyOptional access()
@Const @ByRef public KeyOptional ValueUnsafe()
@ByVal public KeyOptional MoveValueUnsafe()
Copyright © 2022. All rights reserved.