E
- type of marshalled objectspublic interface BytesInterop<E> extends BytesWriter<E>
Byteables
, byte[]
arrays, other primitive arrays, "flat" objects
(with primitives fields only), particularly boxed primitive types.
This interface is called "BytesInterop" because it allows to work with object as they
are already marshalled to Bytes
: compare
with other Bytes
, i. e. interoperate objects and Bytes
.
Modifier and Type | Method and Description |
---|---|
boolean |
equivalent(E a,
E b)
Returns
true if the given objects are serialized to the same sequence of bytes by
BytesWriter.write(Bytes, Object) method, without actual serialization. |
long |
hash(net.openhft.chronicle.hash.hashing.LongHashFunction hashFunction,
E e)
Returns hash code for the byte sequence the given object is serialized to, without actual serialization.
|
boolean |
startsWith(Bytes bytes,
E e)
Checks if the given
bytes starts (from the bytes ' position) with the byte sequence the given object
is serialized to, without actual serialization. |
size, write
boolean startsWith(@NotNull Bytes bytes, @NotNull E e)
bytes
starts (from the bytes
' position) with the byte sequence the given object
is serialized to, without actual serialization.bytes
- the bytes to check if starts with the serialized form of the given object.
bytes
' is positioned at the first byte to compare. bytes
' limit
is unspecified. bytes
' position and limit shouldn't be altered during
this call.e
- the object to serialize virtually and compare with the given bytes
bytes
starts with the given e
object's serialized formboolean equivalent(@NotNull E a, @NotNull E b)
true
if the given objects are serialized to the same sequence of bytes by
BytesWriter.write(Bytes, Object)
method, without actual serialization. Normally this method
should always return the same result as a.equals(b)
call, unless some fields of the
serialized objects, accounted in equals()
implementation, are ignored
on serialization.a
- first object to compareb
- second object to compareBytesInterop
strategylong hash(@NotNull net.openhft.chronicle.hash.hashing.LongHashFunction hashFunction, @NotNull E e)
public long hash(LongHashFunction hashFunction, E e) {
long size = size(e);
long addr = theUnsafe.allocateMemory(size);
Bytes bytes = new NativeBytes(addr, size);
write(bytes, e);
return hashFunction.hashBytes(bytes, 0, size);
}
except that it should perform actual serialization and allocate memory, of cause.hashFunction
- the hash function to use for hash code computatione
- the object to hashCopyright © 2015. All rights reserved.