public class TxnUtils extends Object
Constructor and Description |
---|
TxnUtils() |
Modifier and Type | Method and Description |
---|---|
static List<Integer> |
buildQueryWithINClause(org.apache.hadoop.conf.Configuration conf,
List<String> queries,
StringBuilder prefix,
StringBuilder suffix,
List<Long> inList,
String inColumn,
boolean addParens,
boolean notIn)
Build a query (or queries if one query is too big but only for the case of 'IN'
composite clause.
|
static List<Integer> |
buildQueryWithINClauseStrings(org.apache.hadoop.conf.Configuration conf,
List<String> queries,
StringBuilder prefix,
StringBuilder suffix,
List<String> inList,
String inColumn,
boolean addParens,
boolean notIn)
Build a query (or queries if one query is too big but only for the case of 'IN'
composite clause.
|
static org.apache.hadoop.hive.common.ValidCompactorWriteIdList |
createValidCompactWriteIdList(TableValidWriteIds tableValidWriteIds)
Transform a
TableValidWriteIds to a
ValidCompactorWriteIdList . |
static org.apache.hadoop.hive.common.ValidReaderWriteIdList |
createValidReaderWriteIdList(TableValidWriteIds tableWriteIds)
Transform a
TableValidWriteIds to a
ValidReaderWriteIdList . |
static org.apache.hadoop.hive.common.ValidTxnList |
createValidReadTxnList(GetOpenTxnsResponse txns,
long currentTxn)
Transform a
GetOpenTxnsResponse to a
ValidTxnList . |
static org.apache.hadoop.hive.common.ValidTxnWriteIdList |
createValidTxnWriteIdList(Long currentTxnId,
List<TableValidWriteIds> validIds)
Transform a
GetValidWriteIdsResponse to a
ValidTxnWriteIdList . |
static String[] |
getDbTableName(String fullTableName) |
static String |
getFullTableName(String dbName,
String tableName)
Should produce the result as <dbName>.<tableName>.
|
static TxnStore |
getTxnStore(org.apache.hadoop.conf.Configuration conf)
Get an instance of the TxnStore that is appropriate for this store
|
static boolean |
isAcidTable(Table table)
Should produce the same result as
|
static boolean |
isTransactionalTable(Table table)
Note, users are responsible for using the correct TxnManager.
|
static org.apache.hadoop.hive.common.ValidReaderWriteIdList |
updateForCompactionQuery(org.apache.hadoop.hive.common.ValidReaderWriteIdList ids) |
public static org.apache.hadoop.hive.common.ValidTxnList createValidReadTxnList(GetOpenTxnsResponse txns, long currentTxn)
GetOpenTxnsResponse
to a
ValidTxnList
. This assumes that the caller intends to
read the files, and thus treats both open and aborted transactions as invalid.txns
- txn list from the metastorecurrentTxn
- Current transaction that the user has open. If this is greater than 0 it
will be removed from the exceptions list so that the user sees his own
transaction as valid.public static org.apache.hadoop.hive.common.ValidTxnWriteIdList createValidTxnWriteIdList(Long currentTxnId, List<TableValidWriteIds> validIds)
GetValidWriteIdsResponse
to a
ValidTxnWriteIdList
. This assumes that the caller intends to
read the files, and thus treats both open and aborted transactions as invalid.currentTxnId
- current txn ID for which we get the valid write ids listvalidIds
- valid write ids list from the metastorepublic static org.apache.hadoop.hive.common.ValidReaderWriteIdList createValidReaderWriteIdList(TableValidWriteIds tableWriteIds)
TableValidWriteIds
to a
ValidReaderWriteIdList
. This assumes that the caller intends to
read the files, and thus treats both open and aborted write ids as invalid.tableWriteIds
- valid write ids for the given table from the metastorepublic static org.apache.hadoop.hive.common.ValidCompactorWriteIdList createValidCompactWriteIdList(TableValidWriteIds tableValidWriteIds)
TableValidWriteIds
to a
ValidCompactorWriteIdList
. This assumes that the caller intends to
compact the files, and thus treats only open transactions/write ids as invalid. Additionally any
writeId > highestOpenWriteId is also invalid. This is to avoid creating something like
delta_17_120 where writeId 80, for example, is still open.tableValidWriteIds
- table write id list from the metastorepublic static org.apache.hadoop.hive.common.ValidReaderWriteIdList updateForCompactionQuery(org.apache.hadoop.hive.common.ValidReaderWriteIdList ids)
public static TxnStore getTxnStore(org.apache.hadoop.conf.Configuration conf)
conf
- configurationpublic static boolean isTransactionalTable(Table table)
public static boolean isAcidTable(Table table)
public static String getFullTableName(String dbName, String tableName)
public static List<Integer> buildQueryWithINClause(org.apache.hadoop.conf.Configuration conf, List<String> queries, StringBuilder prefix, StringBuilder suffix, List<Long> inList, String inColumn, boolean addParens, boolean notIn)
queries
- OUT: Array of query stringsprefix
- IN: Part of the query that comes before IN listsuffix
- IN: Part of the query that comes after IN listinList
- IN: the list with IN list valuesinColumn
- IN: single column name of IN list operatoraddParens
- IN: add a pair of parenthesis outside the IN lists
e.g. "(id in (1,2,3) OR id in (4,5,6))"notIn
- IN: is this for building a 'NOT IN' composite clause?public static List<Integer> buildQueryWithINClauseStrings(org.apache.hadoop.conf.Configuration conf, List<String> queries, StringBuilder prefix, StringBuilder suffix, List<String> inList, String inColumn, boolean addParens, boolean notIn)
queries
- OUT: Array of query stringsprefix
- IN: Part of the query that comes before IN listsuffix
- IN: Part of the query that comes after IN listinList
- IN: the list with IN list valuesinColumn
- IN: single column name of IN list operatoraddParens
- IN: add a pair of parenthesis outside the IN lists
e.g. "(id in (1,2,3) OR id in (4,5,6))"notIn
- IN: is this for building a 'NOT IN' composite clause?Copyright © 2022 The Apache Software Foundation. All rights reserved.