Package com.sleepycat.db

Examples of com.sleepycat.db.DatabaseEntry


        this.entityBinding = entityBinding;
        this.isSecondary = isSecondary;
    }

    public DatabaseEntry initKey() {
        return new DatabaseEntry();
    }
View Full Code Here


    public DatabaseEntry initKey() {
        return new DatabaseEntry();
    }

    public DatabaseEntry initPKey() {
        return isSecondary ? (new DatabaseEntry()) : null;
    }
View Full Code Here

    public DatabaseEntry initPKey() {
        return isSecondary ? (new DatabaseEntry()) : null;
    }

    public DatabaseEntry initData() {
        return new DatabaseEntry();
    }
View Full Code Here

    }

    public PK get(Transaction txn, SK key, LockMode lockMode)
        throws DatabaseException {

        DatabaseEntry keyEntry = new DatabaseEntry();
        DatabaseEntry pkeyEntry = new DatabaseEntry();
        keyBinding.objectToEntry(key, keyEntry);

        OperationStatus status = db.get(txn, keyEntry, pkeyEntry, lockMode);

        if (status == OperationStatus.SUCCESS) {
View Full Code Here

         * synchronized.
         */
        classMap = new HashMap();
        formatMap = new HashMap();

        DatabaseEntry key = new DatabaseEntry(LAST_CLASS_ID_KEY);
        DatabaseEntry data = new DatabaseEntry();
        if (dbConfig.getReadOnly()) {
            /* Check that the class ID record exists. */
            OperationStatus status = db.get(null, key, data, null);
            if (status != OperationStatus.SUCCESS) {
                throw new IllegalStateException
                    ("A read-only catalog database may not be empty");
            }
        } else {
            /* Add the initial class ID record if it doesn't exist.  */
            data.setData(new byte[1]); // zero ID
            /* Use putNoOverwrite to avoid phantoms. */
            db.putNoOverwrite(null, key, data);
        }
    }
View Full Code Here

    // javadoc is inherited
    public synchronized ObjectStreamClass getClassFormat(byte[] classID)
        throws DatabaseException, ClassNotFoundException {

        return getClassFormat(classID, new DatabaseEntry());
    }
View Full Code Here

            /* Make the class format key. */

            byte[] keyBytes = new byte[classID.length + 1];
            keyBytes[0] = REC_CLASS_FORMAT;
            System.arraycopy(classID, 0, keyBytes, 1, classID.length);
            DatabaseEntry key = new DatabaseEntry(keyBytes);

            /* Read the class format. */

            OperationStatus status = db.get(null, key, data, LockMode.DEFAULT);
            if (status != OperationStatus.SUCCESS) {
View Full Code Here

            /* Make class info key.  */
            char[] nameChars = className.toCharArray();
            byte[] keyBytes = new byte[1 + UtfOps.getByteLength(nameChars)];
            keyBytes[0] = REC_CLASS_INFO;
            UtfOps.charsToBytes(nameChars, 0, keyBytes, 1, nameChars.length);
            DatabaseEntry key = new DatabaseEntry(keyBytes);

            /* Read class info.  */
            DatabaseEntry data = new DatabaseEntry();
            OperationStatus status = db.get(null, key, data, LockMode.DEFAULT);
            if (status != OperationStatus.SUCCESS) {
                /*
                 * Not found in the database, write class info and class
                 * format.
                 */
                classInfo = putClassInfo(new ClassInfo(), className, key,
                                         classFormat);
            } else {
                /*
                 * Read class info to get the class format key, then read class
                 * format.
                 */
                classInfo = new ClassInfo(data);
                DatabaseEntry formatData = new DatabaseEntry();
                ObjectStreamClass storedClassFormat =
                    getClassFormat(classInfo.getClassID(), formatData);

                /*
                 * Compare the stored class format to the current class format,
View Full Code Here

                txn = db.getEnvironment().beginTransaction(null, null);
            }
            cursor = db.openCursor(txn, cursorConfig);

            /* Get the current class ID. */
            DatabaseEntry key = new DatabaseEntry(LAST_CLASS_ID_KEY);
            DatabaseEntry data = new DatabaseEntry();
            OperationStatus status = cursor.getSearchKey(key, data,
                                                         writeLockMode);
            if (status != OperationStatus.SUCCESS) {
                throw new IllegalStateException("Class ID not initialized");
            }
            byte[] idBytes = getBytes(data);

            /* Increment the ID by one and write the updated record.  */
            idBytes = incrementID(idBytes);
            data.setData(idBytes);
            cursor.put(key, data);

            /*
             * Write the new class format record whose key is the ID just
             * assigned.
             */
            byte[] keyBytes = new byte[1 + idBytes.length];
            keyBytes[0] = REC_CLASS_FORMAT;
            System.arraycopy(idBytes, 0, keyBytes, 1, idBytes.length);
            key.setData(keyBytes);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos;
            try {
                oos = new ObjectOutputStream(baos);
                oos.writeObject(classFormat);
            } catch (IOException e) {
                throw new RuntimeExceptionWrapper(e);
            }
            data.setData(baos.toByteArray());

            cursor.put(key, data);

            /*
             * Write the new class info record, using the key passed in; this
View Full Code Here

      for (i=0; i<count; i++) {
        outbuf[i] = (byte)('0' + i);
      }
      outbuf[i++] = (byte)'x';

      DatabaseEntry key = new DatabaseEntry(outbuf, 0, i);
      DatabaseEntry data = new DatabaseEntry(outbuf, 0, i);

      TestUtils.DEBUGOUT("Put: " + (char)outbuf[0] + ": " + new String(outbuf, 0, i));
      db.putNoOverwrite(null, key, data);

      // Acquire a cursor for the table.
      Cursor dbcp = db.openCursor(null, CursorConfig.DEFAULT);

      // Walk through the table, checking
      DatabaseEntry readkey = new DatabaseEntry();
      DatabaseEntry readdata = new DatabaseEntry();
      DatabaseEntry whoknows = new DatabaseEntry();

      /*
       * NOTE: Maybe want to change from user-buffer to DB buffer
       *       depending on the flag options.user_buffer (setReuseBuffer)
       * The old version set MALLOC/REALLOC here - not sure if it is the same.
View Full Code Here

TOP

Related Classes of com.sleepycat.db.DatabaseEntry

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.