AppSearchBlobHandle


@ExperimentalAppSearchApi
public final class AppSearchBlobHandle


An identifier to represent a blob in AppSearch.

A "blob" is a large binary object. It is used to store a significant amount of data that is not searchable, such as images, videos, audio files, or other binary data. Unlike other fields in AppSearch, blobs are stored as blob files on disk rather than in memory, and use android.os.ParcelFileDescriptor to read and write. This allows for efficient handling of large, non-searchable content.

AppSearchBlobHandle is a light-weight Property of GenericDocument, which is a pointer to the heavy-weight blob data.

The blob data could be written via openBlobForWriteAsync and read via openBlobForReadAsync.

A GenericDocument with AppSearchBlobHandleProperty could be put and read without the large blob data. This offers lazy retrieval to blob data when searching GenericDocument in AppSearch.

Summary

Public methods

static @NonNull AppSearchBlobHandle
createWithSha256(
    @NonNull byte[] digest,
    @NonNull String packageName,
    @NonNull String databaseName,
    @NonNull String namespace
)

Create a new AppSearch blob identifier with given digest, package, database and namespace.

boolean
@NonNull String

Returns the name of database stored the blob that this object is representing.

@NonNull String

Returns the app-defined namespace this blob resides in.

@NonNull String

Returns the package name indicating the owner app of the blob that this object is representing.

@NonNull byte[]

Returns the SHA-256 hash of the blob that this object is representing.

int
@NonNull String

Public methods

createWithSha256

Added in 1.1.0-alpha07
public static @NonNull AppSearchBlobHandle createWithSha256(
    @NonNull byte[] digest,
    @NonNull String packageName,
    @NonNull String databaseName,
    @NonNull String namespace
)

Create a new AppSearch blob identifier with given digest, package, database and namespace.

The package name and database name indicated where this blob will be stored. To write, commit or read this blob via AppSearchSession, it must match the package name and database name of AppSearchSession.

For two objects of AppSearchBlobHandle to be considered equal, the packageName, database, namespace and digest must be equal.

Parameters
@NonNull byte[] digest

The SHA-256 hash of the blob this is representing.

@NonNull String packageName

The package name of the owner of this Blob.

@NonNull String databaseName

The database name of this blob to stored into.

@NonNull String namespace

The namespace of this blob resides in.

Returns
@NonNull AppSearchBlobHandle

a new instance of AppSearchBlobHandle object.

equals

public boolean equals(Object o)

getDatabaseName

Added in 1.1.0-alpha07
public @NonNull String getDatabaseName()

Returns the name of database stored the blob that this object is representing.

For two objects of AppSearchBlobHandle to be considered equal, the packageName, database, namespace and digest must be equal.

getNamespace

Added in 1.1.0-alpha07
public @NonNull String getNamespace()

Returns the app-defined namespace this blob resides in.

For two objects of AppSearchBlobHandle to be considered equal, the packageName, database, namespace and digest must be equal.

getPackageName

Added in 1.1.0-alpha07
public @NonNull String getPackageName()

Returns the package name indicating the owner app of the blob that this object is representing.

For two objects of AppSearchBlobHandle to be considered equal, the packageName, database, namespace and digest must be equal.

getSha256Digest

Added in 1.1.0-alpha07
public @NonNull byte[] getSha256Digest()

Returns the SHA-256 hash of the blob that this object is representing.

For two objects of AppSearchBlobHandle to be considered equal, the packageName, database, namespace and digest must be equal.

hashCode

public int hashCode()

toString

public @NonNull String toString()