Search in sources :

Example 6 with CodecDataInput

use of com.pingcap.tikv.codec.CodecDataInput in project tispark by pingcap.

the class CatalogTransaction method getLatestSchemaVersion.

long getLatestSchemaVersion() {
    ByteString versionBytes = MetaCodec.bytesGet(MetaCodec.KEY_SCHEMA_VERSION, this.snapshot);
    CodecDataInput cdi = new CodecDataInput(versionBytes.toByteArray());
    return Long.parseLong(new String(cdi.toByteArray(), StandardCharsets.UTF_8));
}
Also used : ByteString(com.google.protobuf.ByteString) CodecDataInput(com.pingcap.tikv.codec.CodecDataInput) ByteString(com.google.protobuf.ByteString)

Example 7 with CodecDataInput

use of com.pingcap.tikv.codec.CodecDataInput in project tispark by pingcap.

the class CoprocessorIterator method createDataInputReader.

void createDataInputReader() {
    requireNonNull(chunkList, "Chunk list should not be null.");
    if (0 > chunkIndex || chunkIndex >= chunkList.size()) {
        throw new IllegalArgumentException();
    }
    dataInput = new CodecDataInput(chunkList.get(chunkIndex).getRowsData());
    rowReader = RowReaderFactory.createRowReader(dataInput);
}
Also used : CodecDataInput(com.pingcap.tikv.codec.CodecDataInput)

Example 8 with CodecDataInput

use of com.pingcap.tikv.codec.CodecDataInput in project tispark by pingcap.

the class TiRegion method decodeRegion.

private Region decodeRegion(Region region, boolean isRawRegion) {
    Region.Builder builder = Region.newBuilder().setId(region.getId()).setRegionEpoch(region.getRegionEpoch()).addAllPeers(region.getPeersList());
    if (region.getStartKey().isEmpty() || isRawRegion) {
        builder.setStartKey(region.getStartKey());
    } else {
        byte[] decodedStartKey = BytesCodec.readBytes(new CodecDataInput(region.getStartKey()));
        builder.setStartKey(ByteString.copyFrom(decodedStartKey));
    }
    if (region.getEndKey().isEmpty() || isRawRegion) {
        builder.setEndKey(region.getEndKey());
    } else {
        byte[] decodedEndKey = BytesCodec.readBytes(new CodecDataInput(region.getEndKey()));
        builder.setEndKey(ByteString.copyFrom(decodedEndKey));
    }
    return builder.build();
}
Also used : CodecDataInput(com.pingcap.tikv.codec.CodecDataInput) Region(org.tikv.kvproto.Metapb.Region)

Aggregations

CodecDataInput (com.pingcap.tikv.codec.CodecDataInput)8 ByteString (com.google.protobuf.ByteString)3 Row (com.pingcap.tikv.row.Row)2 DataType (com.pingcap.tikv.types.DataType)2 BytePairWrapper (com.pingcap.tikv.BytePairWrapper)1 CodecDataOutput (com.pingcap.tikv.codec.CodecDataOutput)1 BatchedTiChunkColumnVector (com.pingcap.tikv.columnar.BatchedTiChunkColumnVector)1 TiChunk (com.pingcap.tikv.columnar.TiChunk)1 TiChunkColumnVector (com.pingcap.tikv.columnar.TiChunkColumnVector)1 TiRowColumnVector (com.pingcap.tikv.columnar.TiRowColumnVector)1 CHType (com.pingcap.tikv.columnar.datatypes.CHType)1 AllocateRowIDOverflowException (com.pingcap.tikv.exception.AllocateRowIDOverflowException)1 TiBatchWriteException (com.pingcap.tikv.exception.TiBatchWriteException)1 TypeException (com.pingcap.tikv.exception.TypeException)1 TiDAGRequest (com.pingcap.tikv.meta.TiDAGRequest)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 Region (org.tikv.kvproto.Metapb.Region)1