Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylEnkidu committed Jul 17, 2023
1 parent 09c4373 commit b59690f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
* in remoteDocumentCache or local mutations for the document). The view is computed by applying the
* mutations in the MutationQueue to the RemoteDocumentCache.
*/
public class LocalDocumentsView {
class LocalDocumentsView {

private final RemoteDocumentCache remoteDocumentCache;
private final MutationQueue mutationQueue;
private final DocumentOverlayCache documentOverlayCache;
private final IndexManager indexManager;

protected LocalDocumentsView(
LocalDocumentsView(
RemoteDocumentCache remoteDocumentCache,
MutationQueue mutationQueue,
DocumentOverlayCache documentOverlayCache,
Expand Down Expand Up @@ -279,7 +279,7 @@ ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery(
* @param query The query to match documents against.
* @param offset Read time and key to start scanning by (exclusive).
*/
protected ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery(
ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery(
Query query, IndexOffset offset) {
return getDocumentsMatchingQuery(query, offset, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void setReferenceDelegate(ReferenceDelegate delegate) {
}

@Override
public MutationQueue getMutationQueue(User user, IndexManager indexManager) {
MutationQueue getMutationQueue(User user, IndexManager indexManager) {
MemoryMutationQueue queue = mutationQueues.get(user);
if (queue == null) {
queue = new MemoryMutationQueue(this, user);
Expand All @@ -113,12 +113,12 @@ MemoryTargetCache getTargetCache() {
}

@Override
public MemoryRemoteDocumentCache getRemoteDocumentCache() {
MemoryRemoteDocumentCache getRemoteDocumentCache() {
return remoteDocumentCache;
}

@Override
public MemoryIndexManager getIndexManager(User user) {
MemoryIndexManager getIndexManager(User user) {
// We do not currently support indices for memory persistence, so we can return the same shared
// instance of the memory index manager.
return indexManager;
Expand All @@ -130,7 +130,7 @@ BundleCache getBundleCache() {
}

@Override
public DocumentOverlayCache getDocumentOverlayCache(User user) {
DocumentOverlayCache getDocumentOverlayCache(User user) {
MemoryDocumentOverlayCache overlay = overlays.get(user);
if (overlay == null) {
overlay = new MemoryDocumentOverlayCache();
Expand All @@ -145,7 +145,7 @@ OverlayMigrationManager getOverlayMigrationManager() {
}

@Override
public void runTransaction(String action, Runnable operation) {
void runTransaction(String action, Runnable operation) {
referenceDelegate.onTransactionStarted();
try {
operation.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;

/** A queue of mutations to apply to the remote store. */
public interface MutationQueue {
interface MutationQueue {
/**
* Starts the mutation queue, performing any initial reads that might be required to establish
* invariants, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ public abstract class Persistence {
* implementation to the extent possible (e.g. in the case of uid switching from
* sally=>jack=>sally, sally's mutation queue will be preserved).
*/
public abstract MutationQueue getMutationQueue(User user, IndexManager indexManager);
abstract MutationQueue getMutationQueue(User user, IndexManager indexManager);

/** Creates a TargetCache representing the persisted cache of queries. */
abstract TargetCache getTargetCache();

/** Creates a RemoteDocumentCache representing the persisted cache of remote documents. */
public abstract RemoteDocumentCache getRemoteDocumentCache();
abstract RemoteDocumentCache getRemoteDocumentCache();

/** Creates an IndexManager that manages our persisted query indexes. */
public abstract IndexManager getIndexManager(User user);
abstract IndexManager getIndexManager(User user);

/** Returns a BundleCache representing the persisted cache of loaded bundles. */
abstract BundleCache getBundleCache();

/** Returns a DocumentOverlayCache representing the documents that are mutated locally. */
public abstract DocumentOverlayCache getDocumentOverlayCache(User user);
abstract DocumentOverlayCache getDocumentOverlayCache(User user);

/** Returns a OverlayMigrationManager that runs any pending data migration required by SDK. */
abstract OverlayMigrationManager getOverlayMigrationManager();
Expand All @@ -106,7 +106,7 @@ public abstract class Persistence {
* @param action A description of the action performed by this transaction, used for logging.
* @param operation The operation to run inside a transaction.
*/
public abstract void runTransaction(String action, Runnable operation);
abstract void runTransaction(String action, Runnable operation);

/**
* Performs an operation inside a persistence transaction. Any reads or writes against persistence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* meaning we can cache both Document instances (an actual document with data) as well as NoDocument
* instances (indicating that the document is known to not exist).
*/
public interface RemoteDocumentCache {
interface RemoteDocumentCache {

/** Sets the index manager to use for managing the collectionGroup index. */
void setIndexManager(IndexManager indexManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public SQLiteLruReferenceDelegate getReferenceDelegate() {
}

@Override
public MutationQueue getMutationQueue(User user, IndexManager indexManager) {
MutationQueue getMutationQueue(User user, IndexManager indexManager) {
return new SQLiteMutationQueue(this, serializer, user, indexManager);
}

Expand All @@ -181,7 +181,7 @@ SQLiteTargetCache getTargetCache() {
}

@Override
public IndexManager getIndexManager(User user) {
IndexManager getIndexManager(User user) {
return new SQLiteIndexManager(this, serializer, user);
}

Expand All @@ -191,7 +191,7 @@ BundleCache getBundleCache() {
}

@Override
public DocumentOverlayCache getDocumentOverlayCache(User user) {
DocumentOverlayCache getDocumentOverlayCache(User user) {
return new SQLiteDocumentOverlayCache(this, this.serializer, user);
}

Expand All @@ -201,12 +201,12 @@ OverlayMigrationManager getOverlayMigrationManager() {
}

@Override
public RemoteDocumentCache getRemoteDocumentCache() {
RemoteDocumentCache getRemoteDocumentCache() {
return remoteDocumentCache;
}

@Override
public void runTransaction(String action, Runnable operation) {
void runTransaction(String action, Runnable operation) {
Logger.debug(TAG, "Starting transaction: %s", action);
db.beginTransactionWithListener(transactionListener);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,163 +449,6 @@ public void withMultipleNotIn() {
validateServesTarget(q, "a", FieldIndex.Segment.Kind.ASCENDING);
}

@Test
public void buildTargetIndex() {
Query q =
query("collId")
.filter(filter("a", "==", 1))
.filter(filter("b", "==", 2))
.orderBy(orderBy("__name__", "desc"));
TargetIndexMatcher targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
FieldIndex expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a")).orderBy(orderBy("b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "array-contains", "a")).orderBy(orderBy("b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", ">", 1)).filter(filter("a", "<", 10));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "in", Arrays.asList(1, 2))).filter(filter("b", "==", 5));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("value", "array-contains", "foo")).orderBy(orderBy("value"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("a", "array-contains", "a"))
.filter(filter("a", ">", "b"))
.orderBy(orderBy("a", "asc"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "==", 1)).orderBy(orderBy("__name__", "desc"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a1", "==", "a")).filter(filter("a2", "==", "b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("equality1", "==", "a"))
.filter(filter("equality2", "==", "b"))
.filter(filter("inequality", ">=", "c"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("equality1", "==", "a"))
.filter(filter("inequality", ">=", "c"))
.filter(filter("equality2", "==", "b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a", "desc"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").orderBy(orderBy("a")).orderBy(orderBy("__name__"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "!=", 1));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "!=", 1)).orderBy(orderBy("a")).orderBy(orderBy("b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q = query("collId").filter(filter("a", "==", "a")).filter(filter("b", ">", "b"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("a1", "==", "a"))
.filter(filter("a2", ">", "b"))
.orderBy(orderBy("a2", "asc"));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("a", ">=", 1))
.filter(filter("a", "==", 5))
.filter(filter("a", "<=", 10));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
// assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));

q =
query("collId")
.filter(filter("a", "not-in", Arrays.asList(1, 2, 3)))
.filter(filter("a", ">=", 2));
targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));
}

@Test
public void failedTest() {
Query q =
query("collId")
.filter(filter("a", ">=", 1))
.filter(filter("a", "==", 5))
.filter(filter("a", "<=", 10));
TargetIndexMatcher targetIndexMatcher = new TargetIndexMatcher(q.toTarget());
FieldIndex expectedIndex = targetIndexMatcher.BuildTargetIndex();
assertTrue(targetIndexMatcher.servedByIndex(expectedIndex));
}

@Test
public void withMultipleOrderBys() {
Query q =
Expand Down

0 comments on commit b59690f

Please sign in to comment.