You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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"

Discussion thread: here 

JIRA: KAFKA-13494

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Provide an implementation of the Query interface, introduced in KIP-796: Interactive Query v2 , to support session and window queries.

Public Interfaces

In this KIP we propose two new public classes:

  • SessionQuery: used to query session stores in combination with IQv2
  • WindowQuery: used to query window stores in combination with IQv2

Proposed Changes

The SessionQuery class:

@Evolving
public class SessionQuery<K, V> implements Query<V> {     
    private final Optional<K> lower;
    private final Optional<K> upper;
 
    private SessionQuery(final Optional<K> lower, final Optional<K> upper) {
        this.lower = lower;
        this.upper = upper;
    }
 
    public static <K, V> SessionQuery<K, V> withRange(final K lower, final K upper) {
        return new SessionQuery<>(Optional.of(lower), Optional.of(upper));
    }
 
    public static <K, V> SessionQuery<K, V> withUpperBound(final K upper) {
        return new SessionQuery<>(Optional.empty(), Optional.of(upper));
    }
 
    public static <K, V> SessionQuery<K, V> withLowerBound(final K lower) {
        return new SessionQuery<>(Optional.of(lower), Optional.empty());
    }
 
    public static <K, V> SessionQuery<K, V> withNoBounds() {
        return new SessionQuery<>(Optional.empty(), Optional.empty());
    }
 
    public Optional<K> getLowerBound() {
        return lower;
    }
 
    public Optional<K> getUpperBound() {
        return upper;
    }
}

The WindowQuery class:

@Evolving
public class WindowQuery<K, V> implements Query<V> {     
    private final Optional<K> lower;
    private final Optional<K> upper;
 
    private WindowQuery(final Optional<K> lower, final Optional<K> upper) {
        this.lower = lower;
        this.upper = upper;
    }
 
    public static <K, V> WindowQuery<K, V> withRange(final K lower, final K upper) {
        return new SessionQuery<>(Optional.of(lower), Optional.of(upper));
    }
 
    public static <K, V> WindowQuery<K, V> withUpperBound(final K upper) {
        return new SessionQuery<>(Optional.empty(), Optional.of(upper));
    }
 
    public static <K, V> WindowQuery<K, V> withLowerBound(final K lower) {
        return new SessionQuery<>(Optional.of(lower), Optional.empty());
    }
 
    public static <K, V> WindowQuery<K, V> withNoBounds() {
        return new SessionQuery<>(Optional.empty(), Optional.empty());
    }
 
    public Optional<K> getLowerBound() {
        return lower;
    }
 
    public Optional<K> getUpperBound() {
        return upper;
    }
}

Examples

The following example illustrates the use of the SessionQuery class.

The following example illustrates the use of the SessionQuery class.



Compatibility, Deprecation, and Migration Plan

  • Since this is a completely new set of APIs, no backward compatibility concerns are anticipated. 
  • Since nothing is deprecated in this KIP, users have no need to migrate unless they want to.


  • No labels