
com.basho.riak.client.api.commands.indexes.KeyIndexQuery Maven / Gradle / Ivy
package com.basho.riak.client.api.commands.indexes;
import com.basho.riak.client.core.operations.SecondaryIndexQueryOperation;
import com.basho.riak.client.core.query.Namespace;
import com.basho.riak.client.core.query.indexes.IndexNames;
import com.basho.riak.client.core.util.BinaryValue;
import com.basho.riak.client.core.util.DefaultCharset;
/**
* Performs a 2i query across the special $key index, for a known bucket & range of keys,
* and returns the keys within that range in that bucket.
*
*
* A KeyIndexQuery is used when you want to fetch a range of keys for a bucket. A namespace and a key range is needed.
*
*
* {@code
* Namespace ns = new Namespace("my_type", "my_bucket");
* KeyIndexQuery q = new KeyIndexQuery.Builder(ns, "foo10", "foo19").build();
* RawIndexquery.Response resp = client.execute(q);}
*
* @author Alex Moore
* @since 2.0.7
*/
public class KeyIndexQuery extends RawIndexQuery
{
private KeyIndexQuery(Init builder)
{
super(builder);
}
public static class Builder extends Init
{
public Builder(Namespace namespace, String start, String end)
{
this(namespace,
BinaryValue.unsafeCreate(start.getBytes(DefaultCharset.get())),
BinaryValue.unsafeCreate(end.getBytes(DefaultCharset.get())));
}
public Builder(Namespace namespace, BinaryValue start, BinaryValue end)
{
super(namespace, IndexNames.KEY, start, end);
}
@Override
protected Builder self()
{
return this;
}
public KeyIndexQuery build()
{
return new KeyIndexQuery(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy