Package convex.core.data
Class ALongBlob
java.lang.Object
- All Implemented Interfaces:
IValidated,IWriteable,Comparable<ABlobLike<?>>
- Direct Known Subclasses:
LongBlob
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intstatic final intprotected final longFields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ABlobAppend an additional Blob to this, creating a new Blob as needed.booleanappendHex(BlobBuilder bb, long length) Append hex string up to the given length in hex digits (a multiple of two)final bytebyteAt(long i) Gets the byte at the specified positionfinal bytebyteAtUnchecked(long i) Gets the byte at the specified position in this data object, possibly skipping bounds checking.protected final longCalculates the Memory Size for this Cell.protected intcompareTo(long bvalue) intCompares this Blob to another Blob, in lexicographic order sorting by first bytes (unsigned).Creates a new Ref for this Cellabstract booleanDetermines if this Blob is equal to another Blob.booleanequalsBytes(byte[] bytes, long byteOffset) Tests if the byte contents of this instance are equal to a subset of a byte arrayfinal booleanequalsBytes(ABlob b) Tests if this Blob has exactly the same bytes as another Blobfinal ByteBufferGets a byte buffer containing this Blob's raw data.final intgetBytes(byte[] bs, int pos) Copies the bytes from this instance to a given destination arrayfinal BlobgetChunk(long i) Gets a chunk of this Blob, as a canonical flat Blob up to the maximum Blob chunk size.intgetHexDigit(long i) Gets the specified hex digit from this data object.getRef(int i) Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.final longGets the length of this value in hex digitslongReturns the number of matching hex digits in the given hex range of another Blob.booleanReturns true if this Cell is in a canonical representation.booleanReturns true if this Blob is a fully packed set of chunksfinal booleanDetermines if this Cell Represents an embedded object.booleanReturns true if this is a fully packed set of chunksfinal longConverts this BlobLike to the corresponding long value.intread(long offset, long count, ByteBuffer dest) Gets bytes from this Blob into a ByteBufferabstract ABlobslice(long start, long end) Gets a contiguous slice of this Blob, as a new Blob.Converts this Cell to a canonical version.abstract BlobConverts the contents of this value to a flat array-backed Blob instance.updateRefs(IRefFunction func) Updates all Refs in this object using the given function.Methods inherited from class convex.core.data.ABlob
computeHash, count, empty, encode, encodeRaw, equals, get, getContentHash, getElementRef, getTag, getType, hashCode, isCVMValue, print, read, replaceSlice, shortAt, size, slice, toBlob, toByteBuffer, updateDigest, validate, validateCellMethods inherited from class convex.core.data.ABlobLike
getBytes, hexEquals, hexMatch, isDataValue, toHexString, toHexStringMethods inherited from class convex.core.data.ACountable
isEmptyMethods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, toCVMString, toStringMethods 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 convex.core.data.IWriteable
estimatedEncodingSize
-
Field Details
-
LENGTH
public static final int LENGTH- See Also:
-
HEX_LENGTH
protected static final int HEX_LENGTH- See Also:
-
value
protected final long value
-
-
Constructor Details
-
ALongBlob
protected ALongBlob(long value)
-
-
Method Details
-
hexLength
-
createRef
-
appendHex
Description copied from class:ABlobLikeAppend hex string up to the given length in hex digits (a multiple of two) -
getHexDigit
public int getHexDigit(long i) Description copied from class:ABlobLikeGets the specified hex digit from this data object. WARNING: Result is undefined if index is out of bounds, but probably an IndexOutOfBoundsException.- Overrides:
getHexDigitin classABlobLike<CVMLong>- Parameters:
i- The position of the hex digit- Returns:
- The value of the hex digit, in the range 0-15 inclusive
-
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:ABlobLikeConverts the contents of this value to a flat array-backed Blob instance. Warning: might be O(n) in size of Blob, may not be canonical etc.- Specified by:
toFlatBlobin classABlob- Returns:
- A Blob instance containing the same data as this value. Might be `this` if already a flat Blob.
-
byteAt
-
byteAtUnchecked
public final byte byteAtUnchecked(long i) Description copied from class:ABlobLikeGets the byte at the specified position in this data object, possibly skipping bounds checking. Only safe if index is known to be in bounds, otherwise result is undefined.- Overrides:
byteAtUncheckedin classABlobLike<CVMLong>- Parameters:
i- Index of the byte to get- Returns:
- The byte at the specified position
-
append
-
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 encoded representation, i.e. if and only if all of the following are true: - Blobs are of the same length - All byte values are equal -
getBytes
public final int getBytes(byte[] bs, int pos) Description copied from class:ABlobLikeCopies the bytes from this instance to a given destination array -
getChunk
Description copied from class:ABlobGets a chunk of this Blob, as a canonical flat Blob up to the maximum Blob chunk size. Returns empty Blob if and only if referencing the end of a Blob with fully packed chunks -
getByteBuffer
Description copied from class:ABlobGets a byte buffer containing this Blob's raw data. Will have remaining bytes equal to this Blob's size.- Specified by:
getByteBufferin classABlob- Returns:
- A ByteBuffer containing the Blob's data.
-
hexMatch
Description copied from class:ABlobLikeReturns 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. -
longValue
public final long longValue()Description copied from class:ABlobLikeConverts this BlobLike to the corresponding long value. Assumes big-endian format, as if the entire blob is interpreted as an unsigned big integer. Higher bytes outside the Long range will be ignored, i.e. the lowest 64 bits are taken -
compareTo
Description copied from class:ABlobCompares this Blob to another Blob, in lexicographic order sorting by first bytes (unsigned). Note: This means that compareTo does not precisely match equality, because specialised Blob types may be lexicographically equal but represent different values.- Specified by:
compareToin interfaceComparable<ABlobLike<?>>- Overrides:
compareToin classABlob
-
compareTo
protected int compareTo(long bvalue) -
equalsBytes
Description copied from class:ABlobTests if this Blob has exactly the same bytes as another Blob- Specified by:
equalsBytesin classABlob- Parameters:
b- Blob to compare with- Returns:
- True if byte content is exactly equal, false otherwise
-
equalsBytes
public boolean equalsBytes(byte[] bytes, long byteOffset) Description copied from class:ABlobTests if the byte contents of this instance are equal to a subset of a byte array- Specified by:
equalsBytesin classABlob- Parameters:
bytes- Byte array to compare withbyteOffset- Offset into byte array from which to start comparison- 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. Non-canonical objects may be used on a temporary internal basis, they should be converted to canonical representations for general purpose use.- Specified by:
isCanonicalin classACell- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts this Cell to a canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise. Callers should usually use getCanonical(), which caches canonical instances once created- Specified by:
toCanonicalin classABlob- Returns:
- Canonical version of Cell
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance -
updateRefs
Description copied from class:ACellUpdates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.- Overrides:
updateRefsin classACell- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
getRefCount
public int getRefCount()Description copied from class:ACellGets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. Contained Refs may be either external or embedded.- Overrides:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
isEmbedded
public final boolean isEmbedded()Description copied from class:ACellDetermines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.- Overrides:
isEmbeddedin classACell- Returns:
- true if Cell is embedded, false otherwise
-
calcMemorySize
protected final long calcMemorySize()Description copied from class:ACellCalculates the Memory Size for this Cell. Assumes not already calculated Requires any child Refs to be either direct or of persisted in store at minimum, or you might get a MissingDataException- Overrides:
calcMemorySizein classACell- Returns:
- Memory Size of this Cell
-
isChunkPacked
public boolean isChunkPacked()Description copied from class:ABlobReturns true if this Blob is a fully packed set of chunks- Overrides:
isChunkPackedin classABlob- Returns:
- True if fully packed, false otherwise
-
isFullyPacked
public boolean isFullyPacked()Description copied from class:ABlobReturns true if this is a fully packed set of chunks- Specified by:
isFullyPackedin classABlob- Returns:
- True if fully packed, false otherwise
-
read
Description copied from class:ABlobGets bytes from this Blob into a ByteBuffer
-