Package kyotocabinet

Examples of kyotocabinet.Error


    public boolean jump(byte[] key) throws DataStoreFatalException {
  if (this.firstNextCall) this.firstNextCall = false;
  boolean jumped = this.cursor.jump(key);
  if (!jumped) {
      Error e = db.error();
      if (e != null) logger.debug("DataStoreIterator failed to jump to record {} {}", new String(key), errorToString(e));
  }
  return jumped;
    }
View Full Code Here


    public Record getRecord() throws DataStoreFatalException {
        byte[] key = cursor.get_key(false);
        byte[] value = cursor.get_value(false);
        if (key == null) {
      Error e = db.error();
      if (e != null) logger.warn("Kyoto reporting error {}", errorToString(e));
            throw new DataStoreFatalException("Record key was null", e);
  }
  if (value == null) {
      Error e = db.error();
      if (e != null) logger.warn("Kyoto reporting error {}", errorToString(e));
            throw new DataStoreFatalException("Record value for key "+new String(key)+" was null", e);
        }
        return new Record(key, value);
    }
View Full Code Here

  // if (!db.open(path.getAbsolutePath(), DB.OWRITER | DB.OCREATE)) {
  String kyotoPath = createKyotoPath(path, kprops);
  logger.debug("Using kyoto path {}", kyotoPath);
        if (!db.open(kyotoPath, DB.OWRITER | DB.OCREATE)) {
            // error occurred while opening, throw error
      Error error = db.error();
            db = null;
            throw new DataStoreFatalException("Unable to open " + toString() + " @ " + path + " {code=" + error.code() + ", message=" + error.message() + "}");
        }

        if (this.synchronizeInterval < 0) {
            logger.debug("Automatic sync disabled {synchronizeInterval < 0} for " + toString());
        } else if (this.synchronizeInterval == 0) {
View Full Code Here

            }

            if (db != null) {
                if (!db.close()) {
                    // error occurred while opening, throw error
        Error error = db.error();
                    throw new DataStoreFatalException("Unable to properly close DataStore {code=" + error.code() + ", message=" + error.message() + "}");
                }
            }
        } finally {
            db = null;
        }
View Full Code Here

    @Override
    public void doSetRecord(byte[] key, byte[] value) throws DataStoreFatalException {
        // db.put = returns true if value put in and didn't replace anything
        //           returns false if it failed OR if it had to replace a value
        if (!db.set(key, value)) {
      Error error = db.error();
            // this code may be 0 if the value was replaced
            if (error.code() == Error.DUPREC) {
                // value replaced, ignoring
            } else {
                throw new DataStoreFatalException("Unable to set value and key [0x" + HexUtil.toHexString(key) + "] [code=" + error.code() + ", message=" + error.message() + "]");
            }
        }
  Error error = db.error();
  if (error != null && error.code() != 0) logger.trace("Error on set {}=>{} {} {}", HexUtil.toHexString(key), value.length, error.code(), error);

        // if synchronize interval is zero, sync() on every put() and take()
        if (this.synchronizeInterval == 0) {
            // syncing the b-tree database
            db.synchronize(false, null);
View Full Code Here

    @Override
    public byte[] doGetRecord(byte[] key) throws RecordNotFoundException, DataStoreFatalException {
        byte[] value = db.get(key);

  Error error = db.error();
  if (error != null && error.code() != 0) logger.trace("Error on get {} {} {}", HexUtil.toHexString(key), error.code(), error);

        if (value == null) {
            throw new RecordNotFoundException("The record for key [0x" + HexUtil.toHexString(key) + "] was not found");
        }
View Full Code Here

    }

    @Override
    public void doDeleteRecord(byte[] key) throws RecordNotFoundException, DataStoreFatalException {
        if (!db.remove(key)) {
      Error error = db.error();
            // this code may be 0 if the value was replaced
            if (error.code() == 0) {
                // value deleted, ignoring error code
            } else if (error.code() == Error.NOREC) {
                //[code=22, message=no record found]
                throw new RecordNotFoundException("The record for key [0x" + HexUtil.toHexString(key) + "] was not found");
            } else {
                throw new DataStoreFatalException("Unable to delete record with key [0x" + HexUtil.toHexString(key) + "] [code=" + error.code() + ", message=" + error.message() + "]");
            }
        }
  Error error = db.error();
  if (error != null && error.code() != 0) logger.trace("Error on remove {} {} {}", HexUtil.toHexString(key), error.code(), error);

        // if synchronize interval is zero, sync() on every put() and take()
        if (this.synchronizeInterval == 0) {
            // syncing the b-tree database
            db.synchronize(false, null);
View Full Code Here

TOP

Related Classes of kyotocabinet.Error

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.