com.netflix.astyanax.cql.reads.model.CqlRowSlice Maven / Gradle / Ivy
package com.netflix.astyanax.cql.reads.model;
import java.util.Collection;
import com.netflix.astyanax.query.RowSliceQuery;
/**
* Helper class that encapsulates a row slice for a {@link RowSliceQuery}
*
* Note that there are 2 essential components for a row slice
*
* 1. Collection of individual row keys
* 2. Row range specification.
*
* The class has data structures to represent both these components and also has helpful methods to identify
* the type of row slice query.
*
* @author poberai
*
* @param
*/
public class CqlRowSlice {
// Stuff needed for the direct query using the in() clause
private Collection keys;
private RowRange range = new RowRange();
public static class RowRange {
// Stuff needed for the row range query
private K startKey;
private K endKey;
private String startToken;
private String endToken;
int count;
public K getStartKey() {
return startKey;
}
public K getEndKey() {
return endKey;
}
public String getStartToken() {
return startToken;
}
public String getEndToken() {
return endToken;
}
public int getCount() {
return count;
}
}
public CqlRowSlice(Collection keys) {
this.keys = keys;
}
public CqlRowSlice(K startKey, K endKey, String startToken, String endToken, int count) {
this.range.startKey = startKey;
this.range.endKey = endKey;
this.range.startToken = startToken;
this.range.endToken = endToken;
this.range.count = count;
}
public Collection getKeys() {
return keys;
}
public RowRange getRange() {
return range;
}
public boolean isCollectionQuery() {
return this.keys != null && keys.size() > 0;
}
public boolean isRangeQuery() {
return !isCollectionQuery() && range != null;
}
}