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


Java Storable.tryDelete方法代碼示例

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


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

示例1: updateIndexEntry

import com.amazon.carbonado.Storable; //導入方法依賴的package包/類
/** Assumes caller is in a transaction */
boolean updateIndexEntry(S userStorable, S oldUserStorable) throws PersistException {
    Storable newIndexEntry = makeIndexEntry(userStorable);

    if (oldUserStorable != null) deleteOldEntry: {
        Storable oldIndexEntry;
        try {
            oldIndexEntry = makeIndexEntry(oldUserStorable);
        } catch (PersistException e) {
            Throwable cause = e.getCause();
            if (cause instanceof IllegalArgumentException) {
                // Can be caused by a corrupt master record, which is
                // attempting do assign an illegal value to the index. There's
                // no way to find the old index entry to delete.
                break deleteOldEntry;
            }
            throw e;
        }

        if (oldIndexEntry.equalPrimaryKeys(newIndexEntry)) {
            // Index entry didn't change, so nothing to do. If the index
            // entry has a version, it will lag behind the master's version
            // until the index entry changes, at which point the version
            // will again match the master.
            return true;
        }

        oldIndexEntry.tryDelete();
    }

    return insertIndexEntry(userStorable, newIndexEntry);
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:33,代碼來源:ManagedIndex.java

示例2: updateValues

import com.amazon.carbonado.Storable; //導入方法依賴的package包/類
private void updateValues(S storable, Object state) throws PersistException {
    if (state == null) {
        return;
    }

    List<Storable> oldIndexEntries = (List<Storable>) state;
    int size = oldIndexEntries.size();

    List<Storable> newIndexEntries = new ArrayList<Storable>(size);
    createDependentIndexEntries(storable, newIndexEntries);

    if (size != newIndexEntries.size()) {
        // This is not expected to happen.
        throw new PersistException("Amount of affected dependent indexes changed: " +
                                   size + " != " + newIndexEntries.size());
    }

    for (int i=0; i<size; i++) {
        Storable oldIndexEntry = oldIndexEntries.get(i);
        Storable newIndexEntry = newIndexEntries.get(i);
        if (!oldIndexEntry.equalProperties(newIndexEntry)) {
            // Try delete old entry, just in case it is missing.
            oldIndexEntry.tryDelete();
        }
        // Always try to insert index entry, just in case it is missing.
        newIndexEntry.tryInsert();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:29,代碼來源:DerivedIndexesTrigger.java

示例3: tryDeleteReplica

import com.amazon.carbonado.Storable; //導入方法依賴的package包/類
/**
 * Deletes the replica entry with replication disabled.
 */
boolean tryDeleteReplica(Storable replica) throws PersistException {
    // Prevent trigger from being invoked by deleting replica.
    TriggerManager tm = mTriggerManager;
    tm.locallyDisableDelete();
    try {
        return replica.tryDelete();
    } finally {
        tm.locallyEnableDelete();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:14,代碼來源:ReplicationTrigger.java


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