Package convex.core
Class Result
- All Implemented Interfaces:
IAssociative<Keyword,
,ACell> IValidated
,IWriteable
,Map<Keyword,
ACell>
Class representing the result of a Query or Transaction.
A Result is typically used to communicate the outcome of a Query or a Transaction from a Peer to a Client.
Contains:
- Message ID
- Result value
- Error Code
- Log Records
- Additional info
-
Nested Class Summary
-
Field Summary
Fields inherited from class convex.core.data.ARecordGeneric
format, values
Fields inherited from class convex.core.data.ARecord
DEFAULT_VALUE
Fields inherited from class convex.core.data.ADataStructure
count
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Method Summary
Modifier and TypeMethodDescriptionstatic Result
buildFromVector
(AVector<ACell> values) static Result
Create a Resultstatic Result
Create a Resultstatic Result
Create a Resultint
encode
(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.static Result
static Result
fromContext
(CVMLong id, ResultContext rc) Constructs a Result from a Contextstatic Result
fromContext
(Context ctx) Constructs a Result from a Context.static Result
Returns the Error Code from this Result.Gets the RecordFormat instance that describes this Record's layoutgetID()
Returns the message ID for this result.getInfo()
Returns the info for this Result.getLog()
Returns the log for this Result.byte
getTag()
Gets the tag byte for this record type.getTrace()
Returns the stack trace for this result.<T extends ACell>
TgetValue()
Returns the value for this result.boolean
isError()
Tests is the Result represents an Errorstatic Result
Reads a Result from a Blob encoding.void
Validates the local structure and invariants of this cell.values()
Gets a vector of values for this Record, in format-determined orderwithExtraInfo
(Map<Keyword, ACell> extInfo) Updates result with a given message ID.protected Result
withValues
(AVector<ACell> newValues) Updates the record with a new set of values.Methods inherited from class convex.core.data.ARecordGeneric
encodeRaw, entryAt, equals, equals, get, getRef, getRefCount, updateRefs
Methods inherited from class convex.core.data.ARecord
accumulateEntrySet, accumulateKeySet, accumulateValues, assoc, assocEntry, containsKey, containsValue, dissoc, dissoc, empty, entrySet, estimatedEncodingSize, forEach, get, getEntry, getEntryByHash, getKeyRefEntry, getKeys, getType, getValuesArray, isCanonical, isCVMValue, keySet, reduceEntries, reduceValues, toCanonical, toHashMap
Methods inherited from class convex.core.data.AMap
clear, conj, containsKey, containsKeyRef, containsValue, entryVector, filterValues, get, get, get, getElementRef, merge, print, put, putAll, remove, slice, slice
Methods inherited from class convex.core.data.ADataStructure
checkIndex, conjAll, count, isDataValue, isEmpty, size, toCVMString
Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createEncoding, createRef, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, hashCode, isEmbedded, toString, validate
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Method Details
-
buildFromVector
-
create
-
create
-
create
-
error
-
getID
Returns the message ID for this result. Message ID is an arbitrary ID assigned by a client requesting a transaction.- Returns:
- ID from this result
-
getValue
Returns the value for this result. The value is the result of transaction execution (may be an error message if the transaction failed)- Type Parameters:
T
- Type of Value- Returns:
- ID from this result
-
getTrace
-
getInfo
-
getLog
-
getErrorCode
Returns the Error Code from this Result. Normally this should be a Keyword. Will be null if no error occurred.- Returns:
- ID from this result
-
values
-
withValues
Description copied from class:ARecordGeneric
Updates the record with a new set of values. Returns this if and only if values vector is identical.- Specified by:
withValues
in classARecordGeneric
- Parameters:
newValues
- New values to use- Returns:
- Updated Record
-
validateCell
Description copied from class:ACell
Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.- Overrides:
validateCell
in classARecordGeneric
- Throws:
InvalidDataException
- If the Cell is invalid
-
encode
public int encode(byte[] bs, int pos) Description copied from class:ACell
Writes this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.- Specified by:
encode
in interfaceIWriteable
- Specified by:
encode
in classACell
- Parameters:
bs
- A byte array to which to write the encodingpos
- The offset into the byte array- Returns:
- New position after writing
-
read
Reads a Result from a Blob encoding. Assumes tag byte already checked.- Parameters:
b
- Blob to read frompos
- Start position in Blob (location of tag byte)- Returns:
- New decoded instance
- Throws:
BadFormatException
- In the event of any encoding error
-
isError
public boolean isError()Tests is the Result represents an Error- Returns:
- True if error, false otherwise
-
fromContext
Constructs a Result from a Context- Parameters:
id
- Id for Resultrc
- ResultContext instance from which to extract Result- Returns:
- New Result instance
-
withExtraInfo
-
fromContext
-
withID
-
getTag
public byte getTag()Description copied from class:ARecord
Gets the tag byte for this record type. The Tag is the byte used to identify the record in the binary encoding.- Specified by:
getTag
in classARecordGeneric
- Returns:
- Record tag byte
-
getFormat
Description copied from class:ARecord
Gets the RecordFormat instance that describes this Record's layout -
fromException
-