public abstract static class HivePrivilegeObjectUtils.TableLookup<T> extends Object
When filtering a source list of tables by checking their presence in another permission list using the database name, table name, we need to avoid performing a cartesian product. This product stems from checking each table from the source (n tables) by comparing it to each table in the permission list (m permissions), thus an n * m complexity.
This class reduces the complexity of the lookup in the permission by sorting them and using a binary search; the sort cost is m*log(m) and each lookup is log(m), the overall complexity of a check for all tables is in the order of m*log(m) + n*log(m) = (m + n)*log(n), close to m * log(n).
| Modifier | Constructor and Description |
|---|---|
protected |
TableLookup(List<T> tables)
Creates a ByName
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(T tt)
Checks whether a given table is present in this set.
|
protected abstract String |
getDbName(T table) |
protected abstract String |
getTableName(T table) |
T |
lookup(String dbName,
String tableName)
Lookup using dichotomy using order described by database name, table name.
|
protected abstract String getDbName(T table)
table - the tableprotected abstract String getTableName(T table)
table - the tablepublic final T lookup(String dbName, String tableName)
dbName - the database nametableName - the table namepublic final boolean contains(T tt)
tt - the table to checkCopyright © 2024 The Apache Software Foundation. All rights reserved.