当前位置: 首页>>代码示例>>Java>>正文


Java RocksDB.put方法代码示例

本文整理汇总了Java中org.rocksdb.RocksDB.put方法的典型用法代码示例。如果您正苦于以下问题:Java RocksDB.put方法的具体用法?Java RocksDB.put怎么用?Java RocksDB.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.rocksdb.RocksDB的用法示例。


在下文中一共展示了RocksDB.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
public static void main(String[] args) {
    RocksDB.loadLibrary();
    Options rockopts = new Options().setCreateIfMissing(true);
    RocksDB db = null;
    int count = 0;

    try {
        BufferedReader in = new BufferedReader(new FileReader(args[0]));
        db = RocksDB.open(rockopts, args[1]);
        String line;

        while ((line = in.readLine()) != null) {
            String[] fields = line.split("\\t+");
            if (fields[2].endsWith("@en")) {
                byte[] key = fields[0].substring(1, fields[0].length() - 1).getBytes(StandardCharsets.UTF_8);
                byte[] value = fields[2].substring(1, fields[2].length() - 4).getBytes(StandardCharsets.UTF_8);
                db.put(key, value);
            }
            count++;
            if ((count % 100000) == 0)
                System.out.print(".");
        }

        db.close();
        System.out.println();
    } catch (RocksDBException rdbe) {
        rdbe.printStackTrace(System.err);
    } catch (IOException ioe) {
        ioe.printStackTrace(System.err);
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:32,代码来源:BuildLabelDb.java

示例2: multimapPut

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
private void multimapPut(RocksDB db, byte[] key, byte[] value) throws RocksDBException {
  byte[] current = db.get(key);
  if (current != null) {
    current = ByteBuffer.allocate(current.length + value.length).put(current).put(value).array();
    db.delete(key);
  } else {
    current = value;
  }
  db.put(key, current);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:11,代码来源:ConceptDictionaryBuilder.java

示例3: rocksDbTest

import org.rocksdb.RocksDB; //导入方法依赖的package包/类
private static void rocksDbTest(RocksDB db, List<ColumnFamilyHandle> handlers) {
    try {
        ColumnFamilyHandle handler1 = null;
        ColumnFamilyHandle handler2 = null;
        if (handlers.size() > 0) {
            // skip default column family
            handler1 = handlers.get(1);
            handler2 = handlers.get(2);
        } else {
            handler1 = db.createColumnFamily(new ColumnFamilyDescriptor("test1".getBytes()));
            handler2 = db.createColumnFamily(new ColumnFamilyDescriptor("test2".getBytes()));
        }
        int startValue1 = getStartValue(db, handler1);
        int startValue2 = getStartValue(db, handler2);;

        Checkpoint cp = Checkpoint.create(db);
   
        if (isCompaction) {
            db.compactRange();
            LOG.info("Compaction!");
        }

        long flushWaitTime = System.currentTimeMillis() + flushInterval;
        for (int i = 0; i < putNum || putNum == -1; i++) {
            db.put(handler1, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue1 + i).getBytes());
            db.put(handler2, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue2 + i).getBytes());
            if (isFlush && flushWaitTime <= System.currentTimeMillis()) {
                db.flush(new FlushOptions());
                if (isCheckpoint) {
                    cp.createCheckpoint(cpPath + "/" + i);
                }
                flushWaitTime = System.currentTimeMillis() + flushInterval;
            }
        }
    } catch (RocksDBException e) {
        LOG.error("Failed to put or flush", e);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:39,代码来源:RocksDbUnitTest.java


注:本文中的org.rocksdb.RocksDB.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。