Examples of dbc


Examples of com.sleepycat.db.Dbc

     * @throws IOException if an IO problem occurs.
     */
    public boolean isEmpty()
        throws DbException, IOException {

        Dbc cursor = db.openCursor(false);
        try {
            // val is always unused (discarded) but key is needed for bounds
            // checking if the range has a bound
            DataThang val = DataThang.getDiscardDataThang();
            DataThang key = (range.hasBound()) ? (new DataThang()) : val;
View Full Code Here

Examples of com.sleepycat.db.Dbc

                    throw new IntegrityConstraintException(
                                    "ON_DELETE_ABORT: deletion not allowed");
                }
                case ON_DELETE_CASCADE: {
                    DataThang tempThang = new DataThang();
                    Dbc cursor = store.db.openCursor(true);
                    try {
                        err = cursor.get(primaryKeyThang, tempThang,
                                         Db.DB_SET | env.getWriteLockFlag());
                        if (err == 0) {
                            cursor.delete(0);
                            store.applyChange(primaryKeyThang, tempThang,
                                              null);
                        } else {
                            throw new IntegrityConstraintException(
                               "ON_DELETE_CASCADE: index entry not found");
                        }
                    } finally {
                        store.db.closeCursor(cursor);
                    }
                    break;
                }
                case ON_DELETE_CLEAR: {
                    DataThang valueThang = new DataThang();
                    Dbc cursor = store.db.openCursor(true);
                    try {
                        err = cursor.get(primaryKeyThang, valueThang,
                                         Db.DB_SET | env.getWriteLockFlag());
                        if (err == 0) {
                            keyExtractor.clearIndexKey(
                                (keyExtractor.getValueFormat() != null)
                                ? valueThang : null);
                            cursor.put(primaryKeyThang, valueThang,
                                       Db.DB_CURRENT);
                        } else {
                            throw new IntegrityConstraintException(
                                "ON_DELETE_CLEAR: index entry not found");
                        }
View Full Code Here

Examples of com.sleepycat.db.Dbc

            CdbThreadContext context = (CdbThreadContext) cdbContext.get();
            List cursors = writeCursor ? context.writeCursors
                                       : context.readCursors;
            if (!cursors.contains(cursor))
                throw new IllegalStateException("cursor to dup not tracked");
            Dbc newCursor = cursor.dup(flags);
            cursors.add(newCursor);
            return newCursor;
        } else {
            return cursor.dup(flags);
        }
View Full Code Here

Examples of com.sleepycat.db.Dbc

                                   ObjectStreamClass classFormat)
        throws DbException, ClassNotFoundException {

        // an intent-to-write cursor is needed for CDB

        Dbc cursor = db.openCursor(true);
        try {
            // get and lock the record containing the last assigned ID

            DataThang key = newDbt();
            key.setBytes(LAST_CLASS_ID_KEY);
            DataThang data = newDbt();
            int putFlag = Db.DB_CURRENT;
            int err = cursor.get(key, data,
                                 Db.DB_SET | env.getWriteLockFlag());
            if (err != 0) {
                // if this is a new database, set the initial ID record
                data.setBytes(new byte[1]); // zero ID
                putFlag = Db.DB_KEYLAST;
            }
            byte[] idBytes = data.getBytes();

            // check one last time to see if another thread
            // wrote the information before this thread

            Object anotherClassInfo = classMap.get(className);
            if (anotherClassInfo != null)
                return (ClassInfo) anotherClassInfo;

            // increment the ID by one and write the updated record

            idBytes = incrementID(idBytes);
            data.setBytes(idBytes);
            cursor.put(key, data, putFlag);

            // write the new class format record whose key is the ID just
            // assigned

            byte[] keyBytes = new byte[1 + idBytes.length];
View Full Code Here

Examples of com.sleepycat.db.Dbc

                    "Join cursor for view " + index +
                    " is not indexed on primary store " + view.store);
            }
            cursors[i] = indexCursors[i].cursor;
        }
        Dbc joinCursor = view.store.db.db.join(cursors,
                                           presorted ? Db.DB_JOIN_NOSORT : 0);
        init(view, false, null, joinCursor);
        if (closeIndexCursors) {
            this.indexCursorsToClose = indexCursors;
        }
View Full Code Here

Examples of com.sleepycat.db.Dbc

     */
    public void close()
        throws DbException, IOException {

        if (cursor != null) {
            Dbc toClose = cursor;
            cursor = null;
            if (closeDirect) {
                toClose.close();
            } else {
                db.closeCursor(toClose);
            }
        }
        if (indexCursorsToClose != null) {
View Full Code Here

Examples of com.sleepycat.db.Dbc

    }

    void applyIndexDelete(DataThang keyThang, DataThang oldIndexKey)
        throws DbException, IOException {

        Dbc cursor = db.openCursor(true);
        try {
            int err = cursor.get(oldIndexKey, keyThang,
                                 Db.DB_GET_BOTH |
                                 store.db.env.getWriteLockFlag());
            if (err == 0) {
                cursor.delete(0);
            } else {
                throw new IntegrityConstraintException(
                    "Index entry not found");
            }
        } finally {
View Full Code Here

Examples of com.sleepycat.db.Dbc

    public int get(DataThang key, DataThang data, int flags)
        throws DbException {

        int pos = flags & DataDb.FLAGS_POS_MASK;
        if (cdbContext != null) {
            Dbc cursor = openCursor(flags == Db.DB_CONSUME ||
                                    flags == Db.DB_CONSUME_WAIT);
            try {
                if (pos == 0)
                    flags |= Db.DB_SET;
                return get(cursor, key, data, flags);
View Full Code Here

Examples of com.sleepycat.db.Dbc

        throws DbException {

        // Dbc.put() cannot be used with QUEUE/RECNO types
        if (cdbContext != null && (type == Db.DB_HASH ||
                                   type == Db.DB_BTREE)) {
            Dbc cursor = openCursor(true);
            try {
                int pos = flags & DataDb.FLAGS_POS_MASK;
                if (pos == Db.DB_NODUPDATA && !areDuplicatesOrdered()) {
                    if (areDuplicatesAllowed()) {
                        int err = get(cursor, key, data, Db.DB_GET_BOTH);
View Full Code Here

Examples of com.sleepycat.db.Dbc

     * @throws DbException if a database problem occurs.
     */
    public int delete(DataThang key, int flags)
        throws DbException {

        Dbc cursor = openCursor(true);
        try {
            int err = cursor.get(key, DataThang.getDiscardDataThang(),
                                 Db.DB_SET | env.getWriteLockFlag());
            if (err == 0) {
                return cursor.delete(0);
            } else {
                return err;
            }
        } finally {
            closeCursor(cursor);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.