Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
firstline1
titleVersionedKeyQuery.java
linenumberstrue
collapsetrue
package org.apache.kafka.streams.query;

@Evolving
public final class VersionedKeyQuery<K, V> implements Query<ValueIterator<VersionedRecord<V>>> {

  private final K key;
  private final Optional<Long> asOfTimestamp;
  private final Optional<Long> untilTimestamp;

  private VersionedKeyQuery(final K key, Optional<Long> asOfTimestamp, Optional<Long> untilTimestamp);

  /**
   * Interactive key query that returns one record with the specified key
   * * and with the latest timestamp
   * @param key The key to retrieve
   * @param <K> The key type
   * @param <V> The value type
   */
  public static <K, V> VersionedKeyQuery<K, V> withKeyLatestValue(final K key);

/**
   * Interactive key query that returns one record with the specified key
   * * and with the greatest timestamp <= untilTimeStamp
   * @param key The key to retrieve
   * @param untilTimeStamp The upperbound for timestamp
   * @param <K> The key type
   * @param <V> The value type
   */
  public static <K, V> VersionedKeyQuery<K, V> withKeyWithTimestampBound(final K key, long untilTimeStamp);

  /**
   * Interactive key query that returns the records with the specified key
   * * within the specified time range.
   * @param asOfTimestamp The lowerbound for timestamp
   * @param untilTimeStamp The upperbound for timestamp
   * @param key The key to retrieve
   * @param <K> The key type
   * @param <V> The value type
   */
  public static <K, V> VersionedKeyQuery<K, V> withKeyWithTimestampRange(final K key, long asOfTimestamp, long untilTimestamp);

  /**
   * Interactive key query that returns all the records in the store with the specified key.
   * @param key The key to retrieve
   * @param <K> The key type
   * @param <V> The value type
   */
  public static <K, V> VersionedKeyQuery<K, V> withKeyAllVersions(final K key);

  /**
   * The key that was specified for this query.
   */
  public K getKey();


  /**
   * The lower bound for timestamp of the query, if specified
   */
  public Optional<Long> getAsOfTimestamp();

  /**
   * The upper bound for timestamp of the query, if specified
   */
  public Optional<Long> getUntilTimestamp();
}

...

Code Block
languagejava
firstline1
titleVersionedRangeQuery.java
linenumberstrue
collapsetrue
package org.apache.kafka.streams.query;
@Evolving
public final class VersionedRangeQuery<K, V> implements Query<KeyValueIterator<K, VersionedRecord<V>>> {
    private final Optional<K> lower;
    private final Optional<K> upper;
    private final Optional<Long> asOfTimestamp;
    private final Optional<Long> untilTimestamp;

    private VersionedRangeQuery(
        final Optional<K> lower,
        final Optional<K> upper,
        final Optional<Long> asOfTimestamp,
        final Optional<Long> untilTimestamp);

