Search in sources :

Example 1 with BytesBytesPair

use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair in project hbase by apache.

the class ProtobufUtil method convertToHTableDesc.

/**
   * Converts a TableSchema to HTableDescriptor
   * @param ts A pb TableSchema instance.
   * @return An {@link HTableDescriptor} made from the passed in pb <code>ts</code>.
   */
public static HTableDescriptor convertToHTableDesc(final TableSchema ts) {
    List<ColumnFamilySchema> list = ts.getColumnFamiliesList();
    HColumnDescriptor[] hcds = new HColumnDescriptor[list.size()];
    int index = 0;
    for (ColumnFamilySchema cfs : list) {
        hcds[index++] = ProtobufUtil.convertToHColumnDesc(cfs);
    }
    HTableDescriptor htd = new HTableDescriptor(ProtobufUtil.toTableName(ts.getTableName()));
    for (HColumnDescriptor hcd : hcds) {
        htd.addFamily(hcd);
    }
    for (BytesBytesPair a : ts.getAttributesList()) {
        htd.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray());
    }
    for (NameStringPair a : ts.getConfigurationList()) {
        htd.setConfiguration(a.getName(), a.getValue());
    }
    return htd;
}
Also used : ColumnFamilySchema(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ColumnFamilySchema) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) BytesBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 2 with BytesBytesPair

use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair in project hbase by apache.

the class FuzzyRowFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance
 * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FuzzyRowFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FuzzyRowFilter proto;
    try {
        proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    int count = proto.getFuzzyKeysDataCount();
    ArrayList<Pair<byte[], byte[]>> fuzzyKeysData = new ArrayList<>(count);
    for (int i = 0; i < count; ++i) {
        BytesBytesPair current = proto.getFuzzyKeysData(i);
        byte[] keyBytes = current.getFirst().toByteArray();
        byte[] keyMeta = current.getSecond().toByteArray();
        fuzzyKeysData.add(new Pair<>(keyBytes, keyMeta));
    }
    return new FuzzyRowFilter(fuzzyKeysData);
}
Also used : BytesBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) ArrayList(java.util.ArrayList) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) BytesBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair) Pair(org.apache.hadoop.hbase.util.Pair)

Aggregations

BytesBytesPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair)2 ArrayList (java.util.ArrayList)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)1 FilterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos)1 ColumnFamilySchema (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ColumnFamilySchema)1 NameStringPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair)1 Pair (org.apache.hadoop.hbase.util.Pair)1 InvalidProtocolBufferException (org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException)1