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 as a Blob
We use this mainly for efficient management of indexes using Longs in BlobMaps.
-
Field Summary
FieldsFields inherited from class convex.core.data.ALongBlob
HEX_LENGTH, LENGTH, valueFields 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 first.intencodeRaw(byte[] bs, int pos)Writes this Blob'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 destinationbytegetTag()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 representation for message writing.longGets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exceptionslice(long start, long end)Gets a contiguous slice of this Blob, as a new Blob.Converts this Cell to its canonical version.Converts this object to a flat array-backed Blob instance.protected voidupdateDigest(MessageDigest digest)Methods inherited from class convex.core.data.ALongBlob
append, appendHex, byteAt, calcMemorySize, compareTo, compareTo, count, createRef, equalsBytes, getByteBuffer, getChunk, getHexDigit, getRefCount, getUnchecked, isEmbedded, toLong, writeToBuffer, writeToBufferMethods inherited from class convex.core.data.ABlob
computeHash, empty, encodeRawData, equals, get, getBytes, getContentHash, getElementRef, getType, hashCode, hexEquals, hexEquals, hexLength, isCVMValue, isRegularBlob, print, slice, toByteBuffer, toHexString, 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, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, isCompletelyEncoded, mark, mark, toCVMString, toString, updateRefs, writeMethods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
MAX_ENCODING_LENGTH
public static final int MAX_ENCODING_LENGTH- See Also:
- Constant Field Values
-
ZERO
-
-
Method Details
-
create
-
create
-
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 -
toFlatBlob
Description copied from class:ABlobConverts this object to a flat array-backed Blob instance. Warning: might be O(n) in size of Blob, may not be canonical etc.- Specified by:
toFlatBlobin classALongBlob- Returns:
- A Blob instance containing the same data as this Blob.
-
updateDigest
- Specified by:
updateDigestin classABlob
-
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. 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
-
encodeRaw
public int encodeRaw(byte[] bs, int pos)Description copied from class:ABlobWrites this Blob'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
-
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 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:
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 Cell if already canonical, may be O(n) in size of value otherwise.- Specified by:
toCanonicalin classABlob- Returns:
- Canonical version of Cell
-