@Override public HollowRecord instantiateValue(int valueOrdinal) { return GenericHollowRecordHelper.instantiate(getTypeDataAccess().getDataAccess(), getSchema().getValueType(), valueOrdinal); }
@Override public HollowRecord instantiateKey(int keyOrdinal) { return GenericHollowRecordHelper.instantiate(getTypeDataAccess().getDataAccess(), getSchema().getKeyType(), keyOrdinal); }
private List<Field> createMapFields(HollowEffigy effigy) { List<Field> fields = new ArrayList<Field>(); HollowMapTypeDataAccess typeDataAccess = (HollowMapTypeDataAccess)effigy.dataAccess; HollowMapSchema schema = typeDataAccess.getSchema(); HollowMapEntryOrdinalIterator iter = typeDataAccess.ordinalIterator(effigy.ordinal); while(iter.next()) { HollowEffigy entryEffigy = new HollowEffigy("Map.Entry"); entryEffigy.add(new Field("key", effigy(typeDataAccess.getDataAccess(), schema.getKeyType(), iter.getKey()))); entryEffigy.add(new Field("value", effigy(typeDataAccess.getDataAccess(), schema.getValueType(), iter.getValue()))); fields.add(new Field("entry", "Map.Entry", entryEffigy)); } return fields; }
@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; }
@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; }
@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; }
@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; }