Search in sources :

Example 11 with CellVisibility

use of org.apache.hadoop.hbase.security.visibility.CellVisibility in project hbase by apache.

the class ThriftUtilities method putFromHBase.

public static TPut putFromHBase(Put in) {
    TPut out = new TPut();
    out.setRow(in.getRow());
    if (in.getTimestamp() != HConstants.LATEST_TIMESTAMP) {
        out.setTimestamp(in.getTimestamp());
    }
    if (in.getDurability() != Durability.USE_DEFAULT) {
        out.setDurability(durabilityFromHBase(in.getDurability()));
    }
    for (Map.Entry<byte[], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
        byte[] family = entry.getKey();
        for (Cell cell : entry.getValue()) {
            TColumnValue columnValue = new TColumnValue();
            columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell)).setType(cell.getType().getCode()).setTimestamp(cell.getTimestamp()).setValue(CellUtil.cloneValue(cell));
            if (cell.getTagsLength() != 0) {
                columnValue.setTags(PrivateCellUtil.cloneTags(cell));
            }
            out.addToColumnValues(columnValue);
        }
    }
    for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
        out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
    }
    try {
        CellVisibility cellVisibility = in.getCellVisibility();
        if (cellVisibility != null) {
            TCellVisibility tCellVisibility = new TCellVisibility();
            tCellVisibility.setExpression(cellVisibility.getExpression());
            out.setCellVisibility(tCellVisibility);
        }
    } catch (DeserializationException e) {
        throw new RuntimeException(e);
    }
    return out;
}
Also used : TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) CellVisibility(org.apache.hadoop.hbase.security.visibility.CellVisibility) TColumnValue(org.apache.hadoop.hbase.thrift2.generated.TColumnValue) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) List(java.util.List) ArrayList(java.util.ArrayList) TPut(org.apache.hadoop.hbase.thrift2.generated.TPut) Map(java.util.Map) Cell(org.apache.hadoop.hbase.Cell)

Example 12 with CellVisibility

use of org.apache.hadoop.hbase.security.visibility.CellVisibility in project hbase by apache.

the class ThriftUtilities method incrementFromHBase.

public static TIncrement incrementFromHBase(Increment in) throws IOException {
    TIncrement out = new TIncrement();
    out.setRow(in.getRow());
    if (in.getDurability() != Durability.USE_DEFAULT) {
        out.setDurability(durabilityFromHBase(in.getDurability()));
    }
    for (Map.Entry<byte[], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
        byte[] family = entry.getKey();
        for (Cell cell : entry.getValue()) {
            TColumnIncrement columnValue = new TColumnIncrement();
            columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell));
            columnValue.setAmount(Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
            out.addToColumns(columnValue);
        }
    }
    for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
        out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
    }
    try {
        CellVisibility cellVisibility = in.getCellVisibility();
        if (cellVisibility != null) {
            TCellVisibility tCellVisibility = new TCellVisibility();
            tCellVisibility.setExpression(cellVisibility.getExpression());
            out.setCellVisibility(tCellVisibility);
        }
    } catch (DeserializationException e) {
        throw new RuntimeException(e);
    }
    out.setReturnResults(in.isReturnResults());
    return out;
}
Also used : TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) CellVisibility(org.apache.hadoop.hbase.security.visibility.CellVisibility) TIncrement(org.apache.hadoop.hbase.thrift2.generated.TIncrement) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) TColumnIncrement(org.apache.hadoop.hbase.thrift2.generated.TColumnIncrement) TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) Cell(org.apache.hadoop.hbase.Cell)

Aggregations

CellVisibility (org.apache.hadoop.hbase.security.visibility.CellVisibility)12 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)7 ArrayList (java.util.ArrayList)6 Cell (org.apache.hadoop.hbase.Cell)6 IOException (java.io.IOException)5 Put (org.apache.hadoop.hbase.client.Put)5 List (java.util.List)4 Map (java.util.Map)4 KeyValue (org.apache.hadoop.hbase.KeyValue)3 Table (org.apache.hadoop.hbase.client.Table)3 TreeSet (java.util.TreeSet)2 ArrayBackedTag (org.apache.hadoop.hbase.ArrayBackedTag)2 Tag (org.apache.hadoop.hbase.Tag)2 Result (org.apache.hadoop.hbase.client.Result)2 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)2 Scan (org.apache.hadoop.hbase.client.Scan)2 Authorizations (org.apache.hadoop.hbase.security.visibility.Authorizations)2 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)2 TCellVisibility (org.apache.hadoop.hbase.thrift2.generated.TCellVisibility)2 File (java.io.File)1