@Override
 public boolean next() {
   synchronized (sync) {
     if (SysProperties.CHECK && end) {
       DbException.throwInternalError();
     }
     while (true) {
       if (needNewDelta) {
         loadNext(false);
         needNewDelta = false;
       }
       if (needNewBase) {
         loadNext(true);
         needNewBase = false;
       }
       if (deltaRow == null) {
         if (baseRow == null) {
           end = true;
           return false;
         }
         onBase = true;
         needNewBase = true;
         return true;
       }
       int sessionId = deltaRow.getSessionId();
       boolean isThisSession = sessionId == session.getId();
       boolean isDeleted = deltaRow.isDeleted();
       if (isThisSession && isDeleted) {
         needNewDelta = true;
         continue;
       }
       if (baseRow == null) {
         if (isDeleted) {
           if (isThisSession) {
             end = true;
             return false;
           }
           // the row was deleted by another session: return it
           onBase = false;
           needNewDelta = true;
           return true;
         }
         DbException.throwInternalError();
       }
       int compare = index.compareRows(deltaRow, baseRow);
       if (compare == 0) {
         // can't use compareKeys because the
         // version would be compared as well
         long k1 = deltaRow.getKey();
         long k2 = baseRow.getKey();
         compare = MathUtils.compareLong(k1, k2);
       }
       if (compare == 0) {
         if (isDeleted) {
           if (isThisSession) {
             DbException.throwInternalError();
           }
           // another session updated the row
         } else {
           if (isThisSession) {
             onBase = false;
             needNewBase = true;
             needNewDelta = true;
             return true;
           }
           // another session inserted the row: ignore
           needNewBase = true;
           needNewDelta = true;
           continue;
         }
       }
       if (compare > 0) {
         onBase = true;
         needNewBase = true;
         return true;
       }
       onBase = false;
       needNewDelta = true;
       return true;
     }
   }
 }
Ejemplo n.º 2
0
 protected int compareSecure(Value o, CompareMode mode) {
   return MathUtils.compareLong(nanos, ((ValueTime) o).nanos);
 }
Ejemplo n.º 3
0
 public boolean next() {
   synchronized (this.sync) {
     if ((SysProperties.CHECK) && (this.end)) {
       DbException.throwInternalError();
     }
     int compare;
     for (; ; ) {
       if (this.needNewDelta) {
         loadNext(false);
         this.needNewDelta = false;
       }
       if (this.needNewBase) {
         loadNext(true);
         this.needNewBase = false;
       }
       if (this.deltaRow == null) {
         if (this.baseRow == null) {
           this.end = true;
           return false;
         }
         this.onBase = true;
         this.needNewBase = true;
         return true;
       }
       int sessionId = this.deltaRow.getSessionId();
       boolean isThisSession = sessionId == this.session.getId();
       boolean isDeleted = this.deltaRow.isDeleted();
       if ((isThisSession) && (isDeleted)) {
         this.needNewDelta = true;
       } else {
         if (this.baseRow == null) {
           if (isDeleted) {
             if (isThisSession) {
               this.end = true;
               return false;
             }
             this.onBase = false;
             this.needNewDelta = true;
             return true;
           }
           DbException.throwInternalError();
         }
         compare = this.index.compareRows(this.deltaRow, this.baseRow);
         if (compare == 0) {
           long k1 = this.deltaRow.getKey();
           long k2 = this.baseRow.getKey();
           compare = MathUtils.compareLong(k1, k2);
         }
         if (compare != 0) {
           break;
         }
         if (isDeleted) {
           if (!isThisSession) {
             break;
           }
           DbException.throwInternalError();
           break;
         }
         if (isThisSession) {
           this.onBase = false;
           this.needNewBase = true;
           this.needNewDelta = true;
           return true;
         }
         this.needNewBase = true;
         this.needNewDelta = true;
       }
     }
     if (compare > 0) {
       this.onBase = true;
       this.needNewBase = true;
       return true;
     }
     this.onBase = false;
     this.needNewDelta = true;
     return true;
   }
 }