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

How to use
HollowObjectHashCodeFinder
in
com.netflix.hollow.core.util

Best Java code snippets using com.netflix.hollow.core.util.HollowObjectHashCodeFinder (Showing top 11 results out of 315)

origin: Netflix/hollow

private HollowSetWriteRecord copyToWriteRecord(Set<?> s, FlatRecordWriter flatRecordWriter) {
  HollowSetWriteRecord rec = (HollowSetWriteRecord)writeRecord();
  for(Object o : s) {
    if(o == null) {
      throw new NullPointerException(String.format(NULL_ELEMENT_MESSAGE, schema));
    }
    int ordinal = flatRecordWriter == null ? elementMapper.write(o) : elementMapper.writeFlat(o, flatRecordWriter);
    int hashCode = hashCodeFinder.hashCode(elementMapper.getTypeName(), ordinal, o);
    rec.addElement(ordinal, hashCode);
  }
  return rec;
}
origin: Netflix/hollow

  private void addTypeNamesWithDefinedHashCodesToHeader() {
    Set<String> typeNames = hashCodeFinder.getTypesWithDefinedHashCodes();
    if(typeNames != null && !typeNames.isEmpty()) {
      StringBuilder typeNamesBuilder = new StringBuilder();
      int counter = 0;

      // Sort to be consistent between cycle
      Set<String> sortedNames = new TreeSet<String>(typeNames);
      for (String typeName : sortedNames) {
        if(counter++ != 0)
          typeNamesBuilder.append(",");
        typeNamesBuilder.append(typeName);
      }

      addHeaderTag(HollowObjectHashCodeFinder.DEFINED_HASH_CODES_HEADER_NAME, typeNamesBuilder.toString());
    }
  }
}
origin: Netflix/hollow

private HollowMapWriteRecord copyToWriteRecord(Map<?, ?> m, FlatRecordWriter flatRecordWriter) {
  HollowMapWriteRecord rec = (HollowMapWriteRecord) writeRecord();
  for (Map.Entry<?, ?> entry : m.entrySet()) {
    Object key = entry.getKey();
    if (key == null) {
      throw new NullPointerException(String.format(NULL_KEY_MESSAGE, schema));
    }
    Object value = entry.getValue();
    if (value == null) {
      throw new NullPointerException(String.format(NULL_VALUE_MESSAGE, schema));
    }
    int keyOrdinal, valueOrdinal;
    if (flatRecordWriter == null) {
      keyOrdinal = keyMapper.write(key);
      valueOrdinal = valueMapper.write(value);
    } else {
      keyOrdinal = keyMapper.writeFlat(key, flatRecordWriter);
      valueOrdinal = valueMapper.writeFlat(value, flatRecordWriter);
    }
    int hashCode = hashCodeFinder.hashCode(keyMapper.getTypeName(), keyOrdinal, key);
    rec.addEntry(keyOrdinal, valueOrdinal, hashCode);
  }
  return rec;
}
origin: Netflix/hollow

<K, V> int serializeMap(HollowSerializationRecord rec, String keyTypeName, String valueTypeName, Map<K, V> obj) {
  HollowMapWriteRecord mapRec = (HollowMapWriteRecord)rec.getHollowWriteRecord();
  mapRec.reset();
  for(Map.Entry<K, V> entry : obj.entrySet()) {
    if(entry.getKey() != null && entry.getValue() != null) {
      int keyOrdinal = getFramework().add(keyTypeName, entry.getKey());
      int valueOrdinal = getFramework().add(valueTypeName, entry.getValue());
      int hashCode = hasher.hashCode(keyTypeName, keyOrdinal, entry.getKey());
      mapRec.addEntry(keyOrdinal, valueOrdinal, hashCode);
    }
  }
  return getFramework().getStateEngine().add(rec.getTypeName(), mapRec);
}
origin: Netflix/hollow

<T> int serializeSet(HollowSerializationRecord rec, String typeName, Set<T> obj) {
  HollowSetWriteRecord setRec = (HollowSetWriteRecord)rec.getHollowWriteRecord();
  setRec.reset();
  for(T t : obj) {
    if(t != null) {
      int ordinal = getFramework().add(typeName, t);
      int hashCode = hasher.hashCode(typeName, ordinal, t);
      setRec.addElement(ordinal, hashCode);
    }
  }
  return getFramework().getStateEngine().add(rec.getTypeName(), setRec);
}
origin: Netflix/hollow

