View Javadoc
1   /*
2    * Copyright 2022 TiKV Project Authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  
18  package org.tikv.common.apiversion;
19  
20  import com.google.protobuf.ByteString;
21  import java.util.List;
22  import org.tikv.common.util.Pair;
23  import org.tikv.kvproto.Kvrpcpb.KvPair;
24  import org.tikv.kvproto.Kvrpcpb.Mutation;
25  import org.tikv.kvproto.Metapb.Region;
26  import org.tikv.kvproto.Pdpb;
27  
28  public class RequestKeyV1Codec implements RequestKeyCodec {
29    @Override
30    public ByteString encodeKey(ByteString key) {
31      return key;
32    }
33  
34    @Override
35    public List<ByteString> encodeKeys(List<ByteString> keys) {
36      return keys;
37    }
38  
39    @Override
40    public List<Mutation> encodeMutations(List<Mutation> mutations) {
41      return mutations;
42    }
43  
44    @Override
45    public ByteString decodeKey(ByteString key) {
46      return key;
47    }
48  
49    @Override
50    public KvPair decodeKvPair(KvPair pair) {
51      return pair;
52    }
53  
54    @Override
55    public List<KvPair> decodeKvPairs(List<KvPair> pairs) {
56      return pairs;
57    }
58  
59    @Override
60    public Pair<ByteString, ByteString> encodeRange(ByteString start, ByteString end) {
61      return Pair.create(start, end);
62    }
63  
64    @Override
65    public ByteString encodePdQuery(ByteString key) {
66      return key;
67    }
68  
69    @Override
70    public Pair<ByteString, ByteString> encodePdQueryRange(ByteString start, ByteString end) {
71      return Pair.create(start, end);
72    }
73  
74    @Override
75    public Region decodeRegion(Region region) {
76      return region;
77    }
78  
79    @Override
80    public List<Pdpb.Region> decodePdRegions(List<Pdpb.Region> regions) {
81      return regions;
82    }
83  }