public String toString() { return getLeftBound() + ":" + getRightBound(); } }
/** * @param indexName * @param scope * @param reverse * @param table * @return * @throws SqlJetException */ private boolean isNeedReverse(final ISqlJetBtreeIndexTable indexTable, SqlJetScope scope) throws SqlJetException { Object[] firstKey = scope.getLeftBound() != null ? scope.getLeftBound().getValue() : null; Object[] lastKey = scope.getRightBound() != null ? scope.getRightBound().getValue() : null; if (firstKey != null && lastKey != null && firstKey.length > 0 && lastKey.length > 0) { if (indexTable != null) { return indexTable.compareKeys(firstKey, lastKey) < 0; } else if (firstKey.length == 1 && lastKey.length == 1 && firstKey[0] instanceof Long && lastKey[0] instanceof Long) { return ((Long) firstKey[0]).compareTo((Long) lastKey[0]) > 0; } } return false; }
public SqlJetScope reverse() { SqlJetScopeBound rightBound = getRightBound() != null ? new SqlJetScopeBound(getRightBound().getValue(), getRightBound().isInclusive()) : null; SqlJetScopeBound leftBound = getLeftBound() != null ? new SqlJetScopeBound(getLeftBound().getValue(), getLeftBound().isInclusive()) : null; return new SqlJetScope(rightBound, leftBound); }
/** * @param table * @param db * @param indexName * @param scope * @throws SqlJetException */ public SqlJetIndexScopeCursor(ISqlJetBtreeDataTable table, SqlJetDb db, String indexName, SqlJetScope scope) throws SqlJetException { super(table, db, indexName); this.firstKey = SqlJetUtility.copyArray(scope.getLeftBound() != null ? scope.getLeftBound().getValue() : null); this.firstKeyIncluded = scope.getLeftBound() != null ? scope.getLeftBound().isInclusive() : true; this.lastKey = SqlJetUtility.copyArray(scope.getRightBound() != null ? scope.getRightBound().getValue() : null); this.lastKeyIncluded = scope.getRightBound() != null ? scope.getRightBound().isInclusive() : true; if (null == indexTable) { firstRowId = getRowIdFromKey(this.firstKey); lastRowId = getRowIdFromKey(this.lastKey); if (!firstKeyIncluded && firstRowId > 0) { firstRowId++; } if (!lastKeyIncluded && lastRowId > 0) { lastRowId--; } } first(); }
public static final SqlJetScope adjustScopeNumberTypes(SqlJetScope scope) { if (null == scope) return null; SqlJetScopeBound leftBound = scope.getLeftBound(); SqlJetScopeBound rightBound = scope.getRightBound(); if (leftBound != null) { leftBound = new SqlJetScopeBound(adjustNumberTypes(leftBound.getValue()), leftBound.isInclusive()); } if (rightBound != null) { rightBound = new SqlJetScopeBound(adjustNumberTypes(rightBound.getValue()), rightBound.isInclusive()); } return new SqlJetScope(leftBound, rightBound); }