當前位置: 首頁>>代碼示例>>Java>>正文


Java Database.delete方法代碼示例

本文整理匯總了Java中com.sleepycat.je.Database.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java Database.delete方法的具體用法?Java Database.delete怎麽用?Java Database.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sleepycat.je.Database的用法示例。


在下文中一共展示了Database.delete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkSecondaryUpdate

import com.sleepycat.je.Database; //導入方法依賴的package包/類
/**
 * Check that primary put() writes to each secondary that is open.
 */
private void checkSecondaryUpdate(Transaction txn, Database priDb, int val,
                                  Database secDb, boolean expectSecDbVal,
                                  Database secDb2, boolean expectSecDb2Val)
    throws DatabaseException {

    OperationStatus status;
    DatabaseEntry data = new DatabaseEntry();
    int secVal = KEY_OFFSET + val;

    status = priDb.put(txn, entry(val), entry(val));
    assertSame(OperationStatus.SUCCESS, status);

    status = secDb.get(txn, entry(secVal), data, LockMode.DEFAULT);
    assertSame(expectSecDbVal ? OperationStatus.SUCCESS
                              : OperationStatus.NOTFOUND, status);


    status = secDb2.get(txn, entry(secVal), data, LockMode.DEFAULT);
    assertSame(expectSecDb2Val ? OperationStatus.SUCCESS
                               : OperationStatus.NOTFOUND, status);

    status = priDb.delete(txn, entry(val));
    assertSame(OperationStatus.SUCCESS, status);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:28,代碼來源:SecondaryTest.java

示例2: test11297

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void test11297()
    throws DatabaseException, IOException {

    openEnv();

    /* Write db0 and db1. */
    for (int i = 0; i < 2; i += 1) {
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        dbConfig.setSortedDuplicates(true);
        Database db = env.openDatabase(null, "db" + i, dbConfig);

        /* Write: {0, 0}, {0, 1}, {1, 0}, {2, 0}, {3, 0} */
        for (int j = 0; j < N_ENTRIES; j += 1) {
            db.put(null, entry(j), entry(0));
        }
        db.put(null, entry(0), entry(1));

        /* Delete everything but the last record. */
        for (int j = 0; j < N_ENTRIES - 1; j += 1) {
            db.delete(null, entry(j));
        }

        db.close();
    }

    checkFirstRecord();
    env.compress();
    checkFirstRecord();

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:33,代碼來源:SR11297Test.java

示例3: execute

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void execute () {
        
        super.execute();

//        MyDbEnv myDbEnv = new MyDbEnv();
//        Database relationDB = null;
        Database updateDB = null;

        try {
//            myDbEnv.setup(ExecuteHelpers.myDbEnvPath, READ_WRITE);
//            relationDB = ExecuteHelpers.myDbEnv.getDB("relationDB", READ_WRITE);
            StringBuilder relationMetaData = new StringBuilder();
            String relationName = getRel_name().toString().trim();
            if(!ExecuteHelpers.isTablePresent(relationName, relationMetaData))
                System.err.println("\nRelation not present : " + relationName);
            Map<String, List<AstNode>> clauses = PredicateHelpers.generateClauses(relationName, getOne_rel_pred());
            List<AstNode> clausesList = clauses != null ? clauses.get(relationName) : null;
            List<String>[] data = ExecuteHelpers.getSelectData(relationMetaData.toString(), clausesList);

            Map<String, String[]> metaColumnRelation = new HashMap<String, String[]>();
            Map<String, String[]> metaColumnTypeRelation = new HashMap<String, String[]>();
            Map<String, List<String[]>> allRowsOfRelations = new HashMap<String, List<String[]>>();

            PredicateHelpers.formatData(metaColumnRelation, metaColumnTypeRelation, allRowsOfRelations, data[0]);

            int[] indices = PredicateHelpers.setIndices(metaColumnRelation, clauses, relationName);
            updateDB = ExecuteHelpers.myDbEnv.getDB(relationName+"DB", READ_WRITE);
            List<String> indexes = ExecuteHelpers.getAllIndexes(relationName);

            for(int j = 0; j < allRowsOfRelations.get(relationName).size(); j++) {
                String row[] = allRowsOfRelations.get(relationName).get(j);
                boolean updateRow = PredicateHelpers.applyLocalPredicate(metaColumnTypeRelation.get(relationName), clauses, relationName, indices, row);
                DatabaseEntry theKey = new DatabaseEntry((data[1].get(j)).getBytes("UTF-8"));
                if(updateRow) {
                    updateDB.delete(ExecuteHelpers.txn, theKey);
                    for(int i = 0; i < metaColumnRelation.get(relationName).length; i++) {
                        String relPlusColumnName = metaColumnRelation.get(relationName)[i];
                        Database indexDB = null;
                        if(indexes.contains(relPlusColumnName)) {
                            try{
                                indexDB = ExecuteHelpers.myDbEnv.getDB(relPlusColumnName + "DB", READ_WRITE);
                                //Remove old
                                DatabaseEntry tempData = new DatabaseEntry();
                                DatabaseEntry indexKey = new DatabaseEntry(ExecuteHelpers.bytify(row[i])); // row[i] is value
                                indexDB.get(ExecuteHelpers.txn, indexKey, tempData, LockMode.DEFAULT);
                                if(tempData.getSize() != 0) {
                                    ByteArrayInputStream bais = new ByteArrayInputStream(tempData.getData());
                                    DataInputStream in = new DataInputStream(bais);
                                    ByteArrayOutputStream bOutput = new ByteArrayOutputStream();
                                    DataOutputStream out = new DataOutputStream(bOutput);
                                    while (in.available() > 0) {
                                        String storedData = in.readUTF();
                                        if(!storedData.equals(data[1].get(j))) out.writeUTF(storedData);
                                    }
                                    indexDB.put(ExecuteHelpers.txn, indexKey, new DatabaseEntry(bOutput.toByteArray()));
                                }
                            } finally {
                                if(indexDB != null) indexDB.close();
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
//            if(relationDB != null) relationDB.close();
            if(updateDB != null) updateDB.close();
//            myDbEnv.close();
        }

    }
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:73,代碼來源:DeleteCmd.java


注:本文中的com.sleepycat.je.Database.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。