MCPcopy Index your code
hub / github.com/pingcap/tidb / TestV2TableCodec

Function TestV2TableCodec

pkg/tablecodec/tablecodec_test.go:732–748  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

730}
731
732func TestV2TableCodec(t *testing.T) {
733 const tableID int64 = 31415926
734 key := EncodeTablePrefix(tableID)
735 c, err := tikv.NewCodecV2(tikv.ModeTxn, &keyspacepb.KeyspaceMeta{Id: 271828})
736 require.NoError(t, err)
737 key = c.EncodeKey(key)
738 tbid := DecodeTableID(key)
739 require.Equal(t, tableID, tbid)
740
741 key = []byte("x001HelloWorld")
742 tbid = DecodeTableID(key)
743 require.Equal(t, int64(0), tbid)
744
745 key = []byte("x001x001t123")
746 tbid = DecodeTableID(key)
747 require.Equal(t, int64(0), tbid)
748}
749
750// TestDecodeIndexHandleWithPartitionIDInKeyAndValue tests the scenario where
751// a GlobalIndexVersionV1+ non-unique index has partition ID in both the key

Callers

nothing calls this directly

Calls 3

EncodeTablePrefixFunction · 0.85
DecodeTableIDFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected