Exemplo n.º 1
0
 /**
  * Commit a transaction.
  *
  * @param t the transaction
  * @param maxLogId the last log id
  */
 void commit(Transaction t, long maxLogId) {
   for (long logId = 0; logId < maxLogId; logId++) {
     long[] undoKey = new long[] {t.getId(), logId};
     Object[] op = undoLog.get(undoKey);
     int opType = (Integer) op[0];
     if (opType == Transaction.OP_REMOVE) {
       int mapId = (Integer) op[1];
       Map<String, String> meta = store.getMetaMap();
       String m = meta.get("map." + mapId);
       String mapName = DataUtils.parseMap(m).get("name");
       MVMap<Object, Object[]> map = store.openMap(mapName);
       Object key = op[2];
       Object[] value = map.get(key);
       // possibly the entry was added later on
       // so we have to check
       if (value[2] == null) {
         // remove the value
         map.remove(key);
       }
     }
     undoLog.remove(undoKey);
   }
   endTransaction(t);
 }
Exemplo n.º 2
0
 /**
  * Roll a transaction back.
  *
  * @param t the transaction
  * @param maxLogId the last log id
  */
 void rollback(Transaction t, long maxLogId) {
   rollbackTo(t, maxLogId, 0);
   endTransaction(t);
 }