List of usage examples for org.apache.cassandra.dht Token isMinimum
public boolean isMinimum()
From source file:com.stratio.cassandra.index.TokenMapperMurmur.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w .j ava 2 s . co m protected Query makeQuery(Token lower, Token upper, boolean includeLower, boolean includeUpper) { Long start = lower == null ? null : (Long) lower.getTokenValue(); Long stop = upper == null ? null : (Long) upper.getTokenValue(); if (lower != null && lower.isMinimum()) { start = null; } if (upper != null && upper.isMinimum()) { stop = null; } if (start == null && stop == null) { return null; } return NumericRangeQuery.newLongRange(FIELD_NAME, start, stop, includeLower, includeUpper); }
From source file:com.stratio.cassandra.lucene.key.TokenMapper.java
License:Apache License
/** * Returns a Lucene {@link Query} to find the {@link Document}s containing a {@link Token} inside the specified * token range./*from w w w. j a v a2 s .c o m*/ * * @param lower the lower token * @param upper the upper token * @param includeLower if the lower token should be included * @param includeUpper if the upper token should be included * @return the query to find the documents containing a token inside the range */ public Optional<Query> query(Token lower, Token upper, boolean includeLower, boolean includeUpper) { // Skip if it's full data range if (lower.isMinimum() && upper.isMinimum()) { return Optional.empty(); } // Get token values Long start = lower.isMinimum() ? null : value(lower); Long stop = upper.isMinimum() ? null : value(upper); // Do with cache CacheKey cacheKey = new CacheKey(start, stop, includeLower, includeUpper); CachingWrapperQuery cachedQuery = cache.getIfPresent(cacheKey); if (cachedQuery == null) { Query query = DocValuesRangeQuery.newLongRange(FIELD_NAME, start, stop, includeLower, includeUpper); cachedQuery = new CachingWrapperQuery(query); cache.put(cacheKey, cachedQuery); } return Optional.of(cachedQuery); }