Пример #1
0
 @SuppressWarnings("deprecation")
 @Override
 public DResult get(Get get, long startId) throws IOException {
   if (get.hasFamilies()) get.addFamily(DominoConst.INNER_FAMILY);
   get.setTimeRange(0, startId + 1); // [x, y)
   get.setMaxVersions();
   Result preRead = region.get(get);
   List<KeyValue> status = preRead.getColumn(DominoConst.INNER_FAMILY, DominoConst.STATUS_COL);
   if (status == null || status.size() == 0) {
     Result ret = MVCC.handleResult(this, getTrxMetaTable(), preRead, startId, null);
     return new DResult(ret, null);
   }
   Integer lockId = region.getLock(null, get.getRow(), true);
   try {
     Result r =
         MVCC.handleResult(this, getTrxMetaTable(), region.get(get, lockId), startId, lockId);
     return new DResult(r, null);
   } catch (TransactionOutOfDateException oode) {
     return new DResult(null, oode.getMessage());
   } catch (InvalidRowStatusException e) {
     return new DResult(null, e.getMessage());
   } finally {
     region.releaseRowLock(lockId);
   }
 }
Пример #2
0
 private static boolean containsStatus(Result r, long startId) {
   List<KeyValue> status = r.getColumn(DominoConst.INNER_FAMILY, DominoConst.STATUS_COL);
   if (status == null) return false;
   for (KeyValue kv : status) {
     if (kv.getTimestamp() == startId) return true;
   }
   return false;
 }
Пример #3
0
 @SuppressWarnings("deprecation")
 @Override
 public void commitRow(byte[] row, long startId, long commitId, boolean isDelete, Integer lockId)
     throws IOException {
   Get get = new Get(row);
   get.setMaxVersions();
   get.addFamily(DominoConst.INNER_FAMILY);
   Result r = region.get(get, lockId);
   if (!containsStatus(r, startId)) {
     // Other transaction may have committed this row of this version
     LOG.info(
         "Commit: No status found, returning: {}.{}", new String(this.getName()), new String(row));
     return;
   }
   List<KeyValue> versions = r.getColumn(DominoConst.INNER_FAMILY, DominoConst.VERSION_COL);
   Put commit = new Put(row);
   commit.setWriteToWAL(true);
   boolean isFresh = true;
   if (versions.size() >= DominoConst.MAX_VERSION) {
     // We need to clean the earliest version.
     LOG.info(
         "Commit: rolling version window: {}.{}", new String(this.getName()), new String(row));
     isFresh = addClearColumns(commit, versions, r, row, isDelete, commitId, startId, lockId);
   }
   KeyValue clearStatusKV =
       new KeyValue(
           row, DominoConst.INNER_FAMILY, DominoConst.STATUS_COL, startId, KeyValue.Type.Delete);
   commit.add(clearStatusKV);
   byte[] value = DominoConst.versionValue(startId, isDelete);
   if (isFresh) {
     KeyValue commitKV =
         new KeyValue(row, DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId, value);
     commit.add(commitKV);
   }
   // commitNumericModifications(row, startId, lockId, commit);
   mutateRow(commit, lockId);
 }