View Javadoc
1   /*
2    * Copyright 2021 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.meta;
19  
20  import com.fasterxml.jackson.annotation.JsonCreator;
21  import com.fasterxml.jackson.annotation.JsonProperty;
22  import java.io.Serializable;
23  import java.util.ArrayList;
24  import java.util.List;
25  import java.util.stream.Collectors;
26  
27  public class TiViewInfo implements Serializable {
28    // ViewAlgorithm is VIEW's SQL ALGORITHM characteristic.
29    // See https://dev.mysql.com/doc/refman/5.7/en/view-algorithms.html
30    private final long viewAlgorithm;
31    private final org.tikv.common.meta.TiUserIdentity userIdentity;
32    // ViewSecurity is VIEW's SQL SECURITY characteristic.
33    // See https://dev.mysql.com/doc/refman/5.7/en/create-view.html
34    private final long viewSecurity;
35    private final String viewSelect;
36    // ViewCheckOption is VIEW's WITH CHECK OPTION clause part.
37    // See https://dev.mysql.com/doc/refman/5.7/en/view-check-option.html
38    private final long viewCheckOpt;
39    private final List<String> viewCols;
40  
41    @JsonCreator
42    public TiViewInfo(
43        @JsonProperty("view_algorithm") long viewAlgorithm,
44        @JsonProperty("view_definer") org.tikv.common.meta.TiUserIdentity userIdentity,
45        @JsonProperty("view_security") long viewSecurity,
46        @JsonProperty("view_select") String viewSelect,
47        @JsonProperty("view_checkoption") long viewCheckOpt,
48        @JsonProperty("view_cols") List<org.tikv.common.meta.CIStr> viewCols) {
49      this.viewAlgorithm = viewAlgorithm;
50      this.userIdentity = userIdentity;
51      this.viewSecurity = viewSecurity;
52      this.viewSelect = viewSelect;
53      this.viewCheckOpt = viewCheckOpt;
54      if (viewCols != null) {
55        this.viewCols =
56            viewCols.stream().map(org.tikv.common.meta.CIStr::getO).collect(Collectors.toList());
57      } else {
58        this.viewCols = new ArrayList<>();
59      }
60    }
61  }