Versions Compared

Key

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

...

This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.

Status

Current state: Under Discussion Accpted

Discussion thread:https://lists.apache.org/thread/ogo7ntmj8srdcko2h86vvd9djjsjfvcj 

Vote thread: https://lists.apache.org/thread/q4kn2g6tmc837ph2zvff40pgpmgzok3d

JIRA:

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-15629

...

TimestampedRangeQuery : Tailored for ranges with timestamps, this query will return a KeyValueIterator<K, ValueAndTimestamp<V>>

According to KIP-968, this KIP introduces the public enum ResultOrder to determine whether keys are sorted in ascending or descending  or unordered order. Order is based on the serialized byte[] of the keys, not the 'logical' key order. employs the withDescendingKeys() and withAscendingKeys() methods to specify that the keys should be ordered in descending or ascending or unordered sequence, and the resultOrder() method to retrieve the value of enum value in  ResultOrder. I've incorporated these variables and methods into the TimestampedRangeQuery  class and modified some method inputs. As a result, we can now use withDescendingKeys() to obtain results in reverse order and use withAscendingKeys to obtain the result in ascending order. 

Code Block
languagejava
titleTimestampedRangeQuery
@Evolving
public final class TimestampedRangeQuery<K, V> implements Query<KeyValueIterator<K, ValueAndTimestamp<V>>> {

    ...

    /**
     * Interactive range query using a lower and upper bound to filter the keys 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> TimestampedRangeQuery<K, V> withRange(final K lower, final K upper) 
 

    	/**
     * Interactive range query using an upper bound to filter the keys returned Determines if the serialized byte[] of the keys in ascending or descending or unordered order.
     * IfOrder bothis <K,V>based areon null,the RangQueryserialized returnsbyte[] aof fullthe range scan.
     * @param upper The key that specifies the upper bound of the range
     * @param <K> The key type
     * @param <V> The value typekeys, not the 'logical' key order.
     * @return return the order of return records base on the serialized byte[] of the keys (can be unordered, or in ascending, or in descending order).
     */
    public static <K, V> TimestampedRangeQuery<K, V> withUpperBound(final K upperResultOrder resultOrder() {
        return new TimestampedRangeQuery<>(Optional.empty(), Optional.of(upper), true)order;
    }

    /**
     * InteractiveSet rangethe query using a lower bound to filter the keys 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> TimestampedRangeQuery<K, V> withLowerBound(final K lower) 

    /**
     * Determines if the to return the serialized byte[] of the keys in ascendingdescending order.
     * Order is based on the serialized byte[] of the keys, not the 'logical' key order.
     * @return true if ascending, false otherwise a new RangeQuery instance with descending flag set.
     */
    public TimestampedRangeQuery<K, booleanV> isKeyAscendingwithDescendingKeys() {
        return new TimestampedRangeQuery<>(this.lower, this.upper, ResultOrder.DESCENDING);
    }

    /**
     * Set the query to return the serialized byte[] of the keys in descendingAscending order.
     * Order is based on the serialized byte[] of the keys, not the 'logical' key order.
     * @return a new RangeQuery instance with descendingascending flag set.
     */
    public TimestampedRangeQuery<K, V> withDescendingKeyswithAscendingKeys() 

{
    /**
    return * Interactive scan query that returns all records in the store.
     * @param <K> The key type
     * @param <V> The value type
     */
    public static <K, V> TimestampedRangeQuery<K, V> withNoBounds() 

new TimestampedRangeQuery<>(this.lower, this.upper, ResultOrder.ASCENDING);
    /**}
     * The lower bound of the query, if specified.
     */
    public Optional<K> lowerBound()

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

According to KIP-968, we introduce a public enum ResultOrder.

ResultOrder enum
It helps with specifying the order of the returned results by the query.

Code Block
languagejava
titleResultOrder
package org.apache.kafka.streams.query;
  
public enum ResultOrder {
    ANY,
    ASCENDING,
    DESCENDING
}


Compatibility, Deprecation, and Migration Plan

...