mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
New database queries to provide the minimum and maximum transaction id for a given nodeId range. (#780)
This feature will be used by SOLR MetadataTracker to improve performance.
This commit is contained in:
@@ -4960,6 +4960,18 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
return (id == null ? LONG_ZERO : id);
|
return (id == null ? LONG_ZERO : id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getMinTxInNodeIdRange(Long fromNodeId, Long toNodeId)
|
||||||
|
{
|
||||||
|
return selectMinTxInNodeIdRange(fromNodeId, toNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId)
|
||||||
|
{
|
||||||
|
return selectMaxTxInNodeIdRange(fromNodeId, toNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Abstract methods for underlying CRUD
|
* Abstract methods for underlying CRUD
|
||||||
*/
|
*/
|
||||||
@@ -5128,4 +5140,6 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
protected abstract Long selectMinTxnId();
|
protected abstract Long selectMinTxnId();
|
||||||
protected abstract Long selectMaxTxnId();
|
protected abstract Long selectMaxTxnId();
|
||||||
protected abstract Long selectMinUnusedTxnCommitTime();
|
protected abstract Long selectMinUnusedTxnCommitTime();
|
||||||
|
protected abstract Long selectMinTxInNodeIdRange(Long fromNodeId, Long toNodeId);
|
||||||
|
protected abstract Long selectMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
|
||||||
}
|
}
|
||||||
|
@@ -936,4 +936,23 @@ public interface NodeDAO extends NodeBulkLoader
|
|||||||
Long toTimeExclusive,
|
Long toTimeExclusive,
|
||||||
boolean remoteOnly);
|
boolean remoteOnly);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the minimum commit time from transactions including a node id
|
||||||
|
* in the range [fromNodeId:toNodeId]
|
||||||
|
*
|
||||||
|
* @param fromNodeId Initial node id
|
||||||
|
* @param toNodeId Final node id
|
||||||
|
* @return minimum commit time
|
||||||
|
*/
|
||||||
|
public Long getMinTxInNodeIdRange(Long fromNodeId, Long toNodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum commit time from transactions including a node id
|
||||||
|
* in the range [fromNodeId:toNodeId]
|
||||||
|
*
|
||||||
|
* @param fromNodeId Initial node id
|
||||||
|
* @param toNodeId Final node id
|
||||||
|
* @return maximum commit time
|
||||||
|
*/
|
||||||
|
public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Repository
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.domain.node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Node Range bean including an initial fromNodeId and a final fromNodeId
|
||||||
|
*
|
||||||
|
* @author aborroy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NodeRangeEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
private Long fromNodeId;
|
||||||
|
private Long toNodeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the fromNodeId
|
||||||
|
*/
|
||||||
|
public Long getFromNodeId()
|
||||||
|
{
|
||||||
|
return fromNodeId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param fromNodeId the fromNodeId to set
|
||||||
|
*/
|
||||||
|
public void setFromNodeId(Long fromNodeId)
|
||||||
|
{
|
||||||
|
this.fromNodeId = fromNodeId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the toNodeId
|
||||||
|
*/
|
||||||
|
public Long getToNodeId()
|
||||||
|
{
|
||||||
|
return toNodeId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param toNodeId the toNodeId to set
|
||||||
|
*/
|
||||||
|
public void setToNodeId(Long toNodeId)
|
||||||
|
{
|
||||||
|
this.toNodeId = toNodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -50,6 +50,7 @@ import org.alfresco.repo.domain.node.NodeIdAndAclId;
|
|||||||
import org.alfresco.repo.domain.node.NodePropertyEntity;
|
import org.alfresco.repo.domain.node.NodePropertyEntity;
|
||||||
import org.alfresco.repo.domain.node.NodePropertyKey;
|
import org.alfresco.repo.domain.node.NodePropertyKey;
|
||||||
import org.alfresco.repo.domain.node.NodePropertyValue;
|
import org.alfresco.repo.domain.node.NodePropertyValue;
|
||||||
|
import org.alfresco.repo.domain.node.NodeRangeEntity;
|
||||||
import org.alfresco.repo.domain.node.NodeUpdateEntity;
|
import org.alfresco.repo.domain.node.NodeUpdateEntity;
|
||||||
import org.alfresco.repo.domain.node.NodeVersionKey;
|
import org.alfresco.repo.domain.node.NodeVersionKey;
|
||||||
import org.alfresco.repo.domain.node.PrimaryChildrenAclUpdateEntity;
|
import org.alfresco.repo.domain.node.PrimaryChildrenAclUpdateEntity;
|
||||||
@@ -165,6 +166,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
private static final String SELECT_TXN_MAX_ID = "alfresco.node.select_TxnMaxId";
|
private static final String SELECT_TXN_MAX_ID = "alfresco.node.select_TxnMaxId";
|
||||||
private static final String SELECT_TXN_UNUSED_MIN_COMMIT_TIME = "alfresco.node.select_TxnMinUnusedCommitTime";
|
private static final String SELECT_TXN_UNUSED_MIN_COMMIT_TIME = "alfresco.node.select_TxnMinUnusedCommitTime";
|
||||||
private static final String SELECT_ONE_TXNS_BY_COMMIT_TIME_DESC = "alfresco.node.select_OneTxnsByCommitTimeDescending";
|
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";
|
||||||
|
|
||||||
protected QNameDAO qnameDAO;
|
protected QNameDAO qnameDAO;
|
||||||
protected DictionaryService dictionaryService;
|
protected DictionaryService dictionaryService;
|
||||||
@@ -1751,6 +1754,42 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
return template.selectOne(COUNT_CHILD_ASSOC_BY_PARENT_ID, childAssoc);
|
return template.selectOne(COUNT_CHILD_ASSOC_BY_PARENT_ID, childAssoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the minimum commit time from transactions including a node id
|
||||||
|
* in the range [fromNodeId:toNodeId]
|
||||||
|
*
|
||||||
|
* @param fromNodeId Initial node id
|
||||||
|
* @param toNodeId Final node id
|
||||||
|
* @return minimum commit time
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Long selectMinTxInNodeIdRange(Long fromNodeId, Long toNodeId)
|
||||||
|
{
|
||||||
|
NodeRangeEntity nodeRangeEntity = new NodeRangeEntity();
|
||||||
|
nodeRangeEntity.setFromNodeId(fromNodeId);
|
||||||
|
nodeRangeEntity.setToNodeId(toNodeId);
|
||||||
|
|
||||||
|
return template.selectOne(SELECT_TXN_MIN_TX_ID_IN_NODE_IDRANGE, nodeRangeEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum commit time from transactions including a node id
|
||||||
|
* in the range [fromNodeId:toNodeId]
|
||||||
|
*
|
||||||
|
* @param fromNodeId Initial node id
|
||||||
|
* @param toNodeId Final node id
|
||||||
|
* @return maximum commit time
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Long selectMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId)
|
||||||
|
{
|
||||||
|
NodeRangeEntity nodeRangeEntity = new NodeRangeEntity();
|
||||||
|
nodeRangeEntity.setFromNodeId(fromNodeId);
|
||||||
|
nodeRangeEntity.setToNodeId(toNodeId);
|
||||||
|
|
||||||
|
return template.selectOne(SELECT_TXN_MAX_TX_ID_IN_NODE_IDRANGE, nodeRangeEntity);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DAO OVERRIDES
|
* DAO OVERRIDES
|
||||||
*/
|
*/
|
||||||
|
@@ -1487,4 +1487,40 @@
|
|||||||
<if test="minCommitTime != null"><![CDATA[and txn.commit_time_ms >= #{minCommitTime}]]></if>
|
<if test="minCommitTime != null"><![CDATA[and txn.commit_time_ms >= #{minCommitTime}]]></if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="select_TxnMinTxIdInNodeIdRange" resultType="java.lang.Long">
|
||||||
|
select
|
||||||
|
commit_time_ms
|
||||||
|
from
|
||||||
|
alf_transaction
|
||||||
|
where
|
||||||
|
id =
|
||||||
|
(
|
||||||
|
select
|
||||||
|
min(transaction_id)
|
||||||
|
from
|
||||||
|
alf_node
|
||||||
|
where
|
||||||
|
id >= #{fromNodeId}
|
||||||
|
and id <= #{toNodeId}
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="select_TxnMaxTxIdInNodeIdRange" resultType="java.lang.Long">
|
||||||
|
select
|
||||||
|
commit_time_ms
|
||||||
|
from
|
||||||
|
alf_transaction
|
||||||
|
where
|
||||||
|
id =
|
||||||
|
(
|
||||||
|
select
|
||||||
|
max(transaction_id)
|
||||||
|
from
|
||||||
|
alf_node
|
||||||
|
where
|
||||||
|
id >= #{fromNodeId}
|
||||||
|
and id <= #{toNodeId}
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Reference in New Issue
Block a user