Package convex.core.data
Class LongBlob
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<CVMByte>
convex.core.data.ABlob
convex.core.data.ALongBlob
convex.core.data.LongBlob
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ABlob>
Wrapper for an 8-byte long blob
We use this for efficient management of indexes using longs in BlobMaps.
-
Field Summary
FieldsFields inherited from class convex.core.data.ABlob
contentHash
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionlong
Computes the length of the longest common hex prefix between two blobsstatic LongBlob
create(long value)
static LongBlob
int
encode(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, including a tag byte which will be written firstint
encodeRaw(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, excluding the tag byteboolean
Determines if this Blob is equal to another Blob.boolean
equalsBytes(byte[] bytes, int byteOffset)
Tests if this Blob is equal to a subset of a byte arrayint
Estimate the encoded data size for this Cell.void
getBytes(byte[] dest, int destOffset)
Copies the bytes from this blob to a given destinationint
getHexDigit(long i)
Gets the specified hex digit from this data object.byte
getTag()
Gets the tag byte for this cell.long
hexMatchLength(ABlob b, long start, long length)
Returns the number of matching hex digits in the given hex range of another blob.boolean
Returns true if this Cell is in a canonical representation for message writing.boolean
Returns true if this object represents a first class CVM Value.boolean
Returns true if this object is a regular blob (i.e.long
Gets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exceptionslice(long start, long length)
Gets a contiguous slice of this blob, as a new Blob.toBlob()
Converts this object to a Blob instanceConverts this Cell to its canonical version.protected void
updateDigest(MessageDigest digest)
Methods inherited from class convex.core.data.ALongBlob
append, byteAt, calcMemorySize, count, createRef, equalsBytes, getByteBuffer, getChunk, getRefCount, getUnchecked, isEmbedded, toHexString, toHexString, toLong, writeToBuffer, writeToBuffer
Methods inherited from class convex.core.data.ABlob
compareTo, computeHash, empty, equals, get, getBytes, getContentHash, getElementRef, getType, hashCode, hexEquals, hexEquals, hexLength, print, slice, toByteBuffer, toHexString, validate, validateCell
Methods inherited from class convex.core.data.ACountable
isEmpty, size
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, createAnnounced, createEncoding, createPersisted, createPersisted, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, mark, mark, toString, updateRefs, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
-
Field Details
-
MAX_ENCODING_LENGTH
public static final int MAX_ENCODING_LENGTH- See Also:
- Constant Field Values
-
-
Method Details
-
create
-
create
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACell
Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures- Overrides:
isCVMValue
in classALongBlob
- Returns:
- true if the object is a CVM Value, false otherwise
-
getBytes
public void getBytes(byte[] dest, int destOffset)Description copied from class:ABlob
Copies the bytes from this blob to a given destination -
slice
Description copied from class:ABlob
Gets a contiguous slice of this blob, as a new Blob. Shares underlying backing data where possible -
toBlob
Description copied from class:ABlob
Converts this object to a Blob instance -
updateDigest
- Specified by:
updateDigest
in classABlob
-
getHexDigit
public int getHexDigit(long i)Description copied from class:ABlob
Gets the specified hex digit from this data object. Result is undefined if index is out of bounds.- Overrides:
getHexDigit
in classABlob
- Parameters:
i
- The position of the hex digit- Returns:
- The value of the hex digit, in the range 0-15 inclusive
-
commonHexPrefixLength
Description copied from class:ABlob
Computes the length of the longest common hex prefix between two blobs- Overrides:
commonHexPrefixLength
in classALongBlob
- Parameters:
b
- Blob to compare with- Returns:
- The length of the longest common prefix in hex digits
-
equals
Description copied from class:ABlob
Determines if this Blob is equal to another Blob. Blobs are defined to be equal if they have the same on-chain representation, i.e. if and only if all of the following are true: - Blob is of the same general type - Blobs are of the same length - All byte values are equal -
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- 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
-
encodeRaw
public int encodeRaw(byte[] bs, int pos)Description copied from class:ACell
Writes this Cell's encoding to a byte array, excluding the tag byte -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteable
Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.- Returns:
- The estimated size for the binary representation of this object.
-
longValue
public long longValue()Description copied from class:ABlob
Gets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exception -
hexMatchLength
Description copied from class:ABlob
Returns the number of matching hex digits in the given hex range of another blob. Assumes range is valid for both blobs. Returns length if this Blob is exactly equal to the specified hex range.- Overrides:
hexMatchLength
in classALongBlob
- Parameters:
b
- Blob to compare withstart
- Start position (in hex digits)length
- Length to compare (in hex digits)- Returns:
- The number of matching hex characters
-
isRegularBlob
public boolean isRegularBlob()Description copied from class:ABlob
Returns true if this object is a regular blob (i.e. not a special blob type like Address)- Overrides:
isRegularBlob
in classABlob
- Returns:
- True if a regular blob
-
getTag
public byte getTag()Description copied from class:ACell
Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding -
equalsBytes
public boolean equalsBytes(byte[] bytes, int byteOffset)Description copied from class:ABlob
Tests if this Blob is equal to a subset of a byte array- Specified by:
equalsBytes
in classABlob
- Parameters:
bytes
- Byte array to compare withbyteOffset
- Offset into byte array- Returns:
- true if exactly equal, false otherwise
-
isCanonical
public boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).- Overrides:
isCanonical
in classALongBlob
- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Returns this Cell if already canonical.- Specified by:
toCanonical
in classABlob
- Returns:
- Canonical version of Cell
-