Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction of the return values of the DatabaseInfo methods for determining the insert, read and delete operations #1183

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

DevM900
Copy link
Contributor

@DevM900 DevM900 commented Jul 4, 2024

These changes make it possible to analyze the performance of queries.

IDictionary<short, ulong> readSeqCount = dbInfo.GetReadSeqCount();
IDictionary<short, ulong> readIdxCount = dbInfo.GetReadIdxCount();

var fbCommand = new FbCommand("SELECT MAX(INT_FIELD) FROM TEST", Connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await using

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

IDictionary<short, ulong> readSeqCount = dbInfo.GetReadSeqCount();
IDictionary<short, ulong> readIdxCount = dbInfo.GetReadIdxCount();

var fbCommand = new FbCommand("INSERT INTO TEST (INT_FIELD) VALUES (900)", Connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await using

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

IDictionary<string, short> tableNameList = GetTableNameList();
short tableIdTest = tableNameList["TEST"];

var fbCommand = new FbCommand("INSERT INTO TEST (INT_FIELD) VALUES (900)", Connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await using

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -51,6 +53,22 @@ public static string ToHexString(this byte[] b)
return BitConverter.ToString(b).Replace("-", string.Empty);
}

public static IDictionary<short, ulong> GetTableStatistic(this byte[] b, int aLength)
{
int capacity = aLength > 3 ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it on single line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

case IscCodes.isc_info_update_count:
case IscCodes.isc_info_read_seq_count:
case IscCodes.isc_info_read_idx_count:
info.Add( buffer.GetTableStatistic( length ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra spaces around (/).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private IDictionary<short, ulong> GetAffectedTables(IDictionary<short, ulong> aStatisticInfoBefore, IDictionary<short, ulong> aStatisticInfoAfter)
{
var result = new Dictionary<short, ulong>();
foreach (KeyValuePair<short, ulong> keyValuePair in aStatisticInfoAfter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
if (aStatisticInfoBefore.TryGetValue(keyValuePair.Key, out ulong value))
{
ulong counter = keyValuePair.Value - value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (counter > 0)
result.Add(keyValuePair.Key, counter);
}
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add }/{ for consistency sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return result;
}

private IDictionary<string, short> GetTableNameList()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove private.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -51,6 +53,22 @@ public static string ToHexString(this byte[] b)
return BitConverter.ToString(b).Replace("-", string.Empty);
}

public static IDictionary<short, ulong> GetTableStatistic(this byte[] b, int aLength)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove a prefix on argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants