1 package net.jpountz.xxhash;
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 final class StreamingXXHash64JNI extends StreamingXXHash64 {
20 static class Factory implements StreamingXXHash64.Factory {
22 public static final StreamingXXHash64.Factory INSTANCE = new Factory();
25 public StreamingXXHash64 newStreamingHash(long seed) {
26 return new StreamingXXHash64JNI(seed);
33 StreamingXXHash64JNI(long seed) {
35 state = XXHashJNI.XXH64_init(seed);
38 private void checkState() {
40 throw new AssertionError("Already finalized");
47 XXHashJNI.XXH64_free(state);
48 state = XXHashJNI.XXH64_init(seed);
52 public long getValue() {
54 return XXHashJNI.XXH64_digest(state);
58 public void update(byte[] bytes, int off, int len) {
60 XXHashJNI.XXH64_update(state, bytes, off, len);
64 protected void finalize() throws Throwable {
67 XXHashJNI.XXH64_free(state);