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, valuesFields inherited from class convex.core.data.ARecord
DEFAULT_VALUEFields inherited from class convex.core.data.ADataStructure
countFields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Method Summary
Modifier and TypeMethodDescriptionstatic ResultbuildFromVector(AVector<ACell> values) static ResultCreate a Resultstatic ResultCreate a Resultstatic ResultCreate a Resultintencode(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.static Resultstatic ResultfromContext(CVMLong id, ResultContext rc) Constructs a Result from a Contextstatic ResultfromContext(Context ctx) Constructs a Result from a Context.static ResultReturns 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.bytegetTag()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.booleanisError()Tests is the Result represents an Errorstatic ResultReads a Result from a Blob encoding.voidValidates 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 ResultwithValues(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, updateRefsMethods 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, toHashMapMethods inherited from class convex.core.data.AMap
clear, conj, containsKey, containsKeyRef, containsValue, entryVector, filterValues, get, get, get, getElementRef, merge, print, put, putAll, remove, slice, sliceMethods inherited from class convex.core.data.ADataStructure
checkIndex, conjAll, count, isDataValue, isEmpty, size, toCVMStringMethods 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, validateMethods inherited from class convex.core.data.AObject
attachEncoding, print, printMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:ARecordGenericUpdates the record with a new set of values. Returns this if and only if values vector is identical.- Specified by:
withValuesin classARecordGeneric- Parameters:
newValues- New values to use- Returns:
- Updated Record
-
validateCell
Description copied from class:ACellValidates 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:
validateCellin classARecordGeneric- Throws:
InvalidDataException- If the Cell is invalid
-
encode
public int encode(byte[] bs, int pos) Description copied from class:ACellWrites 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:
encodein interfaceIWriteable- Specified by:
encodein 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:ARecordGets the tag byte for this record type. The Tag is the byte used to identify the record in the binary encoding.- Specified by:
getTagin classARecordGeneric- Returns:
- Record tag byte
-
getFormat
Description copied from class:ARecordGets the RecordFormat instance that describes this Record's layout -
fromException
-