Skip to content

Commit 9c9c4b2

Browse files
Update backfill code
1 parent b38224d commit 9c9c4b2

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/index/IndexEntry.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public class IndexEntry {
2323
private final int indexId;
2424
private final byte[] indexValue;
2525
private final String uid;
26-
private final String documentId;
26+
private final String documentName;
2727

28-
public IndexEntry(int indexId, byte[] indexValue, String uid, String documentId) {
28+
public IndexEntry(int indexId, byte[] indexValue, String uid, String documentName) {
2929
this.indexId = indexId;
3030
this.indexValue = indexValue;
3131
this.uid = uid;
32-
this.documentId = documentId;
32+
this.documentName = documentName;
3333
}
3434

3535
public int getIndexId() {
@@ -44,7 +44,7 @@ public String getUid() {
4444
return uid;
4545
}
4646

47-
public String getDocumentId() {
48-
return documentId;
47+
public String getDocumentName() {
48+
return documentName;
4949
}
5050
}

firebase-firestore/src/main/java/com/google/firebase/firestore/local/IndexBackfiller.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,31 +117,31 @@ void addIndexEntry(IndexEntry entry) {
117117
+ "index_id, "
118118
+ "index_value, "
119119
+ "uid, "
120-
+ "document_id) VALUES(?, ?, ?, ?)",
120+
+ "document_name) VALUES(?, ?, ?, ?)",
121121
entry.getIndexId(),
122122
entry.getIndexValue(),
123123
entry.getUid(),
124-
entry.getDocumentId());
124+
entry.getDocumentName());
125125
}
126126

127127
@VisibleForTesting
128-
void removeIndexEntry(int indexId, String uid, String documentId) {
128+
void removeIndexEntry(int indexId, String uid, String documentName) {
129129
persistence.execute(
130130
"DELETE FROM index_entries "
131131
+ "WHERE index_id = ? "
132132
+ "AND uid = ?"
133-
+ "AND document_id = ?",
133+
+ "AND document_name = ?",
134134
indexId,
135135
uid,
136-
documentId);
136+
documentName);
137137
;
138138
}
139139

140140
@Nullable
141141
@VisibleForTesting
142142
IndexEntry getIndexEntry(int indexId) {
143143
return persistence
144-
.query("SELECT index_value, uid, document_id FROM index_entries WHERE index_id = ?")
144+
.query("SELECT index_value, uid, document_name FROM index_entries WHERE index_id = ?")
145145
.binding(indexId)
146146
.firstValue(
147147
row ->

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteIndexBackfillerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ public void tearDown() {
6565
@Test
6666
public void addAndRemoveIndexEntry() {
6767
IndexEntry testEntry =
68-
new IndexEntry(1, "TEST_BLOB".getBytes(), "sample-uid", "sample-documentId");
68+
new IndexEntry(1, "TEST_BLOB".getBytes(), "sample-uid", "coll/sample-documentId");
6969
persistence.runTransaction(
7070
"testAddAndRemoveIndexEntry",
7171
() -> {
7272
backfiller.addIndexEntry(testEntry);
7373
IndexEntry entry = backfiller.getIndexEntry(1);
7474
assertNotNull(entry);
7575
assertEquals("TEST_BLOB", new String(entry.getIndexValue()));
76-
assertEquals("sample-documentId", entry.getDocumentId());
76+
assertEquals("coll/sample-documentId", entry.getDocumentName());
7777
assertEquals("sample-uid", entry.getUid());
7878

79-
backfiller.removeIndexEntry(1, "sample-uid", "sample-documentId");
79+
backfiller.removeIndexEntry(1, "sample-uid", "coll/sample-documentId");
8080
entry = backfiller.getIndexEntry(1);
8181
assertNull(entry);
8282
});

0 commit comments

Comments
 (0)