Package org.iq80.leveldb

Examples of org.iq80.leveldb.WriteOptions


    public void setSync(boolean sync) {
        this.sync = sync;
    }

    public WriteOptions getWriteOptions() {
        WriteOptions options = new WriteOptions();
        options.sync(sync);
        return options;
    }
View Full Code Here


    public void setSync(boolean sync) {
        this.sync = sync;
    }

    public WriteOptions getWriteOptions() {
        WriteOptions options = new WriteOptions();
        options.sync(sync);
        return options;
    }
View Full Code Here

    public void setSync(boolean sync) {
        this.sync = sync;
    }

    public WriteOptions getWriteOptions() {
        WriteOptions options = new WriteOptions();
        options.sync(sync);
        return options;
    }
View Full Code Here

                            logger.trace("Synchronized data store [name=" + getName() + "]");
          // Implement this in LevelDB by just writing a special key
          byte[] syncKey = new byte[] { 0x00 };
          byte[] syncValue = new byte[8];
          ByteBuffer.wrap(syncValue).putLong(System.currentTimeMillis());
          db.put(syncKey, syncValue, new WriteOptions().sync(true));
                        } else {
                            // cancel this task!
                            logger.warn("Cancelling synchronizeTimerTask since db was null, this may be normal if data store shutting down");
                            this.cancel();
                        }
View Full Code Here

    @Override
    public void doSetRecord(byte[] key, byte[] value) throws DataStoreFatalException {
  try {
      if (this.synchronizeInterval == 0) {
    db.put(key, value, new WriteOptions().sync(true));
      } else {
    db.put(key, value, new WriteOptions().sync(false));
      }
  } catch (DBException e) {
      throw new DataStoreFatalException("Unable to set value and key [0x" + HexUtil.toHexString(key) + "] [message=" + e.getMessage() + "]", e);
  }
    }
View Full Code Here

    public void doDeleteRecord(byte[] key) throws RecordNotFoundException, DataStoreFatalException {
  try {
      // TODO: need to throw a RecordNotFoundException if the key isn't there
      doGetRecord(key);
      if (this.synchronizeInterval == 0) {
    db.delete(key, new WriteOptions().sync(true));
      } else {
    db.delete(key, new WriteOptions().sync(false));
      }
  } catch (DBException e) {
      throw new DataStoreFatalException("Unable to delete record with key [0x" + HexUtil.toHexString(key) + "] [message=" + e.getMessage() + "]", e);
  }
    }
View Full Code Here

    basePath = config.get(Constants.CFG_DATA_LEVELDB_DIR);
    Preconditions.checkNotNull(basePath, "No base directory configured for LevelDB.");

    blockSize = config.getInt(Constants.CFG_DATA_LEVELDB_BLOCKSIZE, Constants.DEFAULT_DATA_LEVELDB_BLOCKSIZE);
    cacheSize = config.getLong(Constants.CFG_DATA_LEVELDB_CACHESIZE, Constants.DEFAULT_DATA_LEVELDB_CACHESIZE);
    writeOptions = new WriteOptions().sync(
      config.getBoolean(Constants.CFG_DATA_LEVELDB_FSYNC, Constants.DEFAULT_DATA_LEVELDB_FSYNC));
  }
View Full Code Here

      // 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));
View Full Code Here

                entityId + " from related entity entry of type:" +
                type + " id:" + id);
          }
        }
      }
      WriteOptions writeOptions = new WriteOptions();
      writeOptions.sync(true);
      db.write(writeBatch, writeOptions);
      return true;
    } finally {
      IOUtils.cleanup(LOG, writeBatch);
    }
View Full Code Here

        options.maxOpenFiles(100);
        options.createIfMissing(true);
        DbImpl db = new DbImpl(options, this.databaseDir);
        Random random = new Random(301);
        for (int i = 0; i < 200000 * STRESS_FACTOR; i++) {
            db.put(randomString(random, 64).getBytes(), new byte[] {0x01}, new WriteOptions().sync(false));
            db.get(randomString(random, 64).getBytes());
            if ((i % 50000) == 0 && i != 0) {
                System.out.println(i + " rows written");
            }
        }
View Full Code Here

TOP

Related Classes of org.iq80.leveldb.WriteOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.