Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make various methods public (test code was in same package).

  • Loading branch information...
commit 80e5abb77d2bc8df46f1a2ccbc53f1f9026dc9d3 1 parent 2f0b22e
@krestenkrab authored
View
10 src/com/trifork/riak/BucketProperties.java
@@ -29,6 +29,16 @@ public Boolean getAllowMult() {
public Integer getNValue() {
return nValue;
}
+
+ public BucketProperties allowMult(boolean val) {
+ this.allowMult = val;
+ return this;
+ }
+
+ public BucketProperties nValue(int val) {
+ this.nValue = val;
+ return this;
+ }
RpbBucketProps build() {
Builder builder = RpbBucketProps.newBuilder();
View
2  src/com/trifork/riak/KeySource.java
@@ -82,7 +82,7 @@ private void get_next_response() throws IOException {
r = RPB.RpbListKeysResp.parseFrom(data);
i = 0;
- // did we got an empty chunk? get another one.
+ // did we got an empty chunk! get another one.
} while (r.getKeysCount() == 0);
}
View
8 src/com/trifork/riak/RequestMeta.java
@@ -45,22 +45,22 @@ public void preparePut(RPB.RpbPutReq.Builder builder) {
}
}
- RequestMeta returnBody(boolean ret) {
+ public RequestMeta returnBody(boolean ret) {
returnBody = Boolean.valueOf(ret);
return this;
}
- RequestMeta w(int w) {
+ public RequestMeta w(int w) {
w = new Integer(w);
return this;
}
- RequestMeta dw(int dw) {
+ public RequestMeta dw(int dw) {
dw = new Integer(dw);
return this;
}
- RequestMeta contentType(String contentType) {
+ public RequestMeta contentType(String contentType) {
this.contentType = contentType;
return this;
}
View
4 src/com/trifork/riak/RiakClient.java
@@ -292,9 +292,9 @@ public String getClientID() throws IOException {
builder.setVclock(value.getVclock());
}
- if (meta != null) {
+ builder.setReturnBody(false);
- builder.setReturnBody(false);
+ if (meta != null) {
if (meta.writeQuorum != null) {
builder.setW(meta.writeQuorum.intValue());
View
21 src/com/trifork/riak/RiakLink.java
@@ -18,6 +18,7 @@
package com.trifork.riak;
+import java.util.ArrayList;
import java.util.List;
import com.google.protobuf.ByteString;
@@ -36,10 +37,22 @@
this.tag = rpbLink.getTag();
}
- public static RiakLink[] decode(List<RpbLink> list) {
- RiakLink[] res = new RiakLink[list.size()];
- for (int i = 0; i < res.length; i++) {
- res[i] = new RiakLink(list.get(i));
+ public RiakLink(String bucket, String key, String tag) {
+ this.bucket = ByteString.copyFromUtf8(bucket);
+ this.key = ByteString.copyFromUtf8(key);
+ this.tag = ByteString.copyFromUtf8(tag);
+ }
+
+ public RiakLink(ByteString bucket, ByteString key, ByteString tag) {
+ this.bucket = (bucket);
+ this.key = (key);
+ this.tag = (tag);
+ }
+
+ public static List<RiakLink> decode(List<RpbLink> list) {
+ List<RiakLink> res = new ArrayList<RiakLink>();
+ for (int i = 0; i < list.size(); i++) {
+ res.add ( new RiakLink(list.get(i)) );
}
return res;
}
View
36 src/com/trifork/riak/RiakObject.java
@@ -18,8 +18,10 @@
package com.trifork.riak;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.protobuf.ByteString;
@@ -36,7 +38,7 @@
private ByteString value;
private String contentType;
- private RiakLink[] links;
+ private List<RiakLink> links;
private String vtag;
private String contentEncoding;
private String charset;
@@ -81,6 +83,12 @@ public RiakObject(ByteString bucket, ByteString key, ByteString content) {
this.value = content;
}
+ public RiakObject(String bucket, String key, byte[] content) {
+ this.bucket = ByteString.copyFromUtf8(bucket);
+ this.key = ByteString.copyFromUtf8(key);
+ this.value = ByteString.copyFrom(content);
+ }
+
public RiakObject(String bucket, String key, String content) {
this.bucket = ByteString.copyFromUtf8(bucket);
this.key = ByteString.copyFromUtf8(key);
@@ -135,9 +143,9 @@ RpbContent buildContent() {
b.setVtag(ByteString.copyFromUtf8(vtag));
}
- if (links != null && links.length != 0) {
- for (int i = 0; i < links.length; i++) {
- b.addLinks(links[i].build());
+ if (links != null && links.size() != 0) {
+ for (RiakLink l : links) {
+ b.addLinks( l.build() );
}
}
@@ -163,4 +171,24 @@ RpbContent buildContent() {
return b.build();
}
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public void addLink(String tag, String bucket,
+ String key) {
+ if (links == null) {
+ links = new ArrayList<RiakLink>();
+ }
+ links.add(new RiakLink(bucket, key, tag));
+ }
+
+ public void addLink(ByteString tag, ByteString bucket,
+ ByteString key) {
+ if (links == null) {
+ links = new ArrayList<RiakLink>();
+ }
+ links.add(new RiakLink(bucket, key, tag));
+ }
+
}
View
12 src/com/trifork/riak/mapreduce/MapReduceResponse.java
@@ -46,11 +46,21 @@ public MapReduceResponse(RpbMapRedResp resp, ByteString contentType2) {
this.contentType = contentType2;
}
- JSONArray getJSON() throws JSONException {
+ public JSONArray getJSON() throws JSONException {
if (response == null)
return null;
if (!APPLICATION_JSON.equals(contentType))
throw new IllegalArgumentException("not application/json");
return new JSONArray(response.toStringUtf8());
}
+
+ public ByteString getContent() {
+ if (response == null)
+ return null;
+ return response;
+ }
+
+ public String getContentType() {
+ return contentType.toStringUtf8();
+ }
}
View
2  test/com/trifork/riak/PushLotsOfData.java
@@ -14,7 +14,7 @@
public static void main(String[] args) throws IOException {
- RiakClient riak = new RiakClient("127.0.0.1");
+ RiakClient riak = new RiakClient("127.0.0.1", RiakConnection.DEFAULT_RIAK_PB_PORT);
long before = System.currentTimeMillis();
Please sign in to comment.
Something went wrong with that request. Please try again.