Tabnine Logo
UniqueKeyIndex
Code IndexAdd Tabnine to your IDE (free)

How to use
UniqueKeyIndex
in
com.netflix.hollow.api.consumer.index

Best Java code snippets using com.netflix.hollow.api.consumer.index.UniqueKeyIndex (Showing top 13 results out of 315)

origin: Netflix/hollow

/**
 * Creates a {@link UniqueKeyIndex} for matching with field paths and types declared by
 * {@link FieldPath} annotated fields or methods on the given key type.
 *
 * @param keyType the key type
 * @param <Q> the key type
 * @return a {@code UniqueKeyIndex}
 * @throws IllegalArgumentException if the key type declares one or more invalid field paths
 * or invalid types given resolution of corresponding field paths
 * @throws IllegalArgumentException if the builder is bound to the primary key of the unique type and
 * the field paths declared by the key type are not the identical to those declared by the primary key
 */
public <Q> UniqueKeyIndex<T, Q> usingBean(Class<Q> keyType) {
  Objects.requireNonNull(keyType);
  return new UniqueKeyIndex<>(consumer, uniqueType, primaryTypeKey,
      keyType);
}
origin: Netflix/hollow

UniqueKeyIndex(
    HollowConsumer consumer,
    Class<T> uniqueType,
    PrimaryKey primaryTypeKey,
    List<MatchFieldPathArgumentExtractor<Q>> matchFields) {
  this.consumer = consumer;
  this.api = consumer.getAPI();
  this.uniqueTypeName = uniqueType.getSimpleName();
  this.uniqueTypeExtractor = SelectFieldPathResultExtractor
      .from(consumer.getAPI().getClass(), consumer.getStateEngine(), uniqueType, "", uniqueType);
  if (primaryTypeKey != null) {
    matchFields = validatePrimaryKeyFieldPaths(consumer, uniqueTypeName, primaryTypeKey, matchFields);
  }
  this.matchFields = matchFields;
  this.matchFieldPaths = matchFields.stream()
      .map(mf -> mf.fieldPath.toString())
      .toArray(String[]::new);
  this.hpki = new HollowPrimaryKeyIndex(consumer.getStateEngine(), uniqueTypeName, matchFieldPaths);
}
origin: Netflix/hollow

public <T> void test(Class<T> keyType, T key) {
  UniqueKeyIndex<DataModel.Consumer.TypeWithPrimaryKey, T> pki = UniqueKeyIndex
      .from(consumer, DataModel.Consumer.TypeWithPrimaryKey.class)
      .bindToPrimaryKey()
      .usingBean(keyType);
  DataModel.Consumer.TypeWithPrimaryKey match = pki.findMatch(key);
  Assert.assertNotNull(match);
  Assert.assertEquals(0, match.getOrdinal());
}
origin: Netflix/hollow

  @Test(expected = IllegalArgumentException.class)
  public void test() {
    UniqueKeyIndex
        .from(consumer, DataModel.Consumer.Values.class)
        .usingPath(path, Object.class);
  }
}
origin: Netflix/hollow

  @Test
  public void test() {
    UniqueKeyIndex<T, Q> pki = UniqueKeyIndex
        .from(consumer, uniqueType)
        .usingPath(path, type);
    T r = pki.findMatch(value);
    Assert.assertNotNull(r);
    Assert.assertEquals(0, r.getOrdinal());
  }
}
origin: Netflix/hollow

@Test(expected = IllegalArgumentException.class)
public void testUnknownRootSelectType() {
  UniqueKeyIndex
      .from(consumer, ErrorsTest.Unknown.class)
      .usingPath("values", DataModel.Consumer.Values.class);
}
origin: Netflix/hollow

  @Test
  public void test() {
    UniqueKeyIndex<DataModel.Consumer.References, Q> uki = UniqueKeyIndex
        .from(consumer, DataModel.Consumer.References.class)
        .usingPath(path, type);
    DataModel.Consumer.References r = uki.findMatch(value);
    Assert.assertNotNull(r);
    Assert.assertEquals(0, r.getOrdinal());
  }
}
origin: Netflix/hollow

