/** * @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 String toString() { StringBuffer sb = new StringBuffer(); sb.append(isInclusive() ? '[' : '('); if (getValue() == null) { sb.append(getValue()); } else if (getValue().length > 0) { sb.append(getValue()[0]); if (getValue().length > 1) { sb.append(",..."); } } sb.append(isInclusive() ? ']' : ')'); return sb.toString(); } }
/** * @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 SqlJetScope(Object[] leftKey, boolean isLeftKeyIncluded, Object[] rightKey, boolean isRightKeyIncluded) { this(new SqlJetScopeBound(leftKey, isLeftKeyIncluded), new SqlJetScopeBound(rightKey, isRightKeyIncluded)); }
public SqlJetScope(Object[] leftKey, Object[] rightKey) { this(new SqlJetScopeBound(leftKey), new SqlJetScopeBound(rightKey)); }
public SqlJetScope(SqlJetScopeBound leftBound, SqlJetScopeBound rightBound) { myLeftBound = leftBound == null ? new SqlJetScopeBound(null, true) : leftBound; myRightBound = rightBound == null ? new SqlJetScopeBound(null, true) : rightBound; }
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); }
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); }