本文整理汇总了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);
}