public final class

OptimizeStats

extends java.lang.Object

 java.lang.Object

↳androidx.appsearch.localstorage.stats.OptimizeStats

Gradle dependencies

compile group: 'androidx.appsearch', name: 'appsearch-local-storage', version: '1.1.0-alpha05'

  • groupId: androidx.appsearch
  • artifactId: appsearch-local-storage
  • version: 1.1.0-alpha05

Artifact androidx.appsearch:appsearch-local-storage:1.1.0-alpha05 it located at Google repository (https://maven.google.com/)

Overview

Class holds detailed stats for Optimize.

Summary

Methods
public intgetDeletedDocumentCount()

Returns number of documents deleted during the optimization.

public intgetDocumentStoreOptimizeLatencyMillis()

Returns time used to optimize the document store in millis.

public intgetExpiredDocumentCount()

Returns number of documents expired during the optimization.

public intgetIndexRestorationLatencyMillis()

Returns time used to restore the index in millis.

public intgetNativeLatencyMillis()

Returns how much time in millis spent in the native code.

public intgetOriginalDocumentCount()

Returns number of documents before the optimization.

public intgetStatusCode()

Returns status code for this optimization.

public longgetStorageSizeAfterBytes()

Returns size of storage in bytes after the optimization.

public longgetStorageSizeBeforeBytes()

Returns size of storage in bytes before the optimization.

public longgetTimeSinceLastOptimizeMillis()

Returns the amount of time in millis since the last optimization ran calculated using wall clock time.

public intgetTotalLatencyMillis()

Returns total latency of this optimization in millis.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public int getStatusCode()

Returns status code for this optimization.

public int getTotalLatencyMillis()

Returns total latency of this optimization in millis.

public int getNativeLatencyMillis()

Returns how much time in millis spent in the native code.

public int getDocumentStoreOptimizeLatencyMillis()

Returns time used to optimize the document store in millis.

public int getIndexRestorationLatencyMillis()

Returns time used to restore the index in millis.

public int getOriginalDocumentCount()

Returns number of documents before the optimization.

public int getDeletedDocumentCount()

Returns number of documents deleted during the optimization.

public int getExpiredDocumentCount()

Returns number of documents expired during the optimization.

public long getStorageSizeBeforeBytes()

Returns size of storage in bytes before the optimization.

public long getStorageSizeAfterBytes()

Returns size of storage in bytes after the optimization.

public long getTimeSinceLastOptimizeMillis()

Returns the amount of time in millis since the last optimization ran calculated using wall clock time.

Source

/*
 * Copyright 2021 The Android Open Source Project
 *
 * 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.
 */

package androidx.appsearch.localstorage.stats;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.appsearch.annotation.CanIgnoreReturnValue;
import androidx.appsearch.app.AppSearchResult;
import androidx.core.util.Preconditions;

/**
 * Class holds detailed stats for Optimize.
 *
 * @exportToFramework:hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class OptimizeStats {
    /**
     * The status code returned by {@link AppSearchResult#getResultCode()} for the call or
     * internal state.
     */
    @AppSearchResult.ResultCode
    private final int mStatusCode;
    private final int mTotalLatencyMillis;
    private final int mNativeLatencyMillis;

    // Time used to optimize the document store in millis.
    private final int mNativeDocumentStoreOptimizeLatencyMillis;

    // Time used to restore the index in millis.
    private final int mNativeIndexRestorationLatencyMillis;

    // Number of documents before the optimization.
    private final int mNativeOriginalDocumentCount;

    // Number of documents deleted during the optimization.
    private final int mNativeDeletedDocumentCount;

    // Number of documents expired during the optimization.
    private final int mNativeExpiredDocumentCount;

    // Size of storage in bytes before the optimization.
    private final long mNativeStorageSizeBeforeBytes;

    // Size of storage in bytes after the optimization.
    private final long mNativeStorageSizeAfterBytes;

    // The amount of time in millis since the last optimization ran calculated using wall clock time
    private final long mNativeTimeSinceLastOptimizeMillis;

    OptimizeStats(@NonNull Builder builder) {
        Preconditions.checkNotNull(builder);
        mStatusCode = builder.mStatusCode;
        mTotalLatencyMillis = builder.mTotalLatencyMillis;
        mNativeLatencyMillis = builder.mNativeLatencyMillis;
        mNativeDocumentStoreOptimizeLatencyMillis =
                builder.mNativeDocumentStoreOptimizeLatencyMillis;
        mNativeIndexRestorationLatencyMillis = builder.mNativeIndexRestorationLatencyMillis;
        mNativeOriginalDocumentCount = builder.mNativeOriginalDocumentCount;
        mNativeDeletedDocumentCount = builder.mNativeDeletedDocumentCount;
        mNativeExpiredDocumentCount = builder.mNativeExpiredDocumentCount;
        mNativeStorageSizeBeforeBytes = builder.mNativeStorageSizeBeforeBytes;
        mNativeStorageSizeAfterBytes = builder.mNativeStorageSizeAfterBytes;
        mNativeTimeSinceLastOptimizeMillis = builder.mNativeTimeSinceLastOptimizeMillis;
    }

    /** Returns status code for this optimization. */
    @AppSearchResult.ResultCode
    public int getStatusCode() {
        return mStatusCode;
    }

    /** Returns total latency of this optimization in millis. */
    public int getTotalLatencyMillis() {
        return mTotalLatencyMillis;
    }

    /** Returns how much time in millis spent in the native code. */
    public int getNativeLatencyMillis() {
        return mNativeLatencyMillis;
    }

    /** Returns time used to optimize the document store in millis. */
    public int getDocumentStoreOptimizeLatencyMillis() {
        return mNativeDocumentStoreOptimizeLatencyMillis;
    }

    /** Returns time used to restore the index in millis. */
    public int getIndexRestorationLatencyMillis() {
        return mNativeIndexRestorationLatencyMillis;
    }

    /** Returns number of documents before the optimization. */
    public int getOriginalDocumentCount() {
        return mNativeOriginalDocumentCount;
    }

    /** Returns number of documents deleted during the optimization. */
    public int getDeletedDocumentCount() {
        return mNativeDeletedDocumentCount;
    }

    /** Returns number of documents expired during the optimization. */
    public int getExpiredDocumentCount() {
        return mNativeExpiredDocumentCount;
    }

    /** Returns size of storage in bytes before the optimization. */
    public long getStorageSizeBeforeBytes() {
        return mNativeStorageSizeBeforeBytes;
    }

    /** Returns size of storage in bytes after the optimization. */
    public long getStorageSizeAfterBytes() {
        return mNativeStorageSizeAfterBytes;
    }

    /**
     * Returns the amount of time in millis since the last optimization ran calculated using wall
     * clock time.
     */
    public long getTimeSinceLastOptimizeMillis() {
        return mNativeTimeSinceLastOptimizeMillis;
    }

    /** Builder for {@link RemoveStats}. */
    public static class Builder {
        /**
         * The status code returned by {@link AppSearchResult#getResultCode()} for the call or
         * internal state.
         */
        @AppSearchResult.ResultCode
        int mStatusCode;
        int mTotalLatencyMillis;
        int mNativeLatencyMillis;
        int mNativeDocumentStoreOptimizeLatencyMillis;
        int mNativeIndexRestorationLatencyMillis;
        int mNativeOriginalDocumentCount;
        int mNativeDeletedDocumentCount;
        int mNativeExpiredDocumentCount;
        long mNativeStorageSizeBeforeBytes;
        long mNativeStorageSizeAfterBytes;
        long mNativeTimeSinceLastOptimizeMillis;

        /** Sets the status code. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setStatusCode(@AppSearchResult.ResultCode int statusCode) {
            mStatusCode = statusCode;
            return this;
        }

        /** Sets total latency in millis. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setTotalLatencyMillis(int totalLatencyMillis) {
            mTotalLatencyMillis = totalLatencyMillis;
            return this;
        }

        /** Sets native latency in millis. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setNativeLatencyMillis(int nativeLatencyMillis) {
            mNativeLatencyMillis = nativeLatencyMillis;
            return this;
        }

        /** Sets time used to optimize the document store. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setDocumentStoreOptimizeLatencyMillis(
                int documentStoreOptimizeLatencyMillis) {
            mNativeDocumentStoreOptimizeLatencyMillis = documentStoreOptimizeLatencyMillis;
            return this;
        }

        /** Sets time used to restore the index. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setIndexRestorationLatencyMillis(int indexRestorationLatencyMillis) {
            mNativeIndexRestorationLatencyMillis = indexRestorationLatencyMillis;
            return this;
        }

        /** Sets number of documents before the optimization. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setOriginalDocumentCount(int originalDocumentCount) {
            mNativeOriginalDocumentCount = originalDocumentCount;
            return this;
        }

        /** Sets number of documents deleted during the optimization. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setDeletedDocumentCount(int deletedDocumentCount) {
            mNativeDeletedDocumentCount = deletedDocumentCount;
            return this;
        }

        /** Sets number of documents expired during the optimization. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setExpiredDocumentCount(int expiredDocumentCount) {
            mNativeExpiredDocumentCount = expiredDocumentCount;
            return this;
        }

        /** Sets Storage size in bytes before optimization. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setStorageSizeBeforeBytes(long storageSizeBeforeBytes) {
            mNativeStorageSizeBeforeBytes = storageSizeBeforeBytes;
            return this;
        }

        /** Sets storage size in bytes after optimization. */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setStorageSizeAfterBytes(long storageSizeAfterBytes) {
            mNativeStorageSizeAfterBytes = storageSizeAfterBytes;
            return this;
        }

        /**
         * Sets the amount the time since the last optimize ran calculated using wall clock time.
         */
        @CanIgnoreReturnValue
        @NonNull
        public Builder setTimeSinceLastOptimizeMillis(long timeSinceLastOptimizeMillis) {
            mNativeTimeSinceLastOptimizeMillis = timeSinceLastOptimizeMillis;
            return this;
        }

        /** Creates a {@link OptimizeStats}. */
        @NonNull
        public OptimizeStats build() {
            return new OptimizeStats(/* builder= */ this);
        }
    }
}