Tabnine Logo
com.netflix.hollow.zenoadapter.util
Code IndexAdd Tabnine to your IDE (free)

How to use com.netflix.hollow.zenoadapter.util

Best Java code snippets using com.netflix.hollow.zenoadapter.util (Showing top 14 results out of 315)

origin: Netflix/hollow

public void clear(){
  for (Segment segment : segments) {
    segment.clear();
  }
}
origin: Netflix/hollow

  public int size() {
    int size = 0;
    for (Segment segment : segments) {
      size += segment.size();
    }
    return size;
  }
}
origin: Netflix/hollow

public Segment(){
  resize(MINIMUM_CAPACITY);
}
origin: Netflix/hollow

@Test
public void test() {
  for(int i=0;i<obj.length;i++) {
    obj[i] = new Object();
  }
  ObjectIdentityOrdinalMap ordinalMap = new ObjectIdentityOrdinalMap();
  for(int i=0;i<obj.length;i++) {
    ordinalMap.put(obj[i], i);
  }
  for(int i=0;i<obj.length;i++) {
    Assert.assertEquals(ordinalMap.getEntry(obj[i]).getOrdinal(), i);
  }
}
origin: Netflix/hollow

public synchronized void put(Object object, int hashCode, int ordinal) {
  int index = index(hashCode, entries.length);
  Entry current = entries[index];
  Entry prev = null;
  while (current != null) {
    if (current.hash() == hashCode) {
      Object currentObject = current.getKey();
      if( currentObject == null){
        deleteEntry(index, current, prev);
        current = current.next;
        continue;
      } else if (currentObject == object) {
        return;
      }
    }
    prev = current;
    current = current.next;
  }
  count++;
  Entry first = entries[index];
  Entry entry = new Entry(object, hashCode, ordinal, first);
  entries[index] = entry;
  entry.next = first;
  checkSize();
  return;
}
origin: Netflix/hollow

public int add(String type, Object o) {
  ObjectIdentityOrdinalMap identityOrdinalMap = getIdentityOrdinalMap(type);
  Entry entry = identityOrdinalMap.getEntry(o);
  if(entry != null) {
    return entry.getOrdinal();
  }
  NFTypeSerializer<Object> serializer = getSerializer(type);
  int ordinal = add(type, o, serializer);
  identityOrdinalMap.put(o, ordinal);
  return ordinal;
}
origin: Netflix/hollow

public synchronized Entry get(Object object, int hashCode) {
  int index = index(hashCode, entries.length);
  Entry current = entries[index];
  Entry prev = null;
  while (current != null) {
    if (current.hash() == hashCode) {
      Object currentObject = current.getKey();
      if( currentObject == null){
        deleteEntry(index, current, prev);
        current = current.next;
        continue;
      } else if (currentObject == object) {
        return current;
      }
    }
    prev = current;
    current = current.next;
  }
  return null;
}
origin: Netflix/hollow

private void resize(int newCapacity) {
  Entry[] newEntries = new Entry[newCapacity];
  if( entries != null){
    for(Entry entry : entries){
      Entry current = entry;
      while(current != null){
        Entry newEntry = current;
        current = current.next;
        int index = index(newEntry.hash(), newEntries.length);
        newEntry.next = newEntries[index];
        newEntries[index] = newEntry;
      }
    }
  }
  minThreshold = (newEntries.length == MINIMUM_CAPACITY) ? 0 : (newEntries.length * LOAD_FACTOR_PERCENT / 200);
  maxThreshold = (newEntries.length == MAXIMUM_CAPACITY) ? Integer.MAX_VALUE : newEntries.length * LOAD_FACTOR_PERCENT / 100;
  entries = newEntries;
}
origin: Netflix/hollow

/**
 * Associating the obj with an ordinal
 *
 * @param obj
 * @param ordinal
 */
public void put(Object obj, int ordinal) {
  int hashCode = System.identityHashCode(obj);
  int segment = segment(hashCode);
  segments[segment].put(obj, hashCode, ordinal);
}
origin: Netflix/hollow

public Entry getEntry(Object obj) {
  int hashCode = System.identityHashCode(obj);
  int segment = segment(hashCode);
  return segments[segment].get(obj, hashCode);
}
origin: Netflix/hollow

private ObjectIdentityOrdinalMap getIdentityOrdinalMap(String type) {
  ObjectIdentityOrdinalMap objectIdentityOrdinalMap = objectIdentityOrdinalMaps.get(type);
  if(objectIdentityOrdinalMap == null) {
    objectIdentityOrdinalMap = new ObjectIdentityOrdinalMap();
    ObjectIdentityOrdinalMap existing = objectIdentityOrdinalMaps.putIfAbsent(type, objectIdentityOrdinalMap);
    if(existing != null)
      objectIdentityOrdinalMap = existing;
  }
  return objectIdentityOrdinalMap;
}
origin: Netflix/hollow

public ObjectIdentityOrdinalMap(int logOfSegmentNumber) {
  if (logOfSegmentNumber < 1 && logOfSegmentNumber > 32) {
    throw new RuntimeException("Invalid power level");
  }
  segments = new Segment[2 << logOfSegmentNumber];
  for(int i=0; i<segments.length; i++){
    segments[i] = new Segment();
  }
  this.mask = (2 << logOfSegmentNumber) - 1;
  this.logOfSegmentNumber = logOfSegmentNumber;
}
origin: Netflix/hollow

public synchronized void clear() {
  Arrays.fill(entries, null);
  count = 0;
  resize(MINIMUM_CAPACITY);
}
origin: Netflix/hollow

private void checkSize() {
  if( count >= minThreshold && count <= maxThreshold ){
    return;
  }
  int newCapacity;
  if( count < minThreshold ) {
    newCapacity = Math.max(MINIMUM_CAPACITY, entries.length >> 1);
  } else {
    newCapacity = Math.min(MAXIMUM_CAPACITY, entries.length << 1);
  }
  // nothing should be done, since capacity is not changed
  if (newCapacity == entries.length) {
    return;
  }
  resize(newCapacity);
}
com.netflix.hollow.zenoadapter.util

Most used classes

  • ObjectIdentityOrdinalMap$Entry
  • ObjectIdentityOrdinalMap
    Hash lookup map associate object references to already seen ordinals. The fundamental assumption mad
  • ObjectIdentityOrdinalMap$Segment
    The map is divided into segments to increase concurrency
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