All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sirix.page.interfaces.KeyValuePage Maven / Gradle / Ivy

package org.sirix.page.interfaces;

import java.util.Collection;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import org.sirix.api.PageReadOnlyTrx;
import org.sirix.node.interfaces.Record;
import org.sirix.page.PageKind;
import org.sirix.page.PageReference;

/**
 * Key/Value page.
 *
 * @author Johannes Lichtenberger
 *
 */
public interface KeyValuePage, V extends Record> extends Page {
  /**
   * Entry set of all nodes in the page. Changes to the set are reflected in the internal data
   * structure
   *
   * @return an entry set
   */
  Set> entrySet();

  /**
   * All available records.
   *
   * @return all records
   */
  Collection values();

  /**
   * Get the unique page record identifier.
   *
   * @return page record key/identifier
   */
  long getPageKey();

  /**
   * Get value with the specified key.
   *
   * @param key the key
   * @return value with given key, or {@code null} if not present
   */
  V getValue(K key);

  /**
   * Store or overwrite a single entry. The implementation must make sure if the key must be
   * permitted, the value or none.
   *
   * @param key key to store
   * @param value value to store
   */
  void setEntry(K key, @Nonnull V value);

  Set> referenceEntrySet();

  /**
   * Store or overwrite a single reference associated with a key for overlong entries. That is
   * entries which are larger than a predefined threshold are written to OverflowPages and thus are
   * just referenced and not deserialized during the deserialization of a page.
   *
   * @param key key to store
   * @param reference reference to store
   */
  void setPageReference(K key, @Nonnull PageReference reference);

  PageReference getPageReference(K key);

  /**
   * Create a new instance.
   *
   * @param recordPageKey the record page key
   * @param pageKind the kind of page (in which subtree it is (NODEPAGE, PATHSUMMARYPAGE,
   *        TEXTVALUEPAGE, ATTRIBUTEVALUEPAGE))
   * @param pageReadTrx transaction to read pages
   * @return a new {@link KeyValuePage} instance
   */
  > C newInstance(@Nonnegative long recordPageKey,
      @Nonnull PageKind pageKind, long previousPageRefKey, @Nonnull PageReadOnlyTrx pageReadTrx);

  /**
   * Get the {@link PageReadOnlyTrx}.
   *
   * @return page reading transaction
   */
  PageReadOnlyTrx getPageReadTrx();

  /**
   * Get the page kind.
   *
   * @return page kind
   */
  PageKind getPageKind();

  /**
   * Get the number of entries/slots/page references filled.
   *
   * @return number of entries/slots/page references filled
   */
  int size();

  /**
   * Get the optional {@link PageReference} pointing to the previous version of the page
   *
   * @return optional {@link PageReference} pointing to the previous version of the page
   */
  long getPreviousReferenceKey();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy