accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Billie J Rinaldi <billie.j.rina...@ugov.gov>
Subject Re: Bug in Range behavior?
Date Thu, 22 Mar 2012 15:08:38 GMT
When you create a new Key without specifying the timestamp, the Key is given a timestamp of
Long.MAX_VALUE.  So, that's why the Range in this example is strictly before and not equal
to the Key stored in Accumulo.  Range has static methods that can help you create the Range
you want.  For example, Range.exact("row", "colFam", "colQual") should include all Keys with
the specified "row", "colFam", and "colQual".  There are also Range.prefix methods.  Range.prefix("row",
"colFam", "colQual") would include all Keys with "row" and "colFam" whose column qualifiers
begin with "colQual".

Billie


On Thursday, March 22, 2012 10:39:33 AM, "Mark Drew" <drewmark@gmail.com> wrote:
> I believe I've found a bug (in version 1.3.5)--was going to submit it
> in Jira (didn't see anything there that looked like this bug), but
> couldn't figure out how to (or if I have permission to).
> 
> 
> When I create a Range using the same Key for both the start and end of
> the range, they are supposed to both be inclusive. (BTW, I get the
> same behavior when using the alternative Range constructor in which
> you explicitly specify inclusive or exclusive end points.) However,
> what I observe is that the key given as the end of the range is NOT
> included, even though it is supposed to be.
> 
> Here's some code that demonstrates the problem:
> 
> Connector conn = ...;
> String table = "dumb";
> 
> BatchWriter writer = null;
> try {
> long memBuf = 1000000L; // bytes to store before sending a batch
> long timeout = 100L; // milliseconds to wait before sending
> int numThreads = 10;
> writer = conn.createBatchWriter(table, memBuf, timeout, numThreads);
> 
> Mutation mutation = createMutation("row", "colFam", "colQual",
> "value");
> writer.addMutation(mutation);
> 
> } finally {
> if (writer != null) writer.close();
> }
> 
> Scanner scanner = conn.createScanner(table, new Authorizations());
> Key k = new Key("row", "colFam", "colQual");
> 
> System.out.println("\nbounded on both ends");
> scanner.setRange(new Range(k,k));
> for (Entry<Key, Value> entry : scanner) {
> System.out.println(" entry = " + entry);
> }
> 
> System.out.println("\nbounded below");
> scanner.setRange(new Range(k,null));
> for (Entry<Key, Value> entry : scanner) {
> System.out.println(" entry = " + entry);
> }
> 
> System.out.println("\nbounded above");
> scanner.setRange(new Range(null,k));
> for (Entry<Key, Value> entry : scanner) {
> System.out.println(" entry = " + entry);
> }
> 
> System.out.println("\nDone!");
> 
> This code produces:
> 
> 
> bounded on both ends
> 
> bounded below
> entry = row colFam:colQual [] 1332426309764 false value
> 
> bounded above
> 
> Done!
> 
> --Mark

Mime
View raw message