@Override
public boolean contains(HollowSet<T> set, int ordinal, Object o) {
  if(getSchema().getHashKey() != null) {
    for(int i=0;i<ordinals.length;i++) {
      if(ordinals[i] != -1 && set.equalsElement(ordinals[i], o))
        return true;
    }
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(o);

    int bucket = HashCodes.hashInt(hashCode) & hashMask;

    while(ordinals[bucket] != -1) {
      if(set.equalsElement(ordinals[bucket], o))
        return true;
      bucket ++;
      bucket &= hashMask;
    }
  }
  return false;
}

origin: Netflix/hollow

@Override
public boolean containsKey(HollowMap<K, V> map, int ordinal, Object key) {
  if(getSchema().getHashKey() != null) {
    for(int i=0;i<ordinals.length;i+=2) {
      if(ordinals[i] != -1 && map.equalsKey(ordinals[i], key))
        return true;
    }
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key);
    int bucket = (HashCodes.hashInt(hashCode) & hashMask) * 2;

    while(ordinals[bucket] != -1) {
      if(map.equalsKey(ordinals[bucket], key)) {
        return true;
      }

      bucket += 2;
      bucket &= ordinals.length - 1;
    }
  }
  return false;
}
origin: Netflix/hollow

@Override
public boolean containsKey(HollowMap<K, V> map, int ordinal, Object key) {
  HollowMapEntryOrdinalIterator iter;
  
  if(getSchema().getHashKey() != null) {
    iter = dataAccess.ordinalIterator(ordinal);
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key);
    iter = dataAccess.potentialMatchOrdinalIterator(ordinal, hashCode);
  }
  while(iter.next()) {
    if(map.equalsKey(iter.getKey(), key))
      return true;
  }
  return false;
}
origin: Netflix/hollow

@Override
public boolean contains(HollowSet<T> set, int ordinal, Object o) {
  HollowOrdinalIterator iter;
  
  if(getSchema().getHashKey() != null) {
    iter = dataAccess.ordinalIterator(ordinal);
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(o);
    iter = dataAccess.potentialMatchOrdinalIterator(ordinal, hashCode);
  }
  int potentialOrdinal = iter.next();
  while(potentialOrdinal != HollowOrdinalIterator.NO_MORE_ORDINALS) {
    if(set.equalsElement(potentialOrdinal, o))
      return true;
    potentialOrdinal = iter.next();
  }
  return false;
}

origin: Netflix/hollow

@Override
public V get(HollowMap<K, V> map, int ordinal, Object key) {
  if(getSchema().getHashKey() != null) {
    for(int i=0;i<ordinals.length;i+=2) {
      if(ordinals[i] != -1 && map.equalsKey(ordinals[i], key))
        return map.instantiateValue(ordinals[i+1]);
    }
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key);
    int bucket = (HashCodes.hashInt(hashCode) & hashMask) * 2;

    while(ordinals[bucket] != -1) {
      if(map.equalsKey(ordinals[bucket], key)) {
        return map.instantiateValue(ordinals[bucket + 1]);
      }

      bucket += 2;
      bucket &= ordinals.length - 1;
    }
  }
  return null;
}
origin: Netflix/hollow

@Override
public V get(HollowMap<K, V> map, int ordinal, Object key) {
  HollowMapEntryOrdinalIterator iter;
  
  if(getSchema().getHashKey() != null) {
    iter = dataAccess.ordinalIterator(ordinal);
  } else {
    int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key);
    iter = dataAccess.potentialMatchOrdinalIterator(ordinal, hashCode);
  }
  
  while(iter.next()) {
    if(map.equalsKey(iter.getKey(), key))
      return map.instantiateValue(iter.getValue());
  }
  return null;
}
com.netflix.hollow.core.utilHollowObjectHashCodeFinder

Javadoc

Use of this interface is not recommended. Instead, use the hash key functionality available sets and maps.

With this interface, in conjunction with a cooperating data ingestion mechanism, it is possible to use custom hash codes in Hollow sets and maps.

Most used methods

  • hashCode
    For serialization. At serialization time, we know the ordinal of a newly added object, but may not k
  • getTypesWithDefinedHashCodes

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Path (java.nio.file)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • BoxLayout (javax.swing)
  • Github Copilot alternatives
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