    /**
     * Interactive range query using a lower and upper bound to filter the keys returned.
     * * For each key only the record with the latest timestamp is returned.
     * @param lower The key that specifies the lower bound of the range
     * @param upper The key that specifies the upper bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> keyRangeLatestValue(final K lower, final K upper);

    /**
     * Interactive range query using a lower bound to filter the keys returned.
     * * For each key only the record with the latest timestamp is returned.
     * @param lower The key that specifies the lower bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withLowerBoundLatestValue(final K lower);

    /**
     * Interactive range query using a lower bound to filter the keys returned.
     * * For each key only the record with the latest timestamp is returned.
     * @param upper The key that specifies the upper bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withUpperBoundLatestValue(final K upper);

    /**
     * Interactive scan query that returns all records in the store.
     * * For each key only the record with the latest timestamp is returned.
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withNoBoundLatestValue();

    /**
     * Interactive range query using a lower and upper bound to filter the keys returned.
     * * For each key all the records with the greatest timestamp <= untilTimeStamp are returned.
     * @param lower The key that specifies the lower bound of the range
     * @param upper The key that specifies the upper bound of the range
     * @param untilTimeStamp The upperbound for timestamp
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> KeyRangeWithTimestampBound(final K lower, final K upper, final long untilTimeStamp);

    /**
     * Interactive range query using a lower bound to filter the keys returned.
     * * For each key all the records with the greatest timestamp <= untilTimeStamp are returned.
     * @param lower The key that specifies the lower bound of the range
     * @param untilTimeStamp The upperbound for timestamp
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withLowerBoundWithTimestampBound(final K lower, final long untilTimeStamp);

    /**
     * Interactive range query using an upper and upper bound to filter the keys returned.
     * * For each key all the records with the greatest timestamp <= untilTimeStamp are returned.
     * @param upper The key that specifies the upper bound of the range
     * @param untilTimeStamp The upperbound for timestamp
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withUpperBoundWithTimestampBound(final K upper, final long untilTimeStamp);

    /**
     * Interactive scan query that returns all records in the store.
     * * For each key all the records with the greatest timestamp <= untilTimeStamp are returned.
     * @param untilTimeStamp The upperbound for timestamp
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withNoBoundWithTimestampBound(final long untilTimeStamp);

    /**
     * Interactive range query using a lower and upper bound to filter the keys returned.
     * * For each key all the records within the specified time range are returned.
     * @param lower The key that specifies the lower bound of the range
     * @param upper The key that specifies the upper bound of the range
     * @param asOfTimestamp The lowerbound for timestamp
     * @param untilTimeStamp The upperbound for timestamp
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> keyRangeWithTimestampRange(final K lower, final K upper, final long asOfTimestamp, final long untilTimestamp);

    /**
     * Interactive range query using a lower bound to filter the keys returned.
     * * For each key all the records within the specified time range are returned.
     * @param lower The key that specifies the lower bound of the range
      * @param <K>asOfTimestamp The lowerbound for timestamp
     * @param untilTimeStamp The upperbound for timestamp       
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withLowerBoundWithTimestampRange(final K lower, final long asOfTimestamp, final long untilTimestamp);

    /**
     * Interactive range query using an upper bound to filter the keys returned.
     * * For each key all the records within the specified time range are returned.
     * @param asOfTimestamp The lowerbound for timestamp
     * @param untilTimeStamp The upperbound for timestamp 
     * @param upper The key that specifies the upper bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withUpperBoundWithTimestampRange(final K upper, final long asOfTimestamp, final long untilTimestamp);

    /**
     * Interactive scan query that returns all records in the store.
     * * For each key all the records within the specified time range are returned.
     * @param asOfTimestamp The lowerbound for timestamp
     * @param untilTimeStamp The upperbound for timestamp 
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withNoBoundWithTimestampRange(final long asOfTimestamp, final long untilTimestamp);

    /**
     * Interactive range query using a lower and upper bound to filter the keys returned.
     * For each key all values from the oldest till the newest record existing in the state store
     * * are returned
     * @param lower The key that specifies the lower bound of the range
     * @param upper The key that specifies the upper bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> keyRangeAllVersions(final K lower, final K upper);

    /**
     * Interactive range query using a lower bound to filter the keys returned.
     * For each key all values from the oldest till the newest record existing in the state store
     * * are returned
     * @param lower The key that specifies the lower bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withLowerBoundAllVersions(final K lower);

    /**
     * Interactive range query using an upper bound to filter the keys returned.
     * For each key all values from the oldest till the newest record existing in the state store
     * * are returned
     * @param upper The key that specifies the lower bound of the range
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withUpperBoundAllVersions(final K upper);

    /**
     * Interactive scan query that returns all records in the store.
     * For each key all values from the oldest till the newest record existing in the state store
     * * are returned
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> VersionedRangeQuery<K, V> withNoBoundAllVersions();

    /**
     * The lower bound of the query, if specified.
     */
    public Optional<K> getLowerBound();

    /**
     * The upper bound of the query, if specified
     */
    public Optional<K> getUpperBound();

    /**
     * The upper bound for timestamp of the query, if specified
     */
    public Optional<Long> getAsOfTimestamp();
    /**
     * The upper bound for timestamp of the query, if specified
     */
    public Optional<Long> getUntilTimestamp();
}

...