1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 22 */ 23 package org.opengrok.suggest.popular; 24 25 import org.apache.lucene.util.BytesRef; 26 27 import java.util.List; 28 import java.util.Map.Entry; 29 30 /** 31 * Abstraction for the map to store the data for most popular completion. 32 */ 33 public interface PopularityMap extends PopularityCounter, AutoCloseable { 34 35 /** 36 * Increment data for the {@code key} by {@code value}. 37 * @param key term to increment data for 38 * @param value positive value by which to increment the data 39 */ increment(BytesRef key, int value)40 void increment(BytesRef key, int value); 41 42 /** 43 * Returns the popularity data sorted according to their value. 44 * @param page which page of data to retrieve 45 * @param pageSize number of results to return 46 * @return popularity data sorted according to their value 47 */ getPopularityData(int page, int pageSize)48 List<Entry<BytesRef, Integer>> getPopularityData(int page, int pageSize); 49 50 /** {@inheritDoc} */ 51 @Override close()52 void close(); 53 54 } 55