Skip to content

Commit

Permalink
Add support for multiple column families in Get, Put and Delete reque…
Browse files Browse the repository at this point in the history
…sts.
  • Loading branch information
adityakishore committed Jan 17, 2014
1 parent bc1db42 commit cef2cdc
Show file tree
Hide file tree
Showing 8 changed files with 713 additions and 213 deletions.
5 changes: 5 additions & 0 deletions src/AtomicIncrementRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public byte[] family() {
return family;
}

@Override
public byte[][] getFamilies() {
return new byte[][] { family };
}

@Override
public byte[] qualifier() {
return qualifier;
Expand Down
35 changes: 28 additions & 7 deletions src/BatchableRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ abstract class BatchableRpc extends HBaseRpc
// So instead we make them package-private so that subclasses can still
// access them directly.

/** Family affected by this RPC. */
/*protected*/ final byte[] family;
/** Families affected by this RPC. */
/*protected*/ final byte[][] families;

/** The timestamp to use for {@link KeyValue}s of this RPC. */
/*protected*/ final long timestamp;
Expand All @@ -72,16 +72,16 @@ abstract class BatchableRpc extends HBaseRpc
* Package private constructor.
* @param table The name of the table this RPC is for.
* @param row The name of the row this RPC is for.
* @param family The column family to edit in that table. Subclass must
* validate, this class doesn't perform any validation on the family.
* @param families The column families to edit in that table. Subclass must
* validate, this class doesn't perform any validation on the families.
* @param timestamp The timestamp to use for {@link KeyValue}s of this RPC.
* @param lockid Explicit row lock to use, or {@link RowLock#NO_LOCK}.
*/
BatchableRpc(final byte[] table,
final byte[] key, final byte[] family,
final byte[] key, final byte[][] families,
final long timestamp, final long lockid) {
super(table, key);
this.family = family;
this.families = families;
this.timestamp = timestamp;
this.lockid = lockid;
}
Expand Down Expand Up @@ -116,7 +116,12 @@ public final void setDurable(final boolean durable) {

@Override
public final byte[] family() {
return family;
return families == null ? null : families[0];
}

@Override
public final byte[][] getFamilies() {
return families;
}

@Override
Expand Down Expand Up @@ -156,18 +161,34 @@ final boolean canBuffer() {

/**
* How many {@link KeyValue}s will be serialized by {@link #serializePayload}.
* Used with RPCs with single column families.
*/
abstract int numKeyValues();

/**
* An estimate of the number of bytes needed for {@link #serializePayload}.
* The estimate is conservative.
* Used with RPCs with single column families.
*/
abstract int payloadSize();

/**
* Serialize the part of this RPC for a {@link MultiAction}.
* Used with RPCs with single column families.
*/
abstract void serializePayload(final ChannelBuffer buf);

/**
* An estimate of the number of bytes needed for {@link #serializePayloads}.
* The estimate is conservative.
* Used with RPCs with multiple column families.
*/
abstract int payloadsSize();

/**
* Serialize the part of this RPC for a {@link MultiAction}.
* Used with RPCs with multiple column families.
*/
abstract void serializePayloads(final ChannelBuffer buf);

}
5 changes: 5 additions & 0 deletions src/CompareAndSetRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public byte[] family() {
return put.family();
}

@Override
public byte[][] getFamilies() {
return put.getFamilies();
}

@Override
public byte[] qualifier() {
return put.qualifier();
Expand Down
Loading

0 comments on commit cef2cdc

Please sign in to comment.