SEARCH-2028: New SOLR database query to provide the next transaction commit time from a given time commit. (#783)

This feature will be used by SOLR MetadataTracker to improve performance.
This commit is contained in:
Angel Borroy
2020-01-20 12:55:56 +01:00
committed by GitHub
parent 9c7ad0b3ab
commit aa41767e58
4 changed files with 45 additions and 2 deletions

View File

@@ -4868,6 +4868,12 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId)
{
return selectMaxTxInNodeIdRange(fromNodeId, toNodeId);
}
@Override
public Long getNextTxCommitTime(Long fromCommitTime)
{
return selectNextTxCommitTime(fromCommitTime);
}
/*
@@ -5037,5 +5043,6 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
protected abstract Long selectMaxTxnId();
protected abstract Long selectMinUnusedTxnCommitTime();
protected abstract Long selectMinTxInNodeIdRange(Long fromNodeId, Long toNodeId);
protected abstract Long selectMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
protected abstract Long selectMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
protected abstract Long selectNextTxCommitTime(Long fromCommitTime);
}

View File

@@ -913,5 +913,14 @@ public interface NodeDAO extends NodeBulkLoader
* @param toNodeId Final node id
* @return maximum commit time
*/
public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
/**
* Gets the next commit time from [fromCommitTime]
*
* @param fromCommitTime Initial commit time
* @return next commit time
*/
public Long getNextTxCommitTime(Long fromCommitTime);
}

View File

@@ -165,6 +165,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
private static final String SELECT_ONE_TXNS_BY_COMMIT_TIME_DESC = "alfresco.node.select_OneTxnsByCommitTimeDescending";
private static final String SELECT_TXN_MIN_TX_ID_IN_NODE_IDRANGE = "alfresco.node.select_TxnMinTxIdInNodeIdRange";
private static final String SELECT_TXN_MAX_TX_ID_IN_NODE_IDRANGE = "alfresco.node.select_TxnMaxTxIdInNodeIdRange";
private static final String SELECT_TXN_NEXT_TXN_COMMIT_TIME = "select_TxnNextTxnCommitTime";
protected QNameDAO qnameDAO;
protected DictionaryService dictionaryService;
@@ -1753,6 +1754,23 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
return template.selectOne(SELECT_TXN_MAX_TX_ID_IN_NODE_IDRANGE, nodeRangeEntity);
}
/**
* Gets the next commit time from [fromCommitTime]
*
* @param fromCommitTime Initial commit time
* @return next commit time
*/
@Override
public Long selectNextTxCommitTime(Long fromCommitTime)
{
TransactionQueryEntity fromCommitTimeEntity = new TransactionQueryEntity();
fromCommitTimeEntity.setMinCommitTime(fromCommitTime);
return template.selectOne(SELECT_TXN_NEXT_TXN_COMMIT_TIME, fromCommitTimeEntity);
}
/*
* DAO OVERRIDES
*/

View File

@@ -1496,4 +1496,13 @@
)
</select>
<select id="select_TxnNextTxnCommitTime" resultType="java.lang.Long">
select
min(commit_time_ms)
from
alf_transaction
where
commit_time_ms > #{minCommitTime}
</select>
</mapper>