Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed vbucket array type from int to short.

We changed this implementation in the spymecached tap client. This
change makes this compatible with the new Spymemcached code.

Change-Id: I0ebc010e8948c0e497cd805bcbb30a2736f875e6
Reviewed-on: http://review.couchbase.org/10296
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
  • Loading branch information...
commit c967d4a7434d6f66099c8dc6b549c92b4809aad6 1 parent 4972608
Mike Wiederhold mikewied authored mikewied committed
10 src/java/com/couchbase/sqoop/mapreduce/db/CouchbaseInputFormat.java
View
@@ -98,10 +98,10 @@ public CouchbaseConfiguration getDBConf() {
List<InputSplit> splits = new ArrayList<InputSplit>();
int splitIndex = 0;
- int[] curSplit = nextEmptySplit(itemsPerChunk, extraItems);
+ short[] curSplit = nextEmptySplit(itemsPerChunk, extraItems);
extraItems--;
- for (int i = 0; i < numVBuckets + 1; i++) {
+ for (short i = 0; i < numVBuckets + 1; i++) {
if (splitIndex == curSplit.length) {
CouchbaseInputSplit split = new CouchbaseInputSplit(curSplit);
splits.add(split);
@@ -115,11 +115,11 @@ public CouchbaseConfiguration getDBConf() {
return splits;
}
- private int[] nextEmptySplit(int itemsPerChunk, int extraItems) {
+ private short[] nextEmptySplit(int itemsPerChunk, int extraItems) {
if (extraItems > 0) {
- return new int[itemsPerChunk + 1];
+ return new short[itemsPerChunk + 1];
} else {
- return new int[itemsPerChunk];
+ return new short[itemsPerChunk];
}
}
}
22 src/java/com/couchbase/sqoop/mapreduce/db/CouchbaseInputSplit.java
View
@@ -31,18 +31,18 @@
public class CouchbaseInputSplit extends InputSplit implements Writable {
// A location here is synonymous with a vbucket.
- private int[] locations;
+ private short[] locations;
public CouchbaseInputSplit() {
// Empty
}
- public CouchbaseInputSplit(int[] locs) {
+ public CouchbaseInputSplit(short[] locs) {
locations = locs;
}
- public CouchbaseInputSplit(List<Integer> locs) {
- locations = new int[locs.size()];
+ public CouchbaseInputSplit(List<Short> locs) {
+ locations = new short[locs.size()];
for (int i = 0; i < locs.size(); i++) {
locations[i] = locs.get(i);
@@ -59,30 +59,30 @@ public long getLength() throws IOException, InterruptedException {
String[] sLocs = new String[locations.length];
for (int i = 0; i < locations.length; i++) {
- sLocs[i] = Integer.toString(locations[i]);
+ sLocs[i] = Short.toString(locations[i]);
}
return sLocs;
}
- public int[] getVBuckets() {
+ public short[] getVBuckets() {
return locations;
}
@Override
public void readFields(DataInput input) throws IOException {
- int length = input.readInt();
- locations = new int[length];
+ int length = input.readShort();
+ locations = new short[length];
for (int i = 0; i < locations.length; i++) {
- locations[i] = input.readInt();
+ locations[i] = input.readShort();
}
}
@Override
public void write(DataOutput output) throws IOException {
- output.writeInt(locations.length);
+ output.writeShort(locations.length);
for (int i = 0; i < locations.length; i++) {
- output.writeInt(locations[i]);
+ output.writeShort(locations[i]);
}
}
5 src/java/com/couchbase/sqoop/mapreduce/db/CouchbaseRecordReader.java
View
@@ -126,15 +126,14 @@ public void initialize(InputSplit splits, TaskAttemptContext context)
builder.doDump();
builder.supportAck();
builder.specifyVbuckets(((CouchbaseInputSplit)split).getVBuckets());
- client.tapCustom(null, builder.getMessage(), null, null);
+ client.tapCustom(null, builder.getMessage());
} else if (tableName.startsWith("BACKFILL_")) {
String time = tableName.substring("BACKFILL_".length(),
tableName.length());
builder.doBackfill(0);
builder.supportAck();
builder.specifyVbuckets(((CouchbaseInputSplit)split).getVBuckets());
- Operation op = client.tapCustom(null, builder.getMessage(), null,
- null);
+ Operation op = client.tapCustom(null, builder.getMessage());
createTapStreamTimeout(op, (new Long(time)).intValue());
}
} catch (ConfigurationException e) {
Please sign in to comment.
Something went wrong with that request. Please try again.