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

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

Best Java code snippets using com.netflix.hollow.core.util.HollowObjectHashCodeFinder.hashCode (Showing top 10 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 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.utilHollowObjectHashCodeFinderhashCode

Javadoc

For look-up at runtime.

If using simple ordinal-based hashing, then objectToHash must be a HollowRecord, and the return value will be objectToHash.getOrdinal();

Otherwise, the hash code is determined with exactly the same logic as was used during serialization.

Popular methods of HollowObjectHashCodeFinder

  • getTypesWithDefinedHashCodes

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Sublime Text 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