Module pravega_client::index

source ·
Expand description

The Index API provides a way to build a monotonic index with a stream.

The index API writes a fixed sized [IndexRecord] to the stream. Each [IndexRecord] contains the user data and a number of user defined fields. A set of fields is called ‘Fields’. An example of Fields is showed as below:

use pravega_client_macros::Fields;

// Use Fields procedural marco to auto implement the necessary trait for MyFields.
#[derive(Fields, Debug, PartialOrd, PartialEq)]
struct MyFields {
    time: u64, // A field
    id: u64,
}

To ensure the searching efficiency in an index stream, we impose some constraints to the Fields. Suppose we have Fields A and B

#[derive(Fields, Debug, PartialOrd, PartialEq)]
struct A {
    x: u64,
    y: u64,
}
#[derive(Fields, Debug, PartialOrd, PartialEq)]
struct B {
    x: u64,
    y: u64,
    z: u64,
}
  • The type of field has to be u64 and the value of the field must be monotonically increasing. It means that if A2 is written after A1, then it must satisfy x2 >= x1 and y2 >= y1.

  • Upgrade is possible, meaning B can be written after A. But it has to meet two conditions: 1. B has to contain all the fields that A has and the order cannot change. 2. new fields can only be appended at the tail like field z.

  • The Index Writer is generic over the Fields struct, user needs to create new an Index writer when doing upgrading.

Modules§

Structs§

  • Index Reader reads the Index Record from Stream.
  • Index Writer writes a fixed size Record to the stream.

Constants§

Traits§