Base class for table metadata. This includes the concept of clustering columns, which are columns by which the table data is physically clustered. In other words, if two rows share the same values for the clustering columns, those two rows are most likely colocated. Note that this is more general t
| 84 | * a key range into a fixed number of buckets). |
| 85 | */ |
| 86 | public abstract class Table extends CatalogObjectImpl implements FeTable { |
| 87 | private static final Logger LOG = LoggerFactory.getLogger(Table.class); |
| 88 | protected org.apache.hadoop.hive.metastore.api.Table msTable_; |
| 89 | protected final Db db_; |
| 90 | protected final String name_; |
| 91 | protected final String full_name_; |
| 92 | protected final String owner_; |
| 93 | protected TAccessLevel accessLevel_ = TAccessLevel.READ_WRITE; |
| 94 | // Lock protecting this table. A read lock must be held when we are serializing |
| 95 | // the table contents over thrift (e.g when returning the table to clients over thrift |
| 96 | // or when topic-update thread serializes the table in the topic update) |
| 97 | // A write lock must be held when the table is being modified (e.g. DDLs or refresh) |
| 98 | private final ReentrantReadWriteLock tableLock_ = new ReentrantReadWriteLock( |
| 99 | true /*fair ordering*/); |
| 100 | private final ReadLock readLock_ = tableLock_.readLock(); |
| 101 | private final WriteLock writeLock_ = tableLock_.writeLock(); |
| 102 | |
| 103 | // Number of clustering columns. |
| 104 | protected int numClusteringCols_; |
| 105 | |
| 106 | // Contains the estimated number of rows and optional file bytes. Non-null. Member |
| 107 | // values of -1 indicate an unknown statistic. |
| 108 | protected TTableStats tableStats_; |
| 109 | |
| 110 | // Estimated size (in bytes) of this table metadata. Stored in an AtomicLong to allow |
| 111 | // this field to be accessed without holding the table lock. |
| 112 | protected AtomicLong estimatedMetadataSize_ = new AtomicLong(0); |
| 113 | |
| 114 | // Number of metadata operations performed on that table since it was loaded. |
| 115 | // Stored in an AtomicLong to allow this field to be accessed without holding the |
| 116 | // table lock. |
| 117 | protected AtomicLong metadataOpsCount_ = new AtomicLong(0); |
| 118 | |
| 119 | // Number of files that the table has. |
| 120 | // Stored in an AtomicLong to allow this field to be accessed without holding the |
| 121 | // table lock. |
| 122 | protected AtomicLong numFiles_ = new AtomicLong(0); |
| 123 | |
| 124 | // Metrics for this table |
| 125 | protected final Metrics metrics_ = new Metrics(); |
| 126 | |
| 127 | // colsByPos[i] refers to the ith column in the table. The first numClusteringCols are |
| 128 | // the clustering columns. |
| 129 | protected final ArrayList<Column> colsByPos_ = new ArrayList<>(); |
| 130 | |
| 131 | // Virtual columns of this table. |
| 132 | protected final ArrayList<VirtualColumn> virtualCols_ = new ArrayList<>(); |
| 133 | |
| 134 | // map from lowercase column name to Column object. |
| 135 | protected final Map<String, Column> colsByName_ = new HashMap<>(); |
| 136 | |
| 137 | // Type of this table (array of struct) that mirrors the columns. Useful for analysis. |
| 138 | protected final ArrayType type_ = new ArrayType(new StructType()); |
| 139 | |
| 140 | // True if this object is stored in an Impalad catalog cache. |
| 141 | protected boolean storedInImpaladCatalogCache_ = false; |
| 142 | |
| 143 | // Time spent in the source systems loading/reloading the fs metadata for the table. |