本文整理匯總了Java中org.iq80.leveldb.Options.comparator方法的典型用法代碼示例。如果您正苦於以下問題:Java Options.comparator方法的具體用法?Java Options.comparator怎麽用?Java Options.comparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.iq80.leveldb.Options
的用法示例。
在下文中一共展示了Options.comparator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EzLevelDbTable
import org.iq80.leveldb.Options; //導入方法依賴的package包/類
public EzLevelDbTable(File path, EzLevelDbFactory factory,
Serde<H> hashKeySerde, Serde<R> rangeKeySerde, Serde<V> valueSerde,
Comparator<byte[]> hashKeyComparator,
Comparator<byte[]> rangeKeyComparator) {
this.hashKeySerde = hashKeySerde;
this.rangeKeySerde = rangeKeySerde;
this.valueSerde = valueSerde;
this.hashKeyComparator = hashKeyComparator;
this.rangeKeyComparator = rangeKeyComparator;
Options options = new Options();
options.createIfMissing(true);
options.comparator(new EzLevelDbComparator(hashKeyComparator,
rangeKeyComparator));
try {
this.db = factory.open(path, options);
} catch (IOException e) {
throw new DbException(e);
}
}
示例2: makeEmptyMap
import org.iq80.leveldb.Options; //導入方法依賴的package包/類
@Override
protected SortedMap<String, String> makeEmptyMap() throws UnsupportedOperationException
{
FileUtils.deleteRecursively(empty);
Options options = new Options();
options.createIfMissing(true);
EntryBinding<String> stringBinding = new StringBinding();
DBComparator comp = new LevelDBStoredSortedMap.BindedDBComparator<String>(stringBinding);
options.comparator(comp);
DB db = null;
try
{
db = factory.open(empty, options);
}
catch (IOException e)
{
e.printStackTrace();
}
return new LevelDBStoredSortedMap<String, String>(db, comp, stringBinding, stringBinding);
}
示例3: makePopulatedMap
import org.iq80.leveldb.Options; //導入方法依賴的package包/類
@Override
protected SortedMap<String, String> makePopulatedMap() throws UnsupportedOperationException
{
FileUtils.deleteRecursively(populated);
Options options = new Options();
options.createIfMissing(true);
EntryBinding<String> stringBinding = new StringBinding();
DBComparator comp = new LevelDBStoredSortedMap.BindedDBComparator<String>(stringBinding);
options.comparator(comp);
DB db = null;
try
{
db = factory.open(populated, options);
}
catch (IOException e)
{
e.printStackTrace();
}
LevelDBStoredSortedMap<String, String> result = new LevelDBStoredSortedMap<String, String>(db, comp,
stringBinding, stringBinding);
result.put("test", "gridline");
result.put("key", "value");
return result;
}
示例4: createSortedMap
import org.iq80.leveldb.Options; //導入方法依賴的package包/類
/**
* Returns a StoredSortedMap which is backed by a DB in the specified directory and sorted using the natural order of
* the keys.
* @param directory The directory in which the database is or will be created
* @param keyBinding An EntryBinding implementation which is used to convert the keys
* @param valueBinding An EntryBinding implementation which is used to convert the values
* @return A StoredSortedMap. The user is responsible for calling close() when the map is no longer needed.
* @throws IOException
*/
public static <K, V> StoredSortedMap<K, V> createSortedMap(File directory, EntryBinding<K> keyBinding,
EntryBinding<V> valueBinding) throws IOException
{
DBComparator dbcomparator = new LevelDBStoredSortedMap.BindedDBComparator<K>(keyBinding);
Options options = new Options();
options.createIfMissing(true);
options.comparator(dbcomparator);
DB db = factory.open(directory, options);
return createSortedMapForDB(db, dbcomparator, keyBinding, valueBinding);
}