Summary: This pull request solves the jlong overflow problem on 32-Bit machines as described in https://github.com/facebook/rocksdb/issues/278: 1. There is a new org.rocksdb.test.PlatformRandomHelper to assist in getting random values. For 32 Bit the getLong method is overriden by xpromaches code above. For 64 Bit it behaves as is. 2. The detection should be cross-platform (Windows is supported though it is not ported completely yet). 3. Every JNI method which sets jlong values must check if the value fits into size_t. If it overflows size_t a InvalidArgument Status object will be returned. If its ok a OK Status will be returned. 4. Setters which have this check will throw a RocksDBException if its no OK Status. Additionally some other parts of code were corrected using the wrong type casts. Test Plan: make rocksdbjava make jtest Differential Revision: https://reviews.facebook.net/D24531
55 lines
1.6 KiB
Java
55 lines
1.6 KiB
Java
package org.rocksdb;
|
|
|
|
/**
|
|
* The config for hash linked list memtable representation
|
|
* Such memtable contains a fix-sized array of buckets, where
|
|
* each bucket points to a sorted singly-linked
|
|
* list (or null if the bucket is empty).
|
|
*
|
|
* Note that since this mem-table representation relies on the
|
|
* key prefix, it is required to invoke one of the usePrefixExtractor
|
|
* functions to specify how to extract key prefix given a key.
|
|
* If proper prefix-extractor is not set, then RocksDB will
|
|
* use the default memtable representation (SkipList) instead
|
|
* and post a warning in the LOG.
|
|
*/
|
|
public class HashLinkedListMemTableConfig extends MemTableConfig {
|
|
public static final long DEFAULT_BUCKET_COUNT = 50000;
|
|
|
|
public HashLinkedListMemTableConfig() {
|
|
bucketCount_ = DEFAULT_BUCKET_COUNT;
|
|
}
|
|
|
|
/**
|
|
* Set the number of buckets in the fixed-size array used
|
|
* in the hash linked-list mem-table.
|
|
*
|
|
* @param count the number of hash buckets.
|
|
* @return the reference to the current HashLinkedListMemTableConfig.
|
|
*/
|
|
public HashLinkedListMemTableConfig setBucketCount(long count) {
|
|
bucketCount_ = count;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Returns the number of buckets that will be used in the memtable
|
|
* created based on this config.
|
|
*
|
|
* @return the number of buckets
|
|
*/
|
|
public long bucketCount() {
|
|
return bucketCount_;
|
|
}
|
|
|
|
@Override protected long newMemTableFactoryHandle()
|
|
throws RocksDBException {
|
|
return newMemTableFactoryHandle(bucketCount_);
|
|
}
|
|
|
|
private native long newMemTableFactoryHandle(long bucketCount)
|
|
throws RocksDBException;
|
|
|
|
private long bucketCount_;
|
|
}
|