Skip to content

add update time to FieldIndex #2984

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

Merged
merged 3 commits into from
Sep 20, 2021
Merged

Conversation

thebrianchen
Copy link

Incremental PR to add storing and retrieving last update time from FieldIndex. Also renamed collectionId to collectionGroup on fieldIndex.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 17, 2021

Coverage Report

Affected SDKs

  • firebase-firestore

    SDK overall coverage changed from 43.10% (e445aca) to 43.16% (38d628d2) by +0.06%.

    Filename Base (e445aca) Head (38d628d2) Diff
    FieldIndex.java 76.47% 75.00% -1.47%
    LocalSerializer.java 97.95% 97.97% +0.03%
    SQLiteIndexManager.java 96.36% 95.74% -0.62%

Test Logs

Notes

HTML coverage reports can be produced locally with ./gradlew <product>:checkCoverage.
Report files are located at <product-build-dir>/reports/jacoco/.

Head commit (38d628d2) is created by Prow via merging commits: e445aca ceb3121.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 17, 2021

Binary Size Report

Affected SDKs

  • firebase-firestore

    Type Base (e445aca) Head (38d628d2) Diff
    aar 1.20 MB 1.20 MB +792 B (+0.1%)
    apk (release) 3.24 MB 3.24 MB +456 B (+0.0%)

Test Logs

Notes

Head commit (38d628d2) is created by Prow via merging commits: e445aca ceb3121.

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Some feedback. Please send to @wu-hui if you have updates by Monday.

public FieldIndex decodeFieldIndex(String collection_group, int indexId, Index index) {
FieldIndex fieldIndex = new FieldIndex(collection_group, indexId);
public FieldIndex decodeFieldIndex(
String collectionGroup, int indexId, Index index, int updateSeconds, int updateNanos) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use SnapshotVersion for seconds+nanos.

Copy link
Author

Choose a reason for hiding this comment

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

done.

result = 31 * result + segments.hashCode();
return result;
}

@Override
public String toString() {
return String.format("FieldIndex{collectionId='%s', segments=%s}", collectionId, segments);
return String.format(
"FieldIndex{collectionGroup='%s', segments=%s}", collectionGroup, segments);
Copy link
Contributor

Choose a reason for hiding this comment

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

updateTime?

Copy link
Author

Choose a reason for hiding this comment

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

done.

}

@Override
public int hashCode() {
int result = collectionId.hashCode();
int result = collectionGroup.hashCode();
Copy link
Contributor

Choose a reason for hiding this comment

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

updateTime?

Copy link
Author

Choose a reason for hiding this comment

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

done.

@@ -118,18 +131,19 @@ public boolean equals(Object o) {
FieldIndex fieldIndex = (FieldIndex) o;

if (!segments.equals(fieldIndex.segments)) return false;
return collectionId.equals(fieldIndex.collectionId);
return collectionGroup.equals(fieldIndex.collectionGroup);
Copy link
Contributor

Choose a reason for hiding this comment

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

updateTime?

Copy link
Author

Choose a reason for hiding this comment

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

done.

assertEquals(indexes.size(), 1);
FieldIndex index = indexes.get(0);
assertEquals(index.getUpdateTime(), new Timestamp(10, 20));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This test seems better suited for our serialization tests.

Copy link
Author

Choose a reason for hiding this comment

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

The test here checks that the persistence queries in addFieldIndex and getFieldIndex are correct.

Copy link
Author

@thebrianchen thebrianchen left a comment

Choose a reason for hiding this comment

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

thanks for the speedy review!

public FieldIndex decodeFieldIndex(String collection_group, int indexId, Index index) {
FieldIndex fieldIndex = new FieldIndex(collection_group, indexId);
public FieldIndex decodeFieldIndex(
String collectionGroup, int indexId, Index index, int updateSeconds, int updateNanos) {
Copy link
Author

Choose a reason for hiding this comment

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

done.

@@ -118,18 +131,19 @@ public boolean equals(Object o) {
FieldIndex fieldIndex = (FieldIndex) o;

if (!segments.equals(fieldIndex.segments)) return false;
return collectionId.equals(fieldIndex.collectionId);
return collectionGroup.equals(fieldIndex.collectionGroup);
Copy link
Author

Choose a reason for hiding this comment

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

done.

}

@Override
public int hashCode() {
int result = collectionId.hashCode();
int result = collectionGroup.hashCode();
Copy link
Author

Choose a reason for hiding this comment

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

done.

result = 31 * result + segments.hashCode();
return result;
}

@Override
public String toString() {
return String.format("FieldIndex{collectionId='%s', segments=%s}", collectionId, segments);
return String.format(
"FieldIndex{collectionGroup='%s', segments=%s}", collectionGroup, segments);
Copy link
Author

Choose a reason for hiding this comment

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

done.

assertEquals(indexes.size(), 1);
FieldIndex index = indexes.get(0);
assertEquals(index.getUpdateTime(), new Timestamp(10, 20));
}
Copy link
Author

Choose a reason for hiding this comment

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

The test here checks that the persistence queries in addFieldIndex and getFieldIndex are correct.

@thebrianchen thebrianchen requested a review from wu-hui September 17, 2021 21:17
@thebrianchen thebrianchen assigned wu-hui and unassigned thebrianchen Sep 17, 2021
Copy link
Contributor

@wu-hui wu-hui left a comment

Choose a reason for hiding this comment

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

@thebrianchen You replied some comments, but the actual changes are not applied it seems. Did you forget to push a new commit?

@wu-hui wu-hui assigned thebrianchen and wu-hui and unassigned wu-hui and thebrianchen Sep 20, 2021
List<FieldIndex> allIndexes = new ArrayList<>();
db.query(
"SELECT index_id, collection_group, index_proto, update_time_seconds, update_time_nanos FROM index_configuration "
+ "WHERE active")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does WHERE active actually work? And even if it works, we should still be using active = 1.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching. SQL query still works without adding = 1, but it's best to follow best practices.

@wu-hui wu-hui assigned thebrianchen and unassigned wu-hui Sep 20, 2021
@thebrianchen thebrianchen requested a review from wu-hui September 20, 2021 16:40
@thebrianchen thebrianchen assigned wu-hui and unassigned thebrianchen Sep 20, 2021
@wu-hui wu-hui removed their assignment Sep 20, 2021
@google-oss-bot
Copy link
Contributor

@thebrianchen: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
device-check-changed ceb3121 link /test device-check-changed

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@thebrianchen thebrianchen merged commit 0e40391 into master Sep 20, 2021
@thebrianchen thebrianchen deleted the bc/field-index-update-times branch September 20, 2021 19:29
@firebase firebase locked and limited conversation to collaborators Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants