Interface IIndex


public interface IIndex
An index that can support the IIndexConstraint, IIndexHasKeyConstraint, and IUniqueConstraint.
  • Method Details

    • newInstance

      @NonNull static IIndex newInstance(@NonNull List<? extends IKeyField> keyFields)
      Construct a new index using the provided key field components to generate keys.
      Parameters:
      keyFields - the key field components to use to generate keys by default
      Returns:
      the new index
    • isAllNulls

      static boolean isAllNulls(@NonNull Iterable<String> key)
      Check if a key contains information other than null Strings.
      Parameters:
      key - the key to check
      Returns:
      true if the series of key values contains only null values, or false otherwise
    • getKeyFields

      @NonNull List<IKeyField> getKeyFields()
      Retrieve the key field components used to generate a key for this index.
      Returns:
      the key field components
    • put

      @Nullable INodeItem put(@NonNull INodeItem item, @NonNull List<String> key)
      Store the provided item using the provided key.
      Parameters:
      item - the item to store
      key - the key to store the item with
      Returns:
      the previous item stored in the index using the key, or null otherwise
    • get

      INodeItem get(List<String> key)
      Retrieve the item from the index that matches the provided key.
      Parameters:
      key - the key to use for lookup
      Returns:
      the item with the matching key or null if no matching item was found
    • toKey

      @NonNull static List<String> toKey(@NonNull INodeItem item, @NonNull List<? extends IKeyField> keyFields, @NonNull DynamicContext dynamicContext)
      Construct a key by evaluating the provided key field components against the provided item.
      Parameters:
      item - the item to generate the key from
      keyFields - the key field components used to generate the key
      dynamicContext - the Metapath evaluation context
      Returns:
      a new key
      Throws:
      IllegalArgumentException - if a key field has a configured pattern that fails to match the key item value or if the pattern is malformed
      MetapathException - if the evaluation of a key field's metapath resulted in an unexpected error