public Selection lessThan(int value) { Selection selection = new BitmapBackedSelection(); Int2ObjectSortedMap<IntArrayList> head = index.headMap(value); // we add 1 to get values equal to the arg for (IntArrayList keys : head.values()) { addAllToSelection(keys, selection); } return selection; }
protected static int getLowestSchemaSameVersion(final Int2ObjectSortedMap<Schema> schemas, final int versionKey) { if (versionKey < schemas.firstIntKey()) { // can't have a data type before anything else return schemas.firstIntKey(); } return schemas.subMap(0, versionKey + 1).lastIntKey(); }
public Schema addSchema(final int version, final int subVersion, final BiFunction<Integer, Schema, Schema> factory) { final int key = DataFixUtils.makeKey(version, subVersion); final Schema parent = schemas.isEmpty() ? null : schemas.get(DataFixerUpper.getLowestSchemaSameVersion(schemas, key - 1)); final Schema schema = factory.apply(DataFixUtils.makeKey(version, subVersion), parent); addSchema(schema); return schema; }
/** * {@inheritDoc} * <p> * Note that this specification strengthens the one given in * {@link SortedMap#subMap(Object,Object)}. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Int2ObjectSortedMap<V> subMap(final Integer from, final Integer to) { return subMap((from).intValue(), (to).intValue()); } /**
@Override public int firstIntKey() { synchronized (sync) { return sortedMap.firstIntKey(); } } @Override
@Override public int lastIntKey() { synchronized (sync) { return sortedMap.lastIntKey(); } } /**
/** * {@inheritDoc} * <p> * Note that this specification strengthens the one given in * {@link SortedMap#headMap(Object)}. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Int2ObjectSortedMap<V> headMap(final Integer to) { return headMap((to).intValue()); } /**
/** * Returns an iterable yielding a bidirectional iterator that will be * {@linkplain FastSortedEntrySet fast}, if possible, on the * {@linkplain Map#entrySet() entry set} of the provided {@code map}. * * @param map * a map from which we will try to extract an iterable yielding a * (fast) bidirectional iterator on the entry set. * @return an iterable yielding a bidirectional iterator on the entry set of the * given map that will be fast, if possible. * @since 8.0.0 */ @SuppressWarnings("unchecked") public static <V> ObjectBidirectionalIterable<Int2ObjectMap.Entry<V>> fastIterable(Int2ObjectSortedMap<V> map) { final ObjectSortedSet<Int2ObjectMap.Entry<V>> entries = map.int2ObjectEntrySet(); return entries instanceof Int2ObjectSortedMap.FastSortedEntrySet ? ((Int2ObjectSortedMap.FastSortedEntrySet<V>) entries)::fastIterator : entries; } /**
@Override public IntComparator comparator() { return sortedMap.comparator(); } @Override
@Override public Schema getSchema(final int key) { return schemas.get(getLowestSchemaSameVersion(schemas, key)); }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Integer firstKey() { return sortedMap.firstKey(); } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Int2ObjectSortedMap<V> subMap(final Integer from, final Integer to) { return new SynchronizedSortedMap<>(sortedMap.subMap(from, to), sync); } /**
@Override public int firstIntKey() { return sortedMap.firstIntKey(); } @Override
@Override public int lastIntKey() { return sortedMap.lastIntKey(); } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Int2ObjectSortedMap<V> headMap(final Integer to) { return new SynchronizedSortedMap<>(sortedMap.headMap(to), sync); } /**
/** * Returns a sorted-set view of the mappings contained in this map. * <p> * Note that this specification strengthens the one given in the corresponding * type-specific unsorted map. * * @return a sorted-set view of the mappings contained in this map. * @see SortedMap#entrySet() * @deprecated Please use the corresponding type-specific method instead. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Deprecated @Override default ObjectSortedSet<Map.Entry<Integer, V>> entrySet() { return (ObjectSortedSet) int2ObjectEntrySet(); } /**
@Override public IntComparator comparator() { synchronized (sync) { return sortedMap.comparator(); } } @Override
public DataFixer build(final Executor executor) { final DataFixerUpper fixerUpper = new DataFixerUpper(new Int2ObjectAVLTreeMap<>(schemas), new ArrayList<>(globalList), new IntAVLTreeSet(fixerVersions)); final IntBidirectionalIterator iterator = fixerUpper.fixerVersions().iterator(); while (iterator.hasNext()) { final int versionKey = iterator.nextInt(); final Schema schema = schemas.get(versionKey); for (final String typeName : schema.types()) { CompletableFuture.runAsync(() -> { final Type<?> dataType = schema.getType(() -> typeName); final TypeRewriteRule rule = fixerUpper.getRule(DataFixUtils.getVersion(versionKey), dataVersion); dataType.rewrite(rule, DataFixerUpper.OPTIMIZATION_RULE); }, executor).exceptionally(e -> { LOGGER.error("Unable to build datafixers", e); Runtime.getRuntime().exit(1); return null; }); } } return fixerUpper; } }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Integer firstKey() { synchronized (sync) { return sortedMap.firstKey(); } } /**
public Selection atMost(int value) { Selection selection = new BitmapBackedSelection(); Int2ObjectSortedMap<IntArrayList> head = index.headMap(value + 1); // we add 1 to get values equal to the arg for (IntArrayList keys : head.values()) { addAllToSelection(keys, selection); } return selection; }