Index: hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestPayloadCarryingRpcController.java
===================================================================
--- hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestPayloadCarryingRpcController.java (revision 1479067)
+++ hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestPayloadCarryingRpcController.java (working copy)
@@ -157,7 +157,37 @@
public int getValueLength() {
return Bytes.SIZEOF_INT;
}
- };
+
+ @Override
+ public boolean hasTags() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int getTagsOffset() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getTagsLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getNumTags() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public byte[] getTagArray() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
}
private boolean hasCell = true;
Index: hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java
===================================================================
--- hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java (revision 1479067)
+++ hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java (working copy)
@@ -90,7 +90,7 @@
byte[] getFamilyArray();
/**
- * @return Array index of first row byte
+ * @return Array index of first family byte
*/
int getFamilyOffset();
@@ -167,5 +167,31 @@
* @return Number of value bytes. Must be < valueArray.length - offset.
*/
int getValueLength();
+
+ /**
+ * @return true - if tags are present in the Cell, false otherwise
+ */
+ boolean hasTags();
+
+ /**
+ * @return the first offset where the tags start in the Cell
+ */
+ int getTagsOffset();
+
+ /**
+ * @return the total length of the tags in the Cell.
+ */
+ int getTagsLength();
+
+ /**
+ * @return the total number of tags in the cell
+ */
+ int getNumTags();
+
+ /**
+ * @return the tag byte array
+ */
+ byte[] getTagArray();
+
}
Index: hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
===================================================================
--- hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java (revision 1479067)
+++ hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java (working copy)
@@ -28,6 +28,7 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.Bytes;
/**
* Utility methods helpful slinging {@link Cell} instances.
@@ -127,6 +128,23 @@
return new KeyValue(row, family, qualifier, timestamp,
KeyValue.Type.codeToType(type), value);
}
+
+ /**
+ * Should create a cell with the specified byte array that represents the tags
+ * Currently not implemented
+ * @param row
+ * @param family
+ * @param qualifier
+ * @param timestamp
+ * @param type
+ * @param value
+ * @param tags
+ * @return
+ */
+ public static Cell createCell(final byte [] row, final byte [] family, final byte [] qualifier,
+ final long timestamp, final byte type, final byte [] value, byte[] tags) {
+ return null;
+ }
/**
* @param cellScannerables
@@ -154,7 +172,7 @@
}
};
}
-
+
/**
* @param cellIterable
* @return CellScanner interface over cellIterable
@@ -242,4 +260,50 @@
}
};
}
+
+ /********************* tags *************************************/
+ /**
+ * Provides an iterator that iterates the tag part of the cell.
+ * If a cell has more than one tag, calling iterator.next() will
+ * return the individual byte array of the tag
+ * @param cell
+ * @return
+ */
+ public static Iterator getTagIterator(final Cell cell) {
+ byte[] tagArray = cell.getTagArray();
+ int tagsOffset = cell.getTagsOffset();
+ int tagsLength = cell.getTagsLength();
+ byte[] tags = new byte[tagsLength];
+ Bytes.putBytes(tags, 0, tagArray, tagsOffset, tagsLength);
+ return getTagIterator(tags);
+ }
+
+ /**
+ * Provides an iterator that iterates the tag part of the cell.
+ * If a cell has more than one tag, calling iterator.next() will
+ * return the individual byte array of the tag
+ * @param tags - the entire byte array of the tag
+ * @return
+ */
+ public static Iterator getTagIterator(final byte[] tags) {
+ return new Iterator() {
+
+ @Override
+ public boolean hasNext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public byte[] next() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+
}
Index: hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
===================================================================
--- hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java (revision 1479067)
+++ hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java (working copy)
@@ -2806,4 +2806,32 @@
sum += Bytes.SIZEOF_LONG;// memstoreTS
return ClassSize.align(sum);
}
+
+ @Override
+ public boolean hasTags() {
+ return false;
+ }
+
+ @Override
+ // Not implemented
+ public int getTagsOffset() {
+ return 0;
+ }
+
+ @Override
+ // Not implemented
+ public int getTagsLength() {
+ return 0;
+ }
+
+ @Override
+ // Not implemented
+ public int getNumTags() {
+ return 0;
+ }
+
+ @Override
+ public byte[] getTagArray() {
+ return null;
+ }
}
Index: hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/PrefixTreeCell.java
===================================================================
--- hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/PrefixTreeCell.java (revision 1479067)
+++ hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/PrefixTreeCell.java (working copy)
@@ -194,4 +194,29 @@
return kv.toString();
}
+ @Override
+ public boolean hasTags() {
+ return false;
+ }
+
+ @Override
+ public int getTagsOffset() {
+ return 0;
+ }
+
+ @Override
+ public int getTagsLength() {
+ return 0;
+ }
+
+ @Override
+ public int getNumTags() {
+ return 0;
+ }
+
+ @Override
+ public byte[] getTagArray() {
+ return null;
+ }
+
}