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
Fields inherited from class convex.core.data.ABlob
contentHashFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionlongComputes the length of the longest common hex prefix between two blobsstatic LongBlobcreate(long value)static LongBlobintencode(byte[] bs, int pos)Writes this Cell's encoding to a byte array, including a tag byte which will be written firstintencodeRaw(byte[] bs, int pos)Writes this Cell's encoding to a byte array, excluding the tag bytebooleanDetermines if this Blob is equal to another Blob.booleanequalsBytes(byte[] bytes, int byteOffset)Tests if this Blob is equal to a subset of a byte arrayintEstimate the encoded data size for this Cell.voidgetBytes(byte[] dest, int destOffset)Copies the bytes from this blob to a given destinationintgetHexDigit(long i)Gets the specified hex digit from this data object.bytegetTag()Gets the tag byte for this cell.longhexMatchLength(ABlob b, long start, long length)Returns the number of matching hex digits in the given hex range of another blob.booleanReturns true if this Cell is in a canonical format for message writing.booleanReturns true if this object represents a first class CVM Value.booleanReturns true if this object is a regular blob (i.e.longGets 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 voidupdateDigest(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, writeToBufferMethods 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, validateCellMethods inherited from class convex.core.data.ACountable
isEmpty, sizeMethods 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, toString, updateRefs, writeMethods inherited from class convex.core.data.AObject
attachEncoding, print
-
Method Details
-
create
-
create
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns 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:
isCVMValuein classALongBlob- Returns:
- true if the object is a CVM Value, false otherwise
-
getBytes
public void getBytes(byte[] dest, int destOffset)Description copied from class:ABlobCopies the bytes from this blob to a given destination -
slice
Description copied from class:ABlobGets a contiguous slice of this blob, as a new Blob. Shares underlying backing data where possible -
toBlob
Description copied from class:ABlobConverts this object to a Blob instance -
updateDigest
- Specified by:
updateDigestin classABlob
-
getHexDigit
public int getHexDigit(long i)Description copied from class:ABlobGets the specified hex digit from this data object. Result is undefined if index is out of bounds.- Overrides:
getHexDigitin 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:ABlobComputes the length of the longest common hex prefix between two blobs- Overrides:
commonHexPrefixLengthin classALongBlob- Parameters:
b- Blob to compare with- Returns:
- The length of the longest common prefix in hex digits
-
equals
Description copied from class:ABlobDetermines 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:ACellWrites this Cell's encoding to a byte array, including a tag byte which will be written first- 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
-
encodeRaw
public int encodeRaw(byte[] bs, int pos)Description copied from class:ACellWrites this Cell's encoding to a byte array, excluding the tag byte -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteableEstimate 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:ABlobGets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exception -
hexMatchLength
Description copied from class:ABlobReturns 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:
hexMatchLengthin 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:ABlobReturns true if this object is a regular blob (i.e. not a special blob type like Hash or Address)- Overrides:
isRegularBlobin classABlob- Returns:
- True if a regular blob
-
getTag
public byte getTag()Description copied from class:ACellGets 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:ABlobTests if this Blob is equal to a subset of a byte array- Specified by:
equalsBytesin 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:ACellReturns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.- Overrides:
isCanonicalin classALongBlob- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Returns this if already canonical- Specified by:
toCanonicalin classABlob- Returns:
- Canonical version of Cell
-