org.sirix.index.SearchMode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package org.sirix.index;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Comparator;
/**
* The search mode in a datastructure.
*
* @author Johannes Lichtenberger
*
*/
public enum SearchMode {
/** Greater than the specified key. */
GREATER {
@Override
public > int compare(K firstKey, @NonNull K secondKey) {
return secondKey.compareTo(firstKey) > 0 ? 0 : -1;
}
@Override
public > int compare(K firstKey, K secondKey,
Comparator super K> comparator) {
return comparator.compare(secondKey, firstKey) > 0 ? 0 : -1;
}
},
/** Lower than the specified key. */
LOWER {
@Override
public > int compare(K firstKey, @NonNull K secondKey) {
return secondKey.compareTo(firstKey) < 0 ? 0 : -1;
}
@Override
public > int compare(K firstKey, K secondKey,
Comparator super K> comparator) {
return comparator.compare(secondKey, firstKey) < 0 ? 0 : -1;
}
},
/** Greater or equal than the specified key. */
GREATER_OR_EQUAL {
@Override
public > int compare(K firstKey, @NonNull K secondKey) {
return secondKey.compareTo(firstKey) >= 0 ? 0 : -1;
}
@Override
public > int compare(K firstKey, K secondKey,
Comparator super K> comparator) {
return comparator.compare(secondKey, firstKey) >= 0 ? 0 : -1;
}
},
/** Lower or equal than the specified key. */
LOWER_OR_EQUAL {
@Override
public > int compare(K firstKey, @NonNull K secondKey) {
return secondKey.compareTo(firstKey) <= 0 ? 0 : -1;
}
@Override
public > int compare(K firstKey, K secondKey,
Comparator super K> comparator) {
return comparator.compare(secondKey, firstKey) <= 0 ? 0 : -1;
}
},
/** Equal to the specified key. */
EQUAL {
@Override
public > int compare(K firstKey, @NonNull K secondKey) {
return firstKey.compareTo(secondKey);
}
@Override
public > int compare(K firstKey, K secondKey,
Comparator super K> comparator) {
return comparator.compare(firstKey, secondKey);
}
};
/**
* Compare two keys.
*
* @param firstKey the search key
* @param secondKey the potential result key
* @return {@code 0} if it's in the search space, else {@code -1} or {@code +1}
*/
public abstract > int compare(final K firstKey,
final K secondKey);
public abstract > int compare(final K firstKey, final K secondKey,
final Comparator super K> comparator);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy