Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DataSource.java
Go to the documentation of this file.
1 // Copyright 2014 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.catalog;
16 
17 import org.apache.hadoop.fs.Path;
18 
19 import com.cloudera.impala.thrift.TCatalogObjectType;
20 import com.cloudera.impala.thrift.TDataSource;
21 import com.google.common.base.Objects;
22 
27 public class DataSource implements CatalogObject {
28  private final String dataSrcName_;
29  private final String className_;
30  private final String apiVersionString_;
31  // Qualified path to the data source.
32  private final String location_;
34 
35  public DataSource(String dataSrcName, String location, String className,
36  String apiVersionString) {
37  dataSrcName_ = dataSrcName;
38  location_ = location;
39  className_ = className;
40  apiVersionString_ = apiVersionString;
41  }
42 
43  public static DataSource fromThrift(TDataSource thrift) {
44  return new DataSource(thrift.getName(), thrift.getHdfs_location(),
45  thrift.getClass_name(), thrift.getApi_version());
46  }
47 
48  @Override
49  public TCatalogObjectType getCatalogObjectType() {
50  return TCatalogObjectType.DATA_SOURCE;
51  }
52 
53  @Override
54  public long getCatalogVersion() { return catalogVersion_; }
55 
56  @Override
57  public void setCatalogVersion(long newVersion) { catalogVersion_ = newVersion; }
58 
59  @Override
60  public String getName() { return dataSrcName_; }
61 
62  @Override
63  public boolean isLoaded() { return true; }
64 
65  public String getLocation() { return location_; }
66  public String getClassName() { return className_; }
67  public String getApiVersion() { return apiVersionString_; }
68 
69  public TDataSource toThrift() {
70  return new TDataSource(getName(), location_, className_, apiVersionString_);
71  }
72 
73  public String debugString() {
74  return Objects.toStringHelper(this)
75  .add("name", dataSrcName_)
76  .add("location", location_)
77  .add("className", className_)
78  .add("apiVersion", apiVersionString_)
79  .toString();
80  }
81 
82  public static String debugString(TDataSource thrift) {
83  return fromThrift(thrift).debugString();
84  }
85 }
static String debugString(TDataSource thrift)
Definition: DataSource.java:82
static final long INITIAL_CATALOG_VERSION
Definition: Catalog.java:57
DataSource(String dataSrcName, String location, String className, String apiVersionString)
Definition: DataSource.java:35
void setCatalogVersion(long newVersion)
Definition: DataSource.java:57
static DataSource fromThrift(TDataSource thrift)
Definition: DataSource.java:43
TCatalogObjectType getCatalogObjectType()
Definition: DataSource.java:49