Skip to content

Add bundle package #2332

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 4 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import com.google.firebase.firestore.model.SnapshotVersion;

/** Represents a Firestore bundle saved by the SDK in its local storage. */
/* package */ class BundleMetadata {
public class BundleMetadata {
private final String bundleId;
private final int version;
private final SnapshotVersion createTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import android.util.Base64;
import androidx.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import com.google.firebase.firestore.model.DocumentKey;
import com.google.firebase.firestore.model.SnapshotVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import com.google.firebase.firestore.core.Query;
import com.google.firebase.firestore.core.Target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import com.google.firebase.firestore.model.SnapshotVersion;

/** Represents a named query saved by the SDK in its local storage. */
/* package */ class NamedQuery {
public class NamedQuery {
private final String name;
private final BundledQuery bundledQuery;
private final SnapshotVersion readTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
package com.google.firebase.firestore.bundle;

import androidx.annotation.RestrictTo;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package com.google.firebase.firestore.local;

import androidx.annotation.Nullable;
import com.google.firebase.firestore.bundle.BundleMetadata;
import com.google.firebase.firestore.bundle.NamedQuery;

/** Provides methods to save and read Firestore bundles. */
public interface BundleCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,12 @@ TargetData decodeTargetData(com.google.firebase.firestore.proto.Target targetPro
resumeToken);
}

public com.google.firestore.proto.BundledQuery encodeBundledQuery(
com.google.firebase.firestore.local.BundledQuery bundledQuery) {
public BundledQuery encodeBundledQuery(
com.google.firebase.firestore.bundle.BundledQuery bundledQuery) {
com.google.firestore.v1.Target.QueryTarget queryTarget =
rpcSerializer.encodeQueryTarget(bundledQuery.getTarget());

com.google.firestore.proto.BundledQuery.Builder result =
com.google.firestore.proto.BundledQuery.newBuilder();
BundledQuery.Builder result = BundledQuery.newBuilder();
result.setLimitType(
bundledQuery.getLimitType().equals(LimitType.LIMIT_TO_FIRST)
? BundledQuery.LimitType.FIRST
Expand All @@ -286,8 +285,8 @@ public com.google.firestore.proto.BundledQuery encodeBundledQuery(
return result.build();
}

public com.google.firebase.firestore.local.BundledQuery decodeBundledQuery(
com.google.firestore.proto.BundledQuery bundledQuery) {
public com.google.firebase.firestore.bundle.BundledQuery decodeBundledQuery(
BundledQuery bundledQuery) {
LimitType limitType =
bundledQuery.getLimitType().equals(BundledQuery.LimitType.FIRST)
? LimitType.LIMIT_TO_FIRST
Expand All @@ -296,6 +295,6 @@ public com.google.firebase.firestore.local.BundledQuery decodeBundledQuery(
rpcSerializer.decodeQueryTarget(
bundledQuery.getParent(), bundledQuery.getStructuredQuery());

return new com.google.firebase.firestore.local.BundledQuery(target, limitType);
return new com.google.firebase.firestore.bundle.BundledQuery(target, limitType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package com.google.firebase.firestore.local;

import androidx.annotation.Nullable;
import com.google.firebase.firestore.bundle.BundleMetadata;
import com.google.firebase.firestore.bundle.NamedQuery;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import androidx.annotation.Nullable;
import com.google.firebase.Timestamp;
import com.google.firebase.firestore.bundle.BundleMetadata;
import com.google.firebase.firestore.bundle.NamedQuery;
import com.google.firebase.firestore.model.SnapshotVersion;
import com.google.firestore.proto.BundledQuery;
import com.google.protobuf.InvalidProtocolBufferException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore.local;
package com.google.firebase.firestore.bundle;

import static com.google.firebase.firestore.testutil.TestUtil.filter;
import static com.google.firebase.firestore.testutil.TestUtil.key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import static org.junit.Assert.assertNull;

import com.google.firebase.Timestamp;
import com.google.firebase.firestore.bundle.BundleMetadata;
import com.google.firebase.firestore.bundle.BundledQuery;
import com.google.firebase.firestore.bundle.NamedQuery;
import com.google.firebase.firestore.core.Query;
import com.google.firebase.firestore.core.Target;
import com.google.firebase.firestore.model.ResourcePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.junit.Assert.assertTrue;

import com.google.firebase.Timestamp;
import com.google.firebase.firestore.bundle.BundledQuery;
import com.google.firebase.firestore.core.Query;
import com.google.firebase.firestore.core.Target;
import com.google.firebase.firestore.model.DatabaseId;
Expand Down