public class HashWire extends Object implements WireOut, net.openhft.chronicle.bytes.HexDumpBytesDescription
WireOut used only for hashing.
Values written to this wire are not serialised. The
value writer mixes each item into a rolling hash using
constants K0, M0, M1, M2 and M3. An
instance is obtained from a thread-local and the hash
is cleared on retrieval.
WireOut.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)
Padding is ignored for hashing.
|
@NotNull net.openhft.chronicle.bytes.Bytes<?> |
bytes()
Unsupported as
HashWire does not hold an output buffer. |
net.openhft.chronicle.bytes.HexDumpBytesDescription<?> |
bytesComment()
Not applicable; returns
this for chaining. |
net.openhft.chronicle.core.pool.ClassLookup |
classLookup()
Always returns
ClassAliasPool.CLASS_ALIASES as type
resolution is still required for consistent hashing. |
void |
classLookup(net.openhft.chronicle.core.pool.ClassLookup classLookup)
Sets the
ClassLookup implementation to be used for class lookup. |
void |
clear()
Reset the accumulated
hash. |
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)
As
hash64(Object) but returning 32 bits. |
static int |
hash32(WriteMarshallable value)
As
hash64(WriteMarshallable) but returning 32 bits. |
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()
Not supported.
|
@NotNull net.openhft.chronicle.core.values.IntArrayValues |
newIntArrayReference()
Not supported.
|
@NotNull net.openhft.chronicle.core.values.IntValue |
newIntReference()
Not supported.
|
@NotNull net.openhft.chronicle.core.values.LongArrayValues |
newLongArrayReference()
Not supported.
|
@NotNull net.openhft.chronicle.core.values.LongValue |
newLongReference()
Not supported.
|
@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()
Unsupported by
HashWire. |
void |
pauser(net.openhft.chronicle.threads.Pauser pauser)
Not supported.
|
void |
reset()
Alias for
clear(). |
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()
Hashes an anonymous value field.
|
@NotNull ValueOut |
write(@NotNull CharSequence name)
Hashes the field name before returning
valueOut. |
@NotNull ValueOut |
write(@NotNull WireKey key)
Writes a WireKey to the stream.
|
@NotNull WireOut |
writeComment(CharSequence s)
Comments do not affect the hash.
|
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)
Hashes the event key and returns
valueOut. |
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)
hash64(WriteMarshallable) but returning 32 bits.public static int hash32(Object value)
hash64(Object) but returning 32 bits.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()
ClassAliasPool.CLASS_ALIASES as type
resolution is still required for consistent hashing.classLookup in interface WireCommonClassLookup implementation being used for class lookuppublic void clear()
hash.clear in interface WireCommonclear in interface WireOutpublic void reset()
clear().reset 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()
@NotNull public @NotNull ValueOut write(@NotNull @NotNull WireKey key)
WireOut@NotNull public @NotNull ValueOut write(@NotNull @NotNull CharSequence name)
valueOut.@NotNull public @NotNull ValueOut writeEvent(Class<?> ignored, @NotNull @NotNull Object eventKey)
valueOut.writeEvent 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)
writeComment in interface WireOuts - The comment to be written to the stream.@NotNull public @NotNull WireOut addPadding(int paddingToAdd)
addPadding 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()
HashWire does not hold an output buffer.bytes in interface WireCommonBytes stored by the wirepublic net.openhft.chronicle.bytes.HexDumpBytesDescription<?> bytesComment()
this for chaining.bytesComment in interface WireCommon@NotNull public @NotNull net.openhft.chronicle.core.values.IntValue newIntReference()
newIntReference in interface WireCommonIntValue.@NotNull public @NotNull net.openhft.chronicle.core.values.LongValue newLongReference()
newLongReference in interface WireCommonLongValue@NotNull public @NotNull net.openhft.chronicle.core.values.BooleanValue newBooleanReference()
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()
newLongArrayReference in interface WireCommonLongArrayValues@NotNull public @NotNull net.openhft.chronicle.core.values.IntArrayValues newIntArrayReference()
newIntArrayReference in interface WireCommonIntArrayValues@NotNull public @NotNull net.openhft.chronicle.threads.Pauser pauser()
HashWire.pauser in interface WireCommonPauser implementation being used for blocking operationspublic void pauser(net.openhft.chronicle.threads.Pauser pauser)
pauser in interface WireCommonpauser - implementation to be used for blocking operations.Copyright © 2026 Chronicle Software Ltd. All rights reserved.