Search in sources :

Example 1 with CodecDataOutput

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

the class ProtoConverter method visit.

@Override
@SuppressWarnings("unchecked")
protected Expr visit(ColumnRef node, Object context) {
    long position = 0;
    if (validateColPosition) {
        requireNonNull(context, "Context of a ColumnRef should not be null");
        Map<String, Integer> colIdOffsetMap = (Map<String, Integer>) context;
        position = requireNonNull(colIdOffsetMap.get(node.getName()), "Required column position info " + node.getName() + " is not in a valid context.");
    }
    Expr.Builder builder = Expr.newBuilder();
    builder.setTp(ExprType.ColumnRef);
    CodecDataOutput cdo = new CodecDataOutput();
    // After switching to DAG request mode, expression value
    // should be the index of table columns we provided in
    // the first executor of a DAG request.
    IntegerCodec.writeLong(cdo, position);
    builder.setVal(cdo.toByteString());
    builder.setFieldType(toPBFieldType(getType(node)));
    return builder.build();
}
Also used : Expr(com.pingcap.tidb.tipb.Expr) FuncCallExpr(com.pingcap.tikv.expression.FuncCallExpr) CodecDataOutput(com.pingcap.tikv.codec.CodecDataOutput) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with CodecDataOutput

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

the class TiColumnInfo method getOriginDefaultValueAsByteString.

private ByteString getOriginDefaultValueAsByteString() {
    CodecDataOutput cdo = new CodecDataOutput();
    type.encode(cdo, EncodeType.VALUE, type.getOriginDefaultValue(getOriginDefaultValue(), version));
    return cdo.toByteString();
}
Also used : CodecDataOutput(com.pingcap.tikv.codec.CodecDataOutput)

Example 3 with CodecDataOutput

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

the class IntHandle method encoded.

@Override
public byte[] encoded() {
    CodecDataOutput cdo = new CodecDataOutput();
    IntegerCodec.writeLong(cdo, handle);
    byte[] encoded = cdo.toBytes();
    if (infFlag == 1) {
        return Arrays.copyOf(encoded, encoded.length + 1);
    }
    return encoded;
}
Also used : CodecDataOutput(com.pingcap.tikv.codec.CodecDataOutput)

Example 4 with CodecDataOutput

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

the class Key method createTypelessMax.

private static Key createTypelessMax() {
    CodecDataOutput cdo = new CodecDataOutput();
    DataType.encodeMaxValue(cdo);
    return new Key(cdo.toBytes()) {

        @Override
        public String toString() {
            return "MAX";
        }
    };
}
Also used : CodecDataOutput(com.pingcap.tikv.codec.CodecDataOutput)

Example 5 with CodecDataOutput

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

the class Key method createNull.

private static Key createNull() {
    CodecDataOutput cdo = new CodecDataOutput();
    DataType.encodeNull(cdo);
    return new Key(cdo.toBytes()) {

        @Override
        public String toString() {
            return "null";
        }
    };
}
Also used : CodecDataOutput(com.pingcap.tikv.codec.CodecDataOutput)

Aggregations

CodecDataOutput (com.pingcap.tikv.codec.CodecDataOutput)20 ByteString (com.google.protobuf.ByteString)4 Expr (com.pingcap.tidb.tipb.Expr)2 BytePairWrapper (com.pingcap.tikv.BytePairWrapper)2 FuncCallExpr (com.pingcap.tikv.expression.FuncCallExpr)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MockServerTest (com.pingcap.tikv.MockServerTest)1 CodecDataInput (com.pingcap.tikv.codec.CodecDataInput)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 TiTableInfo (com.pingcap.tikv.meta.TiTableInfo)1 TiTimestamp (com.pingcap.tikv.meta.TiTimestamp)1 PDErrorHandler (com.pingcap.tikv.operation.PDErrorHandler)1 SchemaInfer (com.pingcap.tikv.operation.SchemaInfer)1 TiRegion (com.pingcap.tikv.region.TiRegion)1 Row (com.pingcap.tikv.row.Row)1 DataType (com.pingcap.tikv.types.DataType)1 RegionTask (com.pingcap.tikv.util.RangeSplitter.RegionTask)1