Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

2i integer indexes limited to Integer.MAX_VALUE #112

Closed
broach opened this Issue · 5 comments

4 participants

@broach

The addIndex() method in the IRiakObject takes an int as its second argument. This limits the value to Integer.MAX_VALUE (2^31-1). Riak/erlang do not have this limitation nor does the HTTP or Protocol Buffers API.

@broach broach was assigned
@broach

This is currently blocked as you can not fix it without breaking the IRiakObject interface. This will have to wait until a major revision.

@deepak-bala

Which riak release can we expect to have this change ? I need it desperately :)

For those that need to perform range queries, you can use the following work around (its not very efficient mind you)

// Declare a java reduce function that returns all rows after arg[0]
public static JSSourceFunction MY_FUNCTION = new JSSourceFunction(
            "function(value, arg) { " +
    "var time = arg[0]; " +
    "var length = value.length; " +
    "var result = new Array(); " + 
    "var counter=0; " +
    "for (var i = 0; i < length; i++) " + 
    "{ " +
        "var element = value[i]; " +
        "if (element.timeUnit > time) " +
        "{ " +
            "result[counter] = element; " +
            "counter++; " +
        "} " +
    "}" +
    "return result; " +
"} " 
            );

// Use it in your map reduce query
client.mapReduce(BUCKET).addKeyFilter(filter)
                    .addLinkPhase(BUCKET_X, "_")
                    .addMapPhase(ANOTHER_FUNCTION)
                    .addReducePhase(MY_FUNCTION, new Long [] {after})
                    .execute();
@russelldb
Owner

Can we make an additive change, like add duplicate methods with either Number or BigInteger in the signature, mark the old methods deprecated and remove them later. That way we can have a none-interface breaking fix sooner rather than later?

@guidomedina

Or could it be handled internally and look for annotations at either Integer or Long types and then use a sort of Long.valueOf(..) assuming it will take either Integer or Long as parameter and just treat them all as Longs. If you always expect a long and receive int it shouldn't break for old code; though I haven't exactly look at the source code, I can only talk from the annotation perspective (POJO/domain style)

@broach broach referenced this issue from a commit
@broach broach Change 2i to use long values
The original implementation of 2i used int for _int indexes
which is caused an upper bound of 2^31. The client will
now use long values eliminating this restriction.

When possible backwards compatability was maintained, specifically
regarding the @RiakIndex notation and the FetchIndex class. Users of
the IRiakObject interface calling getIntIndex() or allIntIndexes()
will need to change the type being returned from Set<Integer> to Set<Long>

This addresses #112
21c8f2f
@russelldb russelldb was assigned
@broach broach closed this
@deepak-bala

Awesome. Looking forward to this on the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.