public class HashWire extends Object implements WireOut, net.openhft.chronicle.bytes.HexDumpBytesDescription
HashWire class is responsible for generating hash values from provided objects or WriteMarshallable instances.
This class provides a consistent hashing mechanism by leveraging a predefined set of constants and algorithms.
Instances are stored in a ThreadLocal to ensure thread-safety and optimized access across the application.
WriteMarshallableWireOut.EndOfWire| Constructor and Description |
|---|
HashWire() |
| Modifier and Type | Method and Description |
|---|---|
DocumentContext |
acquireWritingDocument(boolean metaData)
Retrieves a context for writing either data or metadata, reusing an existing context if available.
|
@NotNull WireOut |
addPadding(int paddingToAdd)
Adds padding to the wire.
|
@NotNull net.openhft.chronicle.bytes.Bytes<?> |
bytes()
Returns the underlying
Bytes stored by the wire. |
net.openhft.chronicle.bytes.HexDumpBytesDescription<?> |
bytesComment()
Returns the bytes() but only for comment.
|
net.openhft.chronicle.core.pool.ClassLookup |
classLookup()
Returns the current
ClassLookup implementation being used for class lookup. |
void |
classLookup(net.openhft.chronicle.core.pool.ClassLookup classLookup)
Sets the
ClassLookup implementation to be used for class lookup. |
void |
clear()
Resets both the positions in the wire and the header number.
|
long |
enterHeader(long safeLength)
INTERNAL METHOD, call writingDocument instead
|
@NotNull ValueOut |
getValueOut()
Retrieves the interface for defining the output of a value
that will be written to the stream.
|
int |
hash32()
Computes and returns the 32-bit hash value.
|
static int |
hash32(Object value)
Computes a 32-bit hash for the provided object.
|
static int |
hash32(WriteMarshallable value)
Computes a 32-bit hash for the provided
WriteMarshallable value. |
long |
hash64()
Computes and returns the 64-bit hash value.
|
static long |
hash64(Object value)
Computes a 64-bit hash for the provided object.
|
static long |
hash64(WriteMarshallable value)
Computes a 64-bit hash for the provided
WriteMarshallable value. |
long |
headerNumber() |
@NotNull WireOut |
headerNumber(long headerNumber) |
boolean |
isBinary()
Determine whether direct access to the underlying byte() makes sense or should it be treated as text
|
@NotNull net.openhft.chronicle.core.values.BooleanValue |
newBooleanReference()
Creates and returns a new
BooleanValue. |
@NotNull net.openhft.chronicle.core.values.IntArrayValues |
newIntArrayReference()
Creates and returns a new
IntArrayValues. |
@NotNull net.openhft.chronicle.core.values.IntValue |
newIntReference()
Creates and returns a new
IntValue. |
@NotNull net.openhft.chronicle.core.values.LongArrayValues |
newLongArrayReference()
Creates and returns a new
LongArrayValues. |
@NotNull net.openhft.chronicle.core.values.LongValue |
newLongReference()
Creates and returns a new
LongValue. |
@NotNull ObjectOutput |
objectOutput()
Get the ObjectOutput associated with this WireOut.
|
@Nullable Object |
parent()
Returns the wire parent object.
|
void |
parent(Object parent)
Assigns the wire parent object for later retrieval.
|
@NotNull net.openhft.chronicle.threads.Pauser |
pauser()
Returns the current
Pauser implementation being used for blocking operations. |
void |
pauser(net.openhft.chronicle.threads.Pauser pauser)
Sets the
Pauser implementation to be used for blocking operations. |
void |
reset()
Reset the state of the wire
|
void |
updateFirstHeader()
INTERNAL METHOD, call writingDocument instead
|
void |
updateFirstHeader(long headerLen)
INTERNAL METHOD, call writingDocument instead
|
void |
updateHeader(long position,
boolean metaData,
int expectedHeader)
INTERNAL METHOD, call writingDocument instead
|
boolean |
usePadding() |
void |
usePadding(boolean usePadding) |
boolean |
useSelfDescribingMessage(@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
Should this wire write the object as a Marshallable or BytesMarshallable
|
@NotNull ValueOut |
write()
Writes an empty field marker to the stream.
|
@NotNull ValueOut |
write(@NotNull CharSequence name)
Writes a CharSequence key to the stream.
|
@NotNull ValueOut |
write(@NotNull WireKey key)
Writes a WireKey to the stream.
|
@NotNull WireOut |
writeComment(CharSequence s)
Writes a comment to the wire.
|
void |
writeEndEvent() |
boolean |
writeEndOfWire(long timeout,
TimeUnit timeUnit,
long lastPosition)
Write the end of wire marker, unless one is already written.
|
@NotNull ValueOut |
writeEvent(Class<?> ignored,
@NotNull Object eventKey)
Writes an event to the stream based on the type and event key.
|
boolean |
writeFirstHeader()
INTERNAL METHOD, call writingDocument instead
|
void |
writeStartEvent()
Start an event object, mostly for internal use.
|
@NotNull DocumentContext |
writingDocument(boolean metaData)
Starts the process of writing a document to the wire with an option for metadata.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdropDefault, endOfWire, padToCacheAlign, writeAlignTo, writeAllAsMap, writeDocument, writeEventId, writeEventId, writeEventName, writeEventName, writeNotCompleteDocument, writingDocument, writingIsCompletenewTwoLongReference, notCompleteIsNotPresent, notCompleteIsNotPresentbuilder, methodWriter, methodWriterBuilder, methodWriterBuilder, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeMessage, writeTextrollbackIfNotCompletepublic static long hash64(WriteMarshallable value)
WriteMarshallable value.value - The WriteMarshallable value to be hashed.public static long hash64(Object value)
value - The object to be hashed.public static int hash32(WriteMarshallable value)
WriteMarshallable value.value - The WriteMarshallable value to be hashed.public static int hash32(Object value)
value - The object to be hashed.public void classLookup(net.openhft.chronicle.core.pool.ClassLookup classLookup)
WireCommonClassLookup implementation to be used for class lookup.classLookup in interface WireCommonclassLookup - implementation to be used for class lookup.public net.openhft.chronicle.core.pool.ClassLookup classLookup()
WireCommonClassLookup implementation being used for class lookup.classLookup in interface WireCommonClassLookup implementation being used for class lookuppublic void clear()
WireOutclear in interface WireCommonclear in interface WireOutpublic void reset()
WireCommonreset in interface WireCommon@Nullable public @Nullable Object parent()
WireCommonnull is
returned instead.parent in interface WireCommonnull if none was assigned.public void parent(Object parent)
WireCommonparent in interface WireCommonparent - to set, or null if there isn't one.public void usePadding(boolean usePadding)
usePadding in interface WireCommonpublic boolean usePadding()
usePadding in interface WireCommonpublic long hash64()
This method uses the current hash value and applies an agitation function to provide a consistent and dispersed 64-bit hash result.
public int hash32()
This method derives the 32-bit hash from the 64-bit hash value. The derived hash is the result of XOR-ing the high and low 32-bits of the 64-bit hash.
@NotNull public @NotNull ValueOut write()
WireOut@NotNull public @NotNull ValueOut write(@NotNull @NotNull WireKey key)
WireOut@NotNull public @NotNull ValueOut write(@NotNull @NotNull CharSequence name)
WireOut@NotNull public @NotNull ValueOut writeEvent(Class<?> ignored, @NotNull @NotNull Object eventKey)
WireOutwriteEvent in interface WireOutignored - The expected type of the event to write.eventKey - The key of the event.public void writeStartEvent()
WireOutwriteStartEvent in interface WireOutpublic void writeEndEvent()
writeEndEvent in interface WireOut@NotNull public @NotNull ValueOut getValueOut()
WireOutgetValueOut in interface WireOut@NotNull public @NotNull ObjectOutput objectOutput()
WireOutobjectOutput in interface WireOut@NotNull public @NotNull WireOut writeComment(CharSequence s)
WireOutwriteComment in interface WireOuts - The comment to be written to the stream.@NotNull public @NotNull WireOut addPadding(int paddingToAdd)
WireOutaddPadding in interface WireOutpaddingToAdd - The amount of padding to add.@NotNull public @NotNull WireOut headerNumber(long headerNumber)
headerNumber in interface WireCommonpublic long headerNumber()
headerNumber in interface WireCommon@NotNull public @NotNull DocumentContext writingDocument(boolean metaData)
WireOutwritingDocument in interface DocumentWrittenwritingDocument in interface MarshallableOutwritingDocument in interface WireOutmetaData - If true, the returned document context will be used for writing metadata.public DocumentContext acquireWritingDocument(boolean metaData)
WireOutacquireWritingDocument in interface DocumentWrittenacquireWritingDocument in interface MarshallableOutacquireWritingDocument in interface WireOutmetaData - If true, the returned context will be used for writing metadata.public long enterHeader(long safeLength)
WireOutStart a header for a document
enterHeader in interface WireOutsafeLength - ensure there is at least this much spacepublic void updateHeader(long position,
boolean metaData,
int expectedHeader)
WireOutUpdate/end a header for a document
updateHeader in interface WireOutpublic boolean writeFirstHeader()
WireOutStart the first header, if there is none This will increment the headerNumber as appropriate if successful
Note: the file might contain other data and the caller has to check this.
writeFirstHeader in interface WireOutpublic void updateFirstHeader()
WireOutupdate the first header after writing.
updateFirstHeader in interface WireOutpublic void updateFirstHeader(long headerLen)
WireOut
update the first header after writing headerEndPos bytes.
updateFirstHeader in interface WireOutpublic boolean writeEndOfWire(long timeout,
TimeUnit timeUnit,
long lastPosition)
WireOutwriteEndOfWire in interface WireOuttimeout - throw TimeoutException if it could not write the marker in time.timeUnit - of the timeoutlastPosition - the end of the wirefalse if it was already there.@NotNull public @NotNull net.openhft.chronicle.bytes.Bytes<?> bytes()
WireCommonBytes stored by the wire.bytes in interface WireCommonBytes stored by the wirepublic net.openhft.chronicle.bytes.HexDumpBytesDescription<?> bytesComment()
WireCommonbytesComment in interface WireCommon@NotNull public @NotNull net.openhft.chronicle.core.values.IntValue newIntReference()
WireCommonIntValue. The IntValue implementation that is
returned depends on the wire implementation.newIntReference in interface WireCommonIntValue.@NotNull public @NotNull net.openhft.chronicle.core.values.LongValue newLongReference()
WireCommonLongValue. The LongValue implementation that is
returned depends on the wire implementation.newLongReference in interface WireCommonLongValue@NotNull public @NotNull net.openhft.chronicle.core.values.BooleanValue newBooleanReference()
WireCommonBooleanValue. The BooleanValue implementation that is
returned depends on the wire implementation.newBooleanReference in interface WireCommonBooleanValue.public boolean useSelfDescribingMessage(@NotNull
@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
WireCommonuseSelfDescribingMessage in interface WireCommonpublic boolean isBinary()
WireCommonisBinary in interface WireCommon@NotNull public @NotNull net.openhft.chronicle.core.values.LongArrayValues newLongArrayReference()
WireCommonLongArrayValues. The LongArrayValues implementation that
is returned depends on the wire implementation.newLongArrayReference in interface WireCommonLongArrayValues@NotNull public @NotNull net.openhft.chronicle.core.values.IntArrayValues newIntArrayReference()
WireCommonIntArrayValues. The IntArrayValues implementation that
is returned depends on the wire implementation.newIntArrayReference in interface WireCommonIntArrayValues@NotNull public @NotNull net.openhft.chronicle.threads.Pauser pauser()
WireCommonPauser implementation being used for blocking operations.pauser in interface WireCommonPauser implementation being used for blocking operationspublic void pauser(net.openhft.chronicle.threads.Pauser pauser)
WireCommonPauser implementation to be used for blocking operations.pauser in interface WireCommonpauser - implementation to be used for blocking operations.Copyright © 2024. All rights reserved.