Java Code Examples for com.google.protobuf.ByteString#hashCode()
The following examples show how to use
com.google.protobuf.ByteString#hashCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteSequence.java From jetcd with Apache License 2.0 | 4 votes |
private ByteSequence(ByteString byteString) { this.byteString = byteString; this.hashVal = byteString.hashCode(); }
Example 2
Source File: Slopbucket.java From jelectrum with MIT License | 4 votes |
protected RecordEntry getKeyValueTable(long table_pos, ByteString key) { int hash_file = (int) (table_pos / SEGMENT_FILE_SIZE); MappedByteBuffer hash_mbb = getBufferMap(hash_file); int file_offset = (int) (table_pos % SEGMENT_FILE_SIZE); int max; int items; long next_ptr; synchronized(hash_mbb) { hash_mbb.position(file_offset + (int) LOCATION_HASH_MAX); max = hash_mbb.getInt(); items = hash_mbb.getInt(); next_ptr = hash_mbb.getLong(); } Assert.assertTrue("Max " + max + " items " + items + " table at " + table_pos + " file " + hash_file + " file offset " + file_offset ,max > items); Assert.assertTrue(max > 4); Assert.assertTrue(items >= 0); int hash = key.hashCode(); int loc = Math.abs(hash % max); if (loc < 0) loc = 0; //DeterministicStream det_stream = new DeterministicStream(key); //int loc = det_stream.nextInt(max); while(true) { Assert.assertTrue(loc >= 0); Assert.assertTrue(loc < max); synchronized(hash_mbb) { hash_mbb.position(file_offset + LOCATION_HASH_START + loc * 8); long ptr = hash_mbb.getLong(); if (ptr != 0) { RecordEntry re = new RecordEntry(ptr); if (re.getKey().equals(key)) return re; } if (ptr == 0) { if (next_ptr != 0) { return getKeyValueTable(next_ptr, key); } else { return null; } } } //loc = det_stream.nextInt(max); loc = (loc + 131 ) % max; } }