@Test(expected = IllegalArgumentException.class)
public void testEmptyMatchPath() {
  UniqueKeyIndex
      .from(consumer, DataModel.Consumer.References.class)
      .usingPath("", DataModel.Consumer.References.class);
}
origin: Netflix/hollow

  /**
   * Creates a {@link UniqueKeyIndex} for matching with a single key field path and type.
   *
   * @param keyFieldPath the key field path
   * @param keyFieldType the key type
   * @param <Q> the key type
   * @return a {@code UniqueKeyIndex}
   * @throws IllegalArgumentException if the key field path is empty or invalid
   * @throws IllegalArgumentException if the key field type is invalid given resolution of the
   * key field path
   * @throws IllegalArgumentException if the builder is bound to the primary key of the unique type and
   * the field path declared by the key type is not identical to the keyFieldPath
   */
  public <Q> UniqueKeyIndex<T, Q> usingPath(String keyFieldPath, Class<Q> keyFieldType) {
    Objects.requireNonNull(keyFieldPath);
    if (keyFieldPath.isEmpty()) {
      throw new IllegalArgumentException("keyFieldPath argument is an empty String");
    }
    Objects.requireNonNull(keyFieldType);
    return new UniqueKeyIndex<>(consumer, uniqueType, primaryTypeKey,
        keyFieldPath, keyFieldType);
  }
}
origin: Netflix/hollow

@Test
public void testFields() {
  UniqueKeyIndex<DataModel.Consumer.Values, ValueFieldsQuery> hi = UniqueKeyIndex
      .from(consumer, DataModel.Consumer.Values.class)
      .usingBean(MatchOnValuesBeanTest.ValueFieldsQuery.class);
  DataModel.Consumer.Values r = hi.findMatch(MatchOnValuesBeanTest.ValueFieldsQuery.create());
  Assert.assertNotNull(r);
  Assert.assertEquals(0, r.getOrdinal());
}
origin: Netflix/hollow

  @Test(expected = IllegalArgumentException.class)
  public void testNoPrimaryKey() {
    UniqueKeyIndex
        .from(consumer, DataModel.Consumer.References.class)
        .bindToPrimaryKey()
        .usingPath("values._int", int.class);
  }
}
origin: Netflix/hollow

  @Test
  public void testMethods() {
    UniqueKeyIndex<DataModel.Consumer.Values, ValueMethodsQuery> hi = UniqueKeyIndex
        .from(consumer, DataModel.Consumer.Values.class)
        .usingBean(MatchOnValuesBeanTest.ValueMethodsQuery.class);
    DataModel.Consumer.Values r = hi.findMatch(MatchOnValuesBeanTest.ValueMethodsQuery.create());
    Assert.assertNotNull(r);
    Assert.assertEquals(0, r.getOrdinal());
  }
}
origin: Netflix/hollow

consumer.triggerRefreshTo(v1);
UniqueKeyIndex<DataModel.Consumer.TypeWithPrimaryKey, Key> uki = UniqueKeyIndex.from(consumer,
    DataModel.Consumer.TypeWithPrimaryKey.class)
    .bindToPrimaryKey()
consumer.addRefreshListener(uki);
Assert.assertNotNull(uki.findMatch(new Key(1, "1", 2)));
Assert.assertNotNull(uki.findMatch(new Key(1, "1", 2)));
Assert.assertNotNull(uki.findMatch(new Key(2, "1", 2)));
Assert.assertNotNull(uki.findMatch(new Key(1, "1", 2)));
Assert.assertNotNull(uki.findMatch(new Key(2, "1", 2)));
Assert.assertNull(uki.findMatch(new Key(3, "1", 2)));
com.netflix.hollow.api.consumer.indexUniqueKeyIndex

Javadoc

A type safe index for indexing with a unique key (such as a primary key).

If the index is HollowConsumer#addRefreshListener(HollowConsumer.RefreshListener) with its associated HollowConsumer then the index will track updates and changes will be reflected in matched results (performed after such updates). When a registered index is no longer needed it should be HollowConsumer#removeRefreshListener(HollowConsumer.RefreshListener) to avoid unnecessary index recalculation and to ensure the index is reclaimed by the garbage collector.

Most used methods

  • <init>
  • findMatch
    Finds the unique object, an instance of the unique type, for a given key.
  • from
    Starts the building of a UniqueKeyIndex.
  • validatePrimaryKeyFieldPaths

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • startActivity (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JList (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now