use xxhash instead of sha

a little speedup
This commit is contained in:
2024-06-21 23:11:55 +02:00
parent 1d4f5a2bd3
commit 0ea57a5508
2 changed files with 9 additions and 2 deletions

View File

@@ -31,6 +31,11 @@
</dependencyManagement>
<dependencies>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>zero-allocation-hashing</artifactId>
<version>0.16</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc</artifactId>

View File

@@ -3,10 +3,11 @@ package com.usatiuk.dhfs.storage.files.objects;
import com.usatiuk.dhfs.storage.objects.jrepository.JObjectData;
import com.usatiuk.dhfs.storage.objects.repository.distributed.ConflictResolver;
import lombok.Getter;
import org.apache.commons.codec.digest.DigestUtils;
import net.openhft.hashing.LongTupleHashFunction;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
@Getter
public class ChunkData extends JObjectData {
@@ -16,7 +17,8 @@ public class ChunkData extends JObjectData {
public ChunkData(byte[] bytes) {
super();
this._bytes = Arrays.copyOf(bytes, bytes.length);
this._hash = DigestUtils.sha512Hex(bytes);
this._hash = Arrays.stream(LongTupleHashFunction.xx128().hashBytes(bytes))
.mapToObj(Long::toHexString).collect(Collectors.joining());
}
@Override