本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于org.apache.hadoop.hbase.protobuf.generated.ClientProtos包,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGetRowOrBeforeRequest
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a new protocol buffer GetRequest to get a row, all columns in a family.
* If there is no such row, return the closest row before it.
*
* @param regionName the name of the region to get
* @param row the row to get
* @param family the column family to get
* should return the immediate row before
* @return a protocol buffer GetReuqest
*/
public static GetRequest buildGetRowOrBeforeRequest(
final byte[] regionName, final byte[] row, final byte[] family) {
GetRequest.Builder builder = GetRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(
RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteStringer.wrap(family));
ClientProtos.Get.Builder getBuilder =
ClientProtos.Get.newBuilder();
getBuilder.setRow(ByteStringer.wrap(row));
getBuilder.addColumn(columnBuilder.build());
getBuilder.setClosestRowBefore(true);
builder.setGet(getBuilder.build());
return builder.build();
}
示例2: buildGetRowOrBeforeRequest
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a new protocol buffer GetRequest to get a row, all columns in a family.
* If there is no such row, return the closest row before it.
*
* @param regionName the name of the region to get
* @param row the row to get
* @param family the column family to get
* should return the immediate row before
* @return a protocol buffer GetReuqest
*/
public static GetRequest buildGetRowOrBeforeRequest(
final byte[] regionName, final byte[] row, final byte[] family) {
GetRequest.Builder builder = GetRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(
RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(HBaseZeroCopyByteString.wrap(family));
ClientProtos.Get.Builder getBuilder =
ClientProtos.Get.newBuilder();
getBuilder.setRow(HBaseZeroCopyByteString.wrap(row));
getBuilder.addColumn(columnBuilder.build());
getBuilder.setClosestRowBefore(true);
builder.setGet(getBuilder.build());
return builder.build();
}
示例3: buildGetRowOrBeforeRequest
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a new protocol buffer GetRequest to get a row, all columns in a family.
* If there is no such row, return the closest row before it.
*
* @param regionName the name of the region to get
* @param row the row to get
* @param family the column family to get
* should return the immediate row before
* @return a protocol buffer GetReuqest
*/
public static GetRequest buildGetRowOrBeforeRequest(
final byte[] regionName, final byte[] row, final byte[] family) {
GetRequest.Builder builder = GetRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(
RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ZeroCopyLiteralByteString.wrap(family));
ClientProtos.Get.Builder getBuilder =
ClientProtos.Get.newBuilder();
getBuilder.setRow(ZeroCopyLiteralByteString.wrap(row));
getBuilder.addColumn(columnBuilder.build());
getBuilder.setClosestRowBefore(true);
builder.setGet(getBuilder.build());
return builder.build();
}
示例4: buildGetRowOrBeforeRequest
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a new protocol buffer GetRequest to get a row, all columns in a family.
* If there is no such row, return the closest row before it.
*
* @param regionName the name of the region to get
* @param row the row to get
* @param family the column family to get
* should return the immediate row before
* @return a protocol buffer GetReuqest
*/
public static GetRequest buildGetRowOrBeforeRequest(
final byte[] regionName, final byte[] row, final byte[] family) {
GetRequest.Builder builder = GetRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(
RegionSpecifierType.REGION_NAME, regionName);
builder.setClosestRowBefore(true);
builder.setRegion(region);
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteString.copyFrom(family));
ClientProtos.Get.Builder getBuilder =
ClientProtos.Get.newBuilder();
getBuilder.setRow(ByteString.copyFrom(row));
getBuilder.addColumn(columnBuilder.build());
builder.setGet(getBuilder.build());
return builder.build();
}
示例5: testGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Test basic Get conversions.
*
* @throws IOException
*/
@Test
public void testGet() throws IOException {
ClientProtos.Get.Builder getBuilder = ClientProtos.Get.newBuilder();
getBuilder.setRow(ByteString.copyFromUtf8("row"));
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteString.copyFromUtf8("f1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c2"));
getBuilder.addColumn(columnBuilder.build());
columnBuilder.clear();
columnBuilder.setFamily(ByteString.copyFromUtf8("f2"));
getBuilder.addColumn(columnBuilder.build());
ClientProtos.Get proto = getBuilder.build();
// default fields
assertEquals(1, proto.getMaxVersions());
assertEquals(true, proto.getCacheBlocks());
// set the default value for equal comparison
getBuilder = ClientProtos.Get.newBuilder(proto);
getBuilder.setMaxVersions(1);
getBuilder.setCacheBlocks(true);
Get get = ProtobufUtil.toGet(proto);
assertEquals(getBuilder.build(), ProtobufUtil.toGet(get));
}
示例6: testScan
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Test basic Scan conversions.
*
* @throws IOException
*/
@Test
public void testScan() throws IOException {
ClientProtos.Scan.Builder scanBuilder = ClientProtos.Scan.newBuilder();
scanBuilder.setStartRow(ByteString.copyFromUtf8("row1"));
scanBuilder.setStopRow(ByteString.copyFromUtf8("row2"));
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteString.copyFromUtf8("f1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c2"));
scanBuilder.addColumn(columnBuilder.build());
columnBuilder.clear();
columnBuilder.setFamily(ByteString.copyFromUtf8("f2"));
scanBuilder.addColumn(columnBuilder.build());
ClientProtos.Scan proto = scanBuilder.build();
// Verify default values
assertEquals(1, proto.getMaxVersions());
assertEquals(true, proto.getCacheBlocks());
// Verify fields survive ClientProtos.Scan -> Scan -> ClientProtos.Scan
// conversion
scanBuilder = ClientProtos.Scan.newBuilder(proto);
scanBuilder.setMaxVersions(2);
scanBuilder.setCacheBlocks(false);
scanBuilder.setCaching(1024);
ClientProtos.Scan expectedProto = scanBuilder.build();
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
ProtobufUtil.toScan(expectedProto));
assertEquals(expectedProto, actualProto);
}
示例7: testScan
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Test basic Scan conversions.
*
* @throws IOException
*/
@Test
public void testScan() throws IOException {
ClientProtos.Scan.Builder scanBuilder = ClientProtos.Scan.newBuilder();
scanBuilder.setStartRow(ByteString.copyFromUtf8("row1"));
scanBuilder.setStopRow(ByteString.copyFromUtf8("row2"));
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteString.copyFromUtf8("f1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c2"));
scanBuilder.addColumn(columnBuilder.build());
columnBuilder.clear();
columnBuilder.setFamily(ByteString.copyFromUtf8("f2"));
scanBuilder.addColumn(columnBuilder.build());
ClientProtos.Scan proto = scanBuilder.build();
// default fields
assertEquals(1, proto.getMaxVersions());
assertEquals(true, proto.getCacheBlocks());
scanBuilder = ClientProtos.Scan.newBuilder(proto);
scanBuilder.setMaxVersions(1);
scanBuilder.setCacheBlocks(true);
Scan scan = ProtobufUtil.toScan(proto);
assertEquals(scanBuilder.build(), ProtobufUtil.toScan(scan));
}
示例8: testGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Test basic Get conversions.
*
* @throws IOException
*/
@Test
public void testGet() throws IOException {
ClientProtos.Get.Builder getBuilder = ClientProtos.Get.newBuilder();
getBuilder.setRow(ByteString.copyFromUtf8("row"));
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setFamily(ByteString.copyFromUtf8("f1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c1"));
columnBuilder.addQualifier(ByteString.copyFromUtf8("c2"));
getBuilder.addColumn(columnBuilder.build());
columnBuilder.clear();
columnBuilder.setFamily(ByteString.copyFromUtf8("f2"));
getBuilder.addColumn(columnBuilder.build());
getBuilder.setLoadColumnFamiliesOnDemand(true);
ClientProtos.Get proto = getBuilder.build();
// default fields
assertEquals(1, proto.getMaxVersions());
assertEquals(true, proto.getCacheBlocks());
// set the default value for equal comparison
getBuilder = ClientProtos.Get.newBuilder(proto);
getBuilder.setMaxVersions(1);
getBuilder.setCacheBlocks(true);
Get get = ProtobufUtil.toGet(proto);
assertEquals(getBuilder.build(), ProtobufUtil.toGet(get));
}
示例9: toGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a protocol buffer Get based on a client Get.
*
* @param get the client Get
* @return a protocol buffer Get
* @throws IOException
*/
public static ClientProtos.Get toGet(
final Get get) throws IOException {
ClientProtos.Get.Builder builder =
ClientProtos.Get.newBuilder();
builder.setRow(ByteStringer.wrap(get.getRow()));
builder.setCacheBlocks(get.getCacheBlocks());
builder.setMaxVersions(get.getMaxVersions());
if (get.getFilter() != null) {
builder.setFilter(ProtobufUtil.toFilter(get.getFilter()));
}
for (Entry<byte[], TimeRange> cftr : get.getColumnFamilyTimeRange().entrySet()) {
HBaseProtos.ColumnFamilyTimeRange.Builder b = HBaseProtos.ColumnFamilyTimeRange.newBuilder();
b.setColumnFamily(ByteString.copyFrom(cftr.getKey()));
b.setTimeRange(timeRangeToProto(cftr.getValue()));
builder.addCfTimeRange(b);
}
TimeRange timeRange = get.getTimeRange();
if (!timeRange.isAllTime()) {
HBaseProtos.TimeRange.Builder timeRangeBuilder =
HBaseProtos.TimeRange.newBuilder();
timeRangeBuilder.setFrom(timeRange.getMin());
timeRangeBuilder.setTo(timeRange.getMax());
builder.setTimeRange(timeRangeBuilder.build());
}
Map<String, byte[]> attributes = get.getAttributesMap();
if (!attributes.isEmpty()) {
NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
attributeBuilder.setName(attribute.getKey());
attributeBuilder.setValue(ByteStringer.wrap(attribute.getValue()));
builder.addAttribute(attributeBuilder.build());
}
}
if (get.hasFamilies()) {
Column.Builder columnBuilder = Column.newBuilder();
Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap();
for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) {
NavigableSet<byte[]> qualifiers = family.getValue();
columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
columnBuilder.clearQualifier();
if (qualifiers != null && qualifiers.size() > 0) {
for (byte[] qualifier: qualifiers) {
columnBuilder.addQualifier(ByteStringer.wrap(qualifier));
}
}
builder.addColumn(columnBuilder.build());
}
}
if (get.getMaxResultsPerColumnFamily() >= 0) {
builder.setStoreLimit(get.getMaxResultsPerColumnFamily());
}
if (get.getRowOffsetPerColumnFamily() > 0) {
builder.setStoreOffset(get.getRowOffsetPerColumnFamily());
}
if (get.isCheckExistenceOnly()){
builder.setExistenceOnly(true);
}
if (get.isClosestRowBefore()){
builder.setClosestRowBefore(true);
}
if (get.getConsistency() != null && get.getConsistency() != Consistency.STRONG) {
builder.setConsistency(toConsistency(get.getConsistency()));
}
return builder.build();
}
示例10: toGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Convert a protocol buffer Get to a client Get
*
* @param proto the protocol buffer Get to convert
* @return the converted client Get
* @throws IOException
*/
public static Get toGet(
final ClientProtos.Get proto) throws IOException {
if (proto == null) return null;
byte[] row = proto.getRow().toByteArray();
Get get = new Get(row);
if (proto.hasCacheBlocks()) {
get.setCacheBlocks(proto.getCacheBlocks());
}
if (proto.hasMaxVersions()) {
get.setMaxVersions(proto.getMaxVersions());
}
if (proto.hasStoreLimit()) {
get.setMaxResultsPerColumnFamily(proto.getStoreLimit());
}
if (proto.hasStoreOffset()) {
get.setRowOffsetPerColumnFamily(proto.getStoreOffset());
}
if (proto.hasTimeRange()) {
HBaseProtos.TimeRange timeRange = proto.getTimeRange();
long minStamp = 0;
long maxStamp = Long.MAX_VALUE;
if (timeRange.hasFrom()) {
minStamp = timeRange.getFrom();
}
if (timeRange.hasTo()) {
maxStamp = timeRange.getTo();
}
get.setTimeRange(minStamp, maxStamp);
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();
get.setFilter(ProtobufUtil.toFilter(filter));
}
for (NameBytesPair attribute: proto.getAttributeList()) {
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
}
if (proto.getColumnCount() > 0) {
for (Column column: proto.getColumnList()) {
byte[] family = column.getFamily().toByteArray();
if (column.getQualifierCount() > 0) {
for (ByteString qualifier: column.getQualifierList()) {
get.addColumn(family, qualifier.toByteArray());
}
} else {
get.addFamily(family);
}
}
}
if (proto.hasExistenceOnly() && proto.getExistenceOnly()){
get.setCheckExistenceOnly(true);
}
if (proto.hasClosestRowBefore() && proto.getClosestRowBefore()){
get.setClosestRowBefore(true);
}
if (proto.hasConsistency()) {
get.setConsistency(toConsistency(proto.getConsistency()));
}
return get;
}
示例11: toGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Convert a protocol buffer Get to a client Get
*
* @param proto the protocol buffer Get to convert
* @return the converted client Get
* @throws IOException
*/
public static Get toGet(
final ClientProtos.Get proto) throws IOException {
if (proto == null) return null;
byte[] row = proto.getRow().toByteArray();
Get get = new Get(row);
if (proto.hasCacheBlocks()) {
get.setCacheBlocks(proto.getCacheBlocks());
}
if (proto.hasMaxVersions()) {
get.setMaxVersions(proto.getMaxVersions());
}
if (proto.hasStoreLimit()) {
get.setMaxResultsPerColumnFamily(proto.getStoreLimit());
}
if (proto.hasStoreOffset()) {
get.setRowOffsetPerColumnFamily(proto.getStoreOffset());
}
if (proto.hasTimeRange()) {
HBaseProtos.TimeRange timeRange = proto.getTimeRange();
long minStamp = 0;
long maxStamp = Long.MAX_VALUE;
if (timeRange.hasFrom()) {
minStamp = timeRange.getFrom();
}
if (timeRange.hasTo()) {
maxStamp = timeRange.getTo();
}
get.setTimeRange(minStamp, maxStamp);
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();
get.setFilter(ProtobufUtil.toFilter(filter));
}
for (NameBytesPair attribute: proto.getAttributeList()) {
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
}
if (proto.getColumnCount() > 0) {
for (Column column: proto.getColumnList()) {
byte[] family = column.getFamily().toByteArray();
if (column.getQualifierCount() > 0) {
for (ByteString qualifier: column.getQualifierList()) {
get.addColumn(family, qualifier.toByteArray());
}
} else {
get.addFamily(family);
}
}
}
if (proto.hasExistenceOnly() && proto.getExistenceOnly()){
get.setCheckExistenceOnly(true);
}
if (proto.hasClosestRowBefore() && proto.getClosestRowBefore()){
get.setClosestRowBefore(true);
}
return get;
}
示例12: toScan
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Convert a client Scan to a protocol buffer Scan
*
* @param scan the client Scan to convert
* @return the converted protocol buffer Scan
* @throws IOException
*/
public static ClientProtos.Scan toScan(
final Scan scan) throws IOException {
ClientProtos.Scan.Builder scanBuilder =
ClientProtos.Scan.newBuilder();
scanBuilder.setCacheBlocks(scan.getCacheBlocks());
if (scan.getBatch() > 0) {
scanBuilder.setBatchSize(scan.getBatch());
}
if (scan.getMaxResultSize() > 0) {
scanBuilder.setMaxResultSize(scan.getMaxResultSize());
}
if (scan.isSmall()) {
scanBuilder.setSmall(scan.isSmall());
}
Boolean loadColumnFamiliesOnDemand = scan.getLoadColumnFamiliesOnDemandValue();
if (loadColumnFamiliesOnDemand != null) {
scanBuilder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand.booleanValue());
}
scanBuilder.setMaxVersions(scan.getMaxVersions());
TimeRange timeRange = scan.getTimeRange();
if (!timeRange.isAllTime()) {
HBaseProtos.TimeRange.Builder timeRangeBuilder =
HBaseProtos.TimeRange.newBuilder();
timeRangeBuilder.setFrom(timeRange.getMin());
timeRangeBuilder.setTo(timeRange.getMax());
scanBuilder.setTimeRange(timeRangeBuilder.build());
}
Map<String, byte[]> attributes = scan.getAttributesMap();
if (!attributes.isEmpty()) {
NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
attributeBuilder.setName(attribute.getKey());
attributeBuilder.setValue(HBaseZeroCopyByteString.wrap(attribute.getValue()));
scanBuilder.addAttribute(attributeBuilder.build());
}
}
byte[] startRow = scan.getStartRow();
if (startRow != null && startRow.length > 0) {
scanBuilder.setStartRow(HBaseZeroCopyByteString.wrap(startRow));
}
byte[] stopRow = scan.getStopRow();
if (stopRow != null && stopRow.length > 0) {
scanBuilder.setStopRow(HBaseZeroCopyByteString.wrap(stopRow));
}
if (scan.hasFilter()) {
scanBuilder.setFilter(ProtobufUtil.toFilter(scan.getFilter()));
}
if (scan.hasFamilies()) {
Column.Builder columnBuilder = Column.newBuilder();
for (Map.Entry<byte[],NavigableSet<byte []>>
family: scan.getFamilyMap().entrySet()) {
columnBuilder.setFamily(HBaseZeroCopyByteString.wrap(family.getKey()));
NavigableSet<byte []> qualifiers = family.getValue();
columnBuilder.clearQualifier();
if (qualifiers != null && qualifiers.size() > 0) {
for (byte [] qualifier: qualifiers) {
columnBuilder.addQualifier(HBaseZeroCopyByteString.wrap(qualifier));
}
}
scanBuilder.addColumn(columnBuilder.build());
}
}
if (scan.getMaxResultsPerColumnFamily() >= 0) {
scanBuilder.setStoreLimit(scan.getMaxResultsPerColumnFamily());
}
if (scan.getRowOffsetPerColumnFamily() > 0) {
scanBuilder.setStoreOffset(scan.getRowOffsetPerColumnFamily());
}
if (scan.isReversed()) {
scanBuilder.setReversed(scan.isReversed());
}
return scanBuilder.build();
}
示例13: toGet
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Create a protocol buffer Get based on a client Get.
*
* @param get the client Get
* @return a protocol buffer Get
* @throws IOException
*/
public static ClientProtos.Get toGet(
final Get get) throws IOException {
ClientProtos.Get.Builder builder =
ClientProtos.Get.newBuilder();
builder.setRow(ByteStringer.wrap(get.getRow()));
builder.setCacheBlocks(get.getCacheBlocks());
builder.setMaxVersions(get.getMaxVersions());
if (get.getFilter() != null) {
builder.setFilter(ProtobufUtil.toFilter(get.getFilter()));
}
for (Entry<byte[], TimeRange> cftr : get.getColumnFamilyTimeRange().entrySet()) {
HBaseProtos.ColumnFamilyTimeRange.Builder b = HBaseProtos.ColumnFamilyTimeRange.newBuilder();
b.setColumnFamily(ByteStringer.wrap(cftr.getKey()));
b.setTimeRange(timeRangeToProto(cftr.getValue()));
builder.addCfTimeRange(b);
}
TimeRange timeRange = get.getTimeRange();
if (!timeRange.isAllTime()) {
HBaseProtos.TimeRange.Builder timeRangeBuilder =
HBaseProtos.TimeRange.newBuilder();
timeRangeBuilder.setFrom(timeRange.getMin());
timeRangeBuilder.setTo(timeRange.getMax());
builder.setTimeRange(timeRangeBuilder.build());
}
Map<String, byte[]> attributes = get.getAttributesMap();
if (!attributes.isEmpty()) {
NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
attributeBuilder.setName(attribute.getKey());
attributeBuilder.setValue(ByteStringer.wrap(attribute.getValue()));
builder.addAttribute(attributeBuilder.build());
}
}
if (get.hasFamilies()) {
Column.Builder columnBuilder = Column.newBuilder();
Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap();
for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) {
NavigableSet<byte[]> qualifiers = family.getValue();
columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
columnBuilder.clearQualifier();
if (qualifiers != null && qualifiers.size() > 0) {
for (byte[] qualifier: qualifiers) {
columnBuilder.addQualifier(ByteStringer.wrap(qualifier));
}
}
builder.addColumn(columnBuilder.build());
}
}
if (get.getMaxResultsPerColumnFamily() >= 0) {
builder.setStoreLimit(get.getMaxResultsPerColumnFamily());
}
if (get.getRowOffsetPerColumnFamily() > 0) {
builder.setStoreOffset(get.getRowOffsetPerColumnFamily());
}
if (get.isCheckExistenceOnly()){
builder.setExistenceOnly(true);
}
if (get.getConsistency() != null && get.getConsistency() != Consistency.STRONG) {
builder.setConsistency(toConsistency(get.getConsistency()));
}
Boolean loadColumnFamiliesOnDemand = get.getLoadColumnFamiliesOnDemandValue();
if (loadColumnFamiliesOnDemand != null) {
builder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand);
}
return builder.build();
}
示例14: toScan
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Convert a client Scan to a protocol buffer Scan
*
* @param scan the client Scan to convert
* @return the converted protocol buffer Scan
* @throws IOException
*/
public static ClientProtos.Scan toScan(
final Scan scan) throws IOException {
ClientProtos.Scan.Builder scanBuilder =
ClientProtos.Scan.newBuilder();
scanBuilder.setCacheBlocks(scan.getCacheBlocks());
if (scan.getBatch() > 0) {
scanBuilder.setBatchSize(scan.getBatch());
}
if (scan.getMaxResultSize() > 0) {
scanBuilder.setMaxResultSize(scan.getMaxResultSize());
}
if (scan.isSmall()) {
scanBuilder.setSmall(scan.isSmall());
}
Boolean loadColumnFamiliesOnDemand = scan.getLoadColumnFamiliesOnDemandValue();
if (loadColumnFamiliesOnDemand != null) {
scanBuilder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand.booleanValue());
}
scanBuilder.setMaxVersions(scan.getMaxVersions());
TimeRange timeRange = scan.getTimeRange();
if (!timeRange.isAllTime()) {
HBaseProtos.TimeRange.Builder timeRangeBuilder =
HBaseProtos.TimeRange.newBuilder();
timeRangeBuilder.setFrom(timeRange.getMin());
timeRangeBuilder.setTo(timeRange.getMax());
scanBuilder.setTimeRange(timeRangeBuilder.build());
}
Map<String, byte[]> attributes = scan.getAttributesMap();
if (!attributes.isEmpty()) {
NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
attributeBuilder.setName(attribute.getKey());
attributeBuilder.setValue(ZeroCopyLiteralByteString.wrap(attribute.getValue()));
scanBuilder.addAttribute(attributeBuilder.build());
}
}
byte[] startRow = scan.getStartRow();
if (startRow != null && startRow.length > 0) {
scanBuilder.setStartRow(ZeroCopyLiteralByteString.wrap(startRow));
}
byte[] stopRow = scan.getStopRow();
if (stopRow != null && stopRow.length > 0) {
scanBuilder.setStopRow(ZeroCopyLiteralByteString.wrap(stopRow));
}
if (scan.hasFilter()) {
scanBuilder.setFilter(ProtobufUtil.toFilter(scan.getFilter()));
}
if (scan.hasFamilies()) {
Column.Builder columnBuilder = Column.newBuilder();
for (Map.Entry<byte[],NavigableSet<byte []>>
family: scan.getFamilyMap().entrySet()) {
columnBuilder.setFamily(ZeroCopyLiteralByteString.wrap(family.getKey()));
NavigableSet<byte []> qualifiers = family.getValue();
columnBuilder.clearQualifier();
if (qualifiers != null && qualifiers.size() > 0) {
for (byte [] qualifier: qualifiers) {
columnBuilder.addQualifier(ZeroCopyLiteralByteString.wrap(qualifier));
}
}
scanBuilder.addColumn(columnBuilder.build());
}
}
if (scan.getMaxResultsPerColumnFamily() >= 0) {
scanBuilder.setStoreLimit(scan.getMaxResultsPerColumnFamily());
}
if (scan.getRowOffsetPerColumnFamily() > 0) {
scanBuilder.setStoreOffset(scan.getRowOffsetPerColumnFamily());
}
return scanBuilder.build();
}
示例15: toScan
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Column; //导入依赖的package包/类
/**
* Convert a client Scan to a protocol buffer Scan
*
* @param scan the client Scan to convert
* @return the converted protocol buffer Scan
* @throws IOException
*/
public static ClientProtos.Scan toScan(
final Scan scan) throws IOException {
ClientProtos.Scan.Builder scanBuilder =
ClientProtos.Scan.newBuilder();
scanBuilder.setCacheBlocks(scan.getCacheBlocks());
if (scan.getBatch() > 0) {
scanBuilder.setBatchSize(scan.getBatch());
}
if (scan.getMaxResultSize() > 0) {
scanBuilder.setMaxResultSize(scan.getMaxResultSize());
}
Boolean loadColumnFamiliesOnDemand = scan.getLoadColumnFamiliesOnDemandValue();
if (loadColumnFamiliesOnDemand != null) {
scanBuilder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand.booleanValue());
}
scanBuilder.setMaxVersions(scan.getMaxVersions());
TimeRange timeRange = scan.getTimeRange();
if (!timeRange.isAllTime()) {
HBaseProtos.TimeRange.Builder timeRangeBuilder =
HBaseProtos.TimeRange.newBuilder();
timeRangeBuilder.setFrom(timeRange.getMin());
timeRangeBuilder.setTo(timeRange.getMax());
scanBuilder.setTimeRange(timeRangeBuilder.build());
}
Map<String, byte[]> attributes = scan.getAttributesMap();
if (!attributes.isEmpty()) {
NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
attributeBuilder.setName(attribute.getKey());
attributeBuilder.setValue(ByteString.copyFrom(attribute.getValue()));
scanBuilder.addAttribute(attributeBuilder.build());
}
}
byte[] startRow = scan.getStartRow();
if (startRow != null && startRow.length > 0) {
scanBuilder.setStartRow(ByteString.copyFrom(startRow));
}
byte[] stopRow = scan.getStopRow();
if (stopRow != null && stopRow.length > 0) {
scanBuilder.setStopRow(ByteString.copyFrom(stopRow));
}
if (scan.hasFilter()) {
scanBuilder.setFilter(ProtobufUtil.toFilter(scan.getFilter()));
}
if (scan.hasFamilies()) {
Column.Builder columnBuilder = Column.newBuilder();
for (Map.Entry<byte[],NavigableSet<byte []>>
family: scan.getFamilyMap().entrySet()) {
columnBuilder.setFamily(ByteString.copyFrom(family.getKey()));
NavigableSet<byte []> qualifiers = family.getValue();
columnBuilder.clearQualifier();
if (qualifiers != null && qualifiers.size() > 0) {
for (byte [] qualifier: qualifiers) {
columnBuilder.addQualifier(ByteString.copyFrom(qualifier));
}
}
scanBuilder.addColumn(columnBuilder.build());
}
}
if (scan.getMaxResultsPerColumnFamily() >= 0) {
scanBuilder.setStoreLimit(scan.getMaxResultsPerColumnFamily());
}
if (scan.getRowOffsetPerColumnFamily() > 0) {
scanBuilder.setStoreOffset(scan.getRowOffsetPerColumnFamily());
}
return scanBuilder.build();
}