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


Java WriteOptions类代码示例

本文整理汇总了Java中org.iq80.leveldb.WriteOptions的典型用法代码示例。如果您正苦于以下问题:Java WriteOptions类的具体用法?Java WriteOptions怎么用?Java WriteOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: replace

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
public static <T extends D_Level> void replace(String cluster, Class<T> clazz, List<T> data) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seekToFirst();
		iterator.forEachRemaining(entry ->{
			byte[] key = entry.getKey();
			write.delete(key);
		});
		data.forEach(t->{
			write.put(t.key().getBytes(), t.value());
		});
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:21,代码来源:LevelTable.java

示例2: deletePrev

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
public static <T extends D_TimeLine> void deletePrev(String cluster, Class<T> clazz, Long start) throws IOException {
	DB db = getDB(path(cluster, clazz));
	ReadOptions readOptions = new ReadOptions().snapshot(db.getSnapshot());
	DBIterator iterator = db.iterator(readOptions);
	WriteBatch write = db.createWriteBatch();
	try {
		iterator.seek((start + "").getBytes());
		while(iterator.hasPrev()){
			byte[] key = iterator.prev().getKey();
			write.delete(key);
		}
		db.write(write, new WriteOptions().sync(true));
	} finally {
		iterator.close();
		write.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:18,代码来源:LevelTable.java

示例3: put

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
public static <T extends D_Level> void put(String cluster, Class<T> clazz, List<T> data) throws IOException {
	DB db = getDB(path(cluster, clazz));
	WriteBatch bitch = db.createWriteBatch();
	try {
		for (T t : data) {
			bitch.put(t.key().getBytes(), t.value());
		}
		db.write(bitch, new WriteOptions().sync(true));
	} finally {
		bitch.close();
	}
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:13,代码来源:LevelTable.java

示例4: checkStartTimeInDb

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
/**
 * Checks db for start time and returns it if it exists.  If it doesn't
 * exist, writes the suggested start time (if it is not null).  This is
 * only called when the start time is not found in the cache,
 * so it adds it back into the cache if it is found. Should only be called
 * when a lock has been obtained on the entity.
 */
private StartAndInsertTime checkStartTimeInDb(EntityIdentifier entity,
    Long suggestedStartTime) throws IOException {
  StartAndInsertTime startAndInsertTime = null;
  // create lookup key for start time
  byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType());
  // retrieve value for key
  byte[] v = db.get(b);
  if (v == null) {
    // start time doesn't exist in db
    if (suggestedStartTime == null) {
      return null;
    }
    startAndInsertTime = new StartAndInsertTime(suggestedStartTime,
        System.currentTimeMillis());

    // write suggested start time
    v = new byte[16];
    writeReverseOrderedLong(suggestedStartTime, v, 0);
    writeReverseOrderedLong(startAndInsertTime.insertTime, v, 8);
    WriteOptions writeOptions = new WriteOptions();
    writeOptions.sync(true);
    db.put(b, v, writeOptions);
  } else {
    // found start time in db, so ignore suggested start time
    startAndInsertTime = new StartAndInsertTime(readReverseOrderedLong(v, 0),
        readReverseOrderedLong(v, 8));
  }
  startTimeWriteCache.put(entity, startAndInsertTime);
  startTimeReadCache.put(entity, startAndInsertTime.startTime);
  return startAndInsertTime;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:39,代码来源:LeveldbTimelineStore.java

示例5: store

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
@Override
public Future<Variable> store(final Variable variable)
{
    checkNotNull(variable, "variable is null");
    checkState(!closed.get(), "already closed");
    checkState(variable instanceof JVariable, "can not process native variable, use JVariable");

    final JVariable v = (JVariable) variable;

    return executor.submit(new Callable<Variable>() {
        @Override
        public Variable call() throws Exception
        {
            final WriteOptions writeOptions = new WriteOptions();
            writeOptions.sync(true);

            final String internedName = v.getName().intern();
            synchronized (internedName) {
                final JVariable current = load(internedName);
                if (current == null || current.getUuid().equals(v.getUuid())) {
                    final JVariable update = new JVariable(internedName, v.value());
                    final WriteBatch writeBatch = db.createWriteBatch();
                    writeBatch.delete(bytes(internedName));
                    writeBatch.put(bytes(internedName), update.getEntry().toByteArray());
                    db.write(writeBatch, writeOptions);
                    return update;
                }
                else {
                    return null;
                }
            }
        }
    });
}
 
开发者ID:groupon,项目名称:jesos,代码行数:35,代码来源:JLevelDBState.java

示例6: expunge

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
@Override
public Future<Boolean> expunge(final Variable variable)
{
    checkNotNull(variable, "variable is null");
    checkState(!closed.get(), "already closed");
    checkState(variable instanceof JVariable, "can not process native variable, use JVariable");

    final JVariable v = (JVariable) variable;

    return executor.submit(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception
        {
            final WriteOptions writeOptions = new WriteOptions();
            writeOptions.sync(true);

            final String internedName = v.getName().intern();
            synchronized (internedName) {
                final JVariable current = load(internedName);
                if (current != null && current.getUuid().equals(v.getUuid())) {
                    db.delete(bytes(internedName));
                    return Boolean.TRUE;
                }
                else {
                    return Boolean.FALSE;
                }
            }
        }
    });
}
 
开发者ID:groupon,项目名称:jesos,代码行数:31,代码来源:JLevelDBState.java

示例7: deleteSpentTxOutputs

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
/**
 * Deletes spent transaction outputs that are older than the maximum transaction age
 *
 * @throws      BlockStoreException     Unable to delete spent transaction outputs
 */
@Override
public void deleteSpentTxOutputs() throws BlockStoreException {
    long ageLimit = chainTime - MAX_TX_AGE;
    int txPurged = 0;
    List<byte[]> purgeList = new LinkedList<>();
    synchronized(lock) {
        try {
            //
            // Delete spent transaction outputs
            //
            log.info("Deleting spent transaction outputs");
            try (DBIterator it = dbTxSpent.iterator()) {
                it.seekToFirst();
                while (it.hasNext()) {
                    Entry<byte[], byte[]> dbEntry = it.next();
                    long timeSpent = getLong(dbEntry.getValue());
                    if (timeSpent < ageLimit) {
                        purgeList.add(dbEntry.getKey());
                        txPurged++;
                    }
                }
            }
            WriteOptions options = new WriteOptions();
            options.sync(false);
            for (int i=0; i<purgeList.size(); i++) {
                dbTxSpent.delete(purgeList.get(i), options);
                dbTxOutputs.delete(purgeList.get(i), options);
            }
            log.info(String.format("%,d spent transaction outputs deleted", txPurged));
        } catch (DBException | IOException exc) {
            log.error("Unable to remove spent transactions", exc);
            throw new BlockStoreException("Unable to remove spent transactions");
        }
    }
}
 
开发者ID:shadders,项目名称:JavaBitcoin,代码行数:41,代码来源:BlockStoreLdb.java

示例8: getWriteOptions

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
public WriteOptions getWriteOptions() {
    WriteOptions options = new WriteOptions();
    options.sync(sync);
    return options;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:LevelDBFile.java

示例9: delete

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
@Override
public Snapshot delete(byte[] arg0, WriteOptions arg1)
        throws DBException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:7,代码来源:MockDB.java

示例10: put

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
@Override
public Snapshot put(byte[] arg0, byte[] arg1, WriteOptions arg2)
        throws DBException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:7,代码来源:MockDB.java

示例11: write

import org.iq80.leveldb.WriteOptions; //导入依赖的package包/类
@Override
public Snapshot write(WriteBatch arg0, WriteOptions arg1)
        throws DBException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:7,代码来源:MockDB.java


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