Skip to content

Commit

Permalink
Increase report filter performance
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Oct 18, 2017
1 parent ab67d26 commit feedfcc
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 170 deletions.
36 changes: 36 additions & 0 deletions db_migrate/versions/04e2bad1cc8f_report_filename_and_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Report filename and indexes
Revision ID: 04e2bad1cc8f
Revises: 82ca43f05c10
Create Date: 2017-10-18 10:58:33.997769
"""

# revision identifiers, used by Alembic.
revision = '04e2bad1cc8f'
down_revision = '82ca43f05c10'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('reports', sa.Column('filename', sa.String(), nullable=True))
op.create_index(op.f('ix_reports_checker_id'), 'reports', ['checker_id'], unique=False)
op.create_index(op.f('ix_reports_checker_message'), 'reports', ['checker_message'], unique=False)
op.create_index(op.f('ix_reports_filename'), 'reports', ['filename'], unique=False)
op.create_index('report_filter_idx', 'reports', ['bug_id', 'checker_id', 'checker_message', 'severity', 'filename'], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('report_filter_idx', table_name='reports')
op.drop_index(op.f('ix_reports_filename'), table_name='reports')
op.drop_index(op.f('ix_reports_checker_message'), table_name='reports')
op.drop_index(op.f('ix_reports_checker_id'), table_name='reports')
op.drop_column('reports', 'filename')
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions libcodechecker/analyze/store_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def setRunDuration(storage_session, run_id, duration):
def addReport(storage_session,
run_id,
file_id,
file_name,
main_section,
bugpath,
events,
Expand Down Expand Up @@ -384,6 +385,7 @@ def addReport(storage_session,
report = Report(run_id,
bug_hash,
file_id,
file_name,
msg,
checker_id,
checker_cat,
Expand Down
42 changes: 20 additions & 22 deletions libcodechecker/cmd/cmd_line_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def printReports(client, reports, output_format):


def handle_list_result_types(args):
def getStatistics(client, run_ids, field, values):
def get_statistics(client, run_ids, field, values):
report_filter = ttypes.ReportFilter()
report_filter.isUnique = True
setattr(report_filter, field, values)
Expand All @@ -427,17 +427,15 @@ def getStatistics(client, run_ids, field, values):

return dict((res.name, res.count) for res in checkers)

def checkerCount(dict, key):
def checker_count(dict, key):
return dict[key] if key in dict else 0

client = setup_client(args.product_url)

if 'all_results' in args:
items = check_run_names(client, None)
else:
run_ids = None
if 'all_results' not in args:
items = check_run_names(client, args.names)

run_ids = map(lambda run: run.runId, items.values())
run_ids = map(lambda run: run.runId, items.values())

all_checkers_report_filter = ttypes.ReportFilter()
all_checkers_report_filter.isUnique = True
Expand All @@ -446,20 +444,20 @@ def checkerCount(dict, key):
None)
all_checkers_dict = dict((res.name, res) for res in all_checkers)

unrev_checkers = getStatistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.UNREVIEWED])
unrev_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.UNREVIEWED])

confirmed_checkers = getStatistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.CONFIRMED])
confirmed_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.CONFIRMED])

false_checkers = getStatistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.FALSE_POSITIVE])
false_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.FALSE_POSITIVE])

intentional_checkers = getStatistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.INTENTIONAL])
intentional_checkers = get_statistics(client, run_ids, 'reviewStatus',
[ttypes.ReviewStatus.INTENTIONAL])

resolved_checkers = getStatistics(client, run_ids, 'detectionStatus',
[ttypes.DetectionStatus.RESOLVED])
resolved_checkers = get_statistics(client, run_ids, 'detectionStatus',
[ttypes.DetectionStatus.RESOLVED])

all_results = []
for key, checker_data in sorted(all_checkers_dict.items(),
Expand All @@ -469,11 +467,11 @@ def checkerCount(dict, key):
checker=key,
severity=ttypes.Severity._VALUES_TO_NAMES[checker_data.severity],
reports=checker_data.count,
unreviewed=checkerCount(unrev_checkers, key),
confirmed=checkerCount(confirmed_checkers, key),
false_positive=checkerCount(false_checkers, key),
intentional=checkerCount(intentional_checkers, key),
resolved=checkerCount(resolved_checkers, key),
unreviewed=checker_count(unrev_checkers, key),
confirmed=checker_count(confirmed_checkers, key),
false_positive=checker_count(false_checkers, key),
intentional=checker_count(intentional_checkers, key),
resolved=checker_count(resolved_checkers, key),
))

if args.output_format == 'json':
Expand Down
Loading

0 comments on commit feedfcc

Please sign in to comment.