Search in sources :

Example 81 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException 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 82 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class ThriftUtilities method getFromHBase.

public static TGet getFromHBase(Get in) {
    TGet out = new TGet();
    out.setRow(in.getRow());
    TTimeRange tTimeRange = new TTimeRange();
    tTimeRange.setMaxStamp(in.getTimeRange().getMax()).setMinStamp(in.getTimeRange().getMin());
    out.setTimeRange(tTimeRange);
    out.setMaxVersions(in.getMaxVersions());
    for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
        out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
    }
    try {
        Authorizations authorizations = in.getAuthorizations();
        if (authorizations != null) {
            TAuthorization tAuthorization = new TAuthorization();
            tAuthorization.setLabels(authorizations.getLabels());
            out.setAuthorizations(tAuthorization);
        }
    } catch (DeserializationException e) {
        throw new RuntimeException(e);
    }
    out.setConsistency(consistencyFromHBase(in.getConsistency()));
    out.setTargetReplicaId(in.getReplicaId());
    out.setCacheBlocks(in.getCacheBlocks());
    out.setStoreLimit(in.getMaxResultsPerColumnFamily());
    out.setStoreOffset(in.getRowOffsetPerColumnFamily());
    out.setExistence_only(in.isCheckExistenceOnly());
    for (Map.Entry<byte[], NavigableSet<byte[]>> family : in.getFamilyMap().entrySet()) {
        if (family.getValue() != null && !family.getValue().isEmpty()) {
            for (byte[] qualifier : family.getValue()) {
                TColumn column = new TColumn();
                column.setFamily(family.getKey());
                column.setQualifier(qualifier);
                out.addToColumns(column);
            }
        } else {
            TColumn column = new TColumn();
            column.setFamily(family.getKey());
            out.addToColumns(column);
        }
    }
    if (in.getFilter() != null) {
        try {
            out.setFilterBytes(filterFromHBase(in.getFilter()));
        } catch (IOException ioE) {
            throw new RuntimeException(ioE);
        }
    }
    return out;
}
Also used : Authorizations(org.apache.hadoop.hbase.security.visibility.Authorizations) NavigableSet(java.util.NavigableSet) TGet(org.apache.hadoop.hbase.thrift2.generated.TGet) TColumn(org.apache.hadoop.hbase.thrift2.generated.TColumn) TTimeRange(org.apache.hadoop.hbase.thrift2.generated.TTimeRange) TAuthorization(org.apache.hadoop.hbase.thrift2.generated.TAuthorization) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) Map(java.util.Map)

Example 83 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException 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

DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)83 IOException (java.io.IOException)57 InvalidProtocolBufferException (org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException)15 FilterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos)13 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)12 KeeperException (org.apache.zookeeper.KeeperException)12 ArrayList (java.util.ArrayList)11 ServerName (org.apache.hadoop.hbase.ServerName)9 Cell (org.apache.hadoop.hbase.Cell)8 CompareOperator (org.apache.hadoop.hbase.CompareOperator)8 InterruptedIOException (java.io.InterruptedIOException)7 CellVisibility (org.apache.hadoop.hbase.security.visibility.CellVisibility)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Tag (org.apache.hadoop.hbase.Tag)6 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)6 Map (java.util.Map)5 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)5 TableName (org.apache.hadoop.hbase.TableName)5 FilterList (org.apache.hadoop.hbase.filter.FilterList)5 List (java.util.List)4