Skip to content

Commit

Permalink
MNTSUP-165 - speed up content_url query
Browse files Browse the repository at this point in the history
  • Loading branch information
wimfabri committed Oct 18, 2023
1 parent 28bacb6 commit a9191ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
username: ${{ secrets.CLOUDSMITH_USER }}
password: ${{ secrets.CLOUDSMITH_APIKEY }}
- name: Publish docker image
if: ${{ startsWith(github.ref, 'refs/heads/master') }}
#if: ${{ startsWith(github.ref, 'refs/heads/master') }}
uses: gradle/[email protected]
env:
BRANCH_NAME: ${{ github.ref_name }}
Expand Down
13 changes: 12 additions & 1 deletion src/main/docker/docker_root/swarmclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import records
from dataclasses import dataclass, asdict
import humanfriendly
import binascii

sys.path.insert(0,sys.path[0]+'/castorsdk')
import scspHeaders
Expand Down Expand Up @@ -456,7 +457,17 @@ def __init__(self, args):

def isDeletionCandidate(self, swarm_object):
if args.filter_method == 'alfresco_db':
result = self.alfresco_db.query_single_value("select count(*) from alf_content_url where content_url like :object_name", {'object_name': f"%/{swarm_object.name}"}) == 0
content_url_short = swarm_object.name[-12:]
#content_url_crc = binascii.crc32(bytes(f"swarm://{self.args.swarm_bucket}/{swarm_object.name}", 'ascii'))
content_url_crc = binascii.crc32(bytes(f"s3://{swarm_object.name}", 'ascii'))
# table has an index on content_url_short + content_url_crc
result = self.alfresco_db.query_single_value(
"select count(*) from alf_content_url where content_url_short = :content_url_short and content_url_crc = :content_url_crc",
{
'content_url_short': content_url_short,
'content_url_crc': content_url_crc
}
) == 0
elif args.filter_method == 'regex':
result = self.filterRegex.match(swarm_object.name)
logging.trace(f"filter { swarm_object.name }: { bool(result) } - size { humanfriendly.format_size(swarm_object.bytes, binary=True) }")
Expand Down

0 comments on commit a9191ed

Please sign in to comment.