// Copyright 2010-2021, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto2";

package mozc.user_history_predictor;

message UserHistory {
  message NextEntry {
    // Just store the Fingerprint32(key + "\t" + value)
    // |entry| is used as the key of LRU cache
    optional uint32 entry_fp = 1 [default = 0];
  }

  message Entry {
    optional string key = 1 [default = ""];
    optional string value = 2 [default = ""];
    optional string description = 6 [default = ""];

    // how many times the candidate is selected.
    optional uint32 suggestion_freq = 3 [default = 0];

    // This field is kept for backward compatibility.
    // We do not distinguish suggestion and conversion mode.
    // When loading old proto, max(conversion_freq_deprecated, suggestion_freq)
    // is set to suggestion_freq.
    optional uint32 conversion_freq_deprecated = 5 [default = 0];

    // how many times the candidate is shown on commit event
    optional uint32 shown_freq = 22 [default = 0];

    optional uint64 last_access_time = 4 [default = 0];

    // list entries which were input just after this entry.
    // This field is no longer used. uses `next_entry_fps`.
    repeated NextEntry next_entries_deprecated = 7 [deprecated = true];

    // list of entry-fps that were input just after this entry.
    // uses fixed64 and packed as Fp cannot be compressed.
    // It won't result in an error, but duplicates aren't allowed.
    // The fps are stored to operate as an LRU (Least Recently Used) cache.
    // The front element is the oldest, and the back element is the newest.
    repeated fixed64 next_entry_fps = 23 [packed = true];

    // This entry is removed.
    optional bool removed = 8 [default = false];

    // Inner segment boundary. See converter/inner_segment.h
    repeated fixed32 inner_segment_boundary = 24;

    // Allow the entry to be a content key/value of other segment.
    optional bool allow_partial_match = 25 [default = false];

    // This field is used to hold various information for ranking and filtering.
    // It is intended for internal use only and should be cleared during
    // serialization.
    optional uint32 attributes = 26 [default = 0];

    reserved 9;  // Deprecated entry_type
    reserved 20; // Deprecated bigram_boost
    reserved 21; // Deprecated spelling_correction
  }

  repeated Entry entries = 6;
}
