/** * A {@code ToFreqMap} is a {@link KorypheFunction} that * creates a new FreqMap and upserts a given value. */ @Since("1.8.0") @Summary("Creates a new FreqMap and upserts a given value") public class ToFreqMap extends KorypheFunction<Object, FreqMap> { @Override public FreqMap apply(final Object value) { return new FreqMap(null != value ? value.toString() : null); } }
/** * An {@code UnwrapVertex} is a {@link KorypheFunction} for unwrapping {@link EntityId}s. * If the input is an EntityId the vertex is extracted, otherwise the original * value is returned. */ @Since("1.5.0") @Summary("Extracts the the vertex from an entityId") public class UnwrapEntityId extends KorypheFunction<Object, Object> { @Override public Object apply(final Object item) { return null != item ? item instanceof EntityId ? ((EntityId) item).getVertex() : item : null; } }
/** * A {@code ToTypeSubTypeValue} is a {@link KorypheFunction} that converts a * value into a {@link TypeSubTypeValue}, by setting the Type and SubType to null * and the Value to the input value. */ @Since("1.8.0") @Summary("Converts a value into a TypeSubTypeValue") public class ToTypeSubTypeValue extends KorypheFunction<Object, TypeSubTypeValue> { @Override public TypeSubTypeValue apply(final Object value) { return new TypeSubTypeValue(null, null, null != value ? value.toString() : null); } }
/** * A {@code LongsSketchAggregator} is a {@link java.util.function.BinaryOperator} that takes in * {@link LongsSketch}s and merges them together using {@link LongsSketch#merge(LongsSketch)}. */ @Since("1.0.0") @Summary("Aggregates LongSketches objects") public class LongsSketchAggregator extends KorypheBinaryOperator<LongsSketch> { @Override protected LongsSketch _apply(final LongsSketch a, final LongsSketch b) { a.merge(b); return a; } }
/** * A {@code KllFloatsSketchAggregator} is a {@link KorypheBinaryOperator} that aggregates * {@link KllFloatsSketch}s. */ @Since("1.4.0") @Summary("Aggregates KllFloatsSketches") public class KllFloatsSketchAggregator extends KorypheBinaryOperator<KllFloatsSketch> { @Override protected KllFloatsSketch _apply(final KllFloatsSketch a, final KllFloatsSketch b) { a.merge(b); return a; } }
/** * A {@code ToTypeValue} is a {@link KorypheFunction} that converts a * value into a {@link TypeValue}, by setting the Type to null * and the Value to the input value. */ @Since("1.8.0") @Summary("Converts a value into a TypeValue") public class ToTypeValue extends KorypheFunction<Object, TypeValue> { @Override public TypeValue apply(final Object value) { return new TypeValue(null, null != value ? value.toString() : null); } }
/** * An {@code ExtractGroup} is a {@link KorypheFunction} for * extracting a group from an {@link Element}. * If the Element is null, this function will return null. */ @Since("1.4.0") @Summary("Extracts a group from an element") public class ExtractGroup extends KorypheFunction<Element, String> { @Override public String apply(final Element element) { return null != element ? element.getGroup() : null; } }
/** * Aggregator for {@link RoaringBitmap} objects. * Bitmaps are aggregated using a bitwise OR operation. */ @Since("1.0.0") @Summary("Aggregates RoaringBitmaps") public class RoaringBitmapAggregator extends KorypheBinaryOperator<RoaringBitmap> { @Override protected RoaringBitmap _apply(final RoaringBitmap a, final RoaringBitmap b) { a.or(b); return a; } }
/** * A {@code UnionAggregator} is a {@link java.util.function.BinaryOperator} that aggregates {@link Union}s. * It does this by extracting a {@link com.yahoo.sketches.theta.CompactSketch} from each {@link Union} * and merges that using {@link Union#update(com.yahoo.sketches.theta.Sketch)}. */ @Since("1.0.0") @Summary("Aggregates Unions") public class UnionAggregator extends KorypheBinaryOperator<Union> { @Override protected Union _apply(final Union a, final Union b) { a.update(b.getResult()); return a; } }
/** * A {@code HllUnionAggregator} is a {@link java.util.function.BinaryOperator} that takes in * {@link com.yahoo.sketches.hll.Union}s and merges them together using * {@link Union#update(com.yahoo.sketches.hll.HllSketch)}. */ @Since("1.0.0") @Summary("Aggregates HllUnions objects") public class HllUnionAggregator extends KorypheBinaryOperator<Union> { @Override protected Union _apply(final Union a, final Union b) { a.update(b.getResult()); return a; } }
/** * A {@code DoublesUnionAggregator} is a {@link java.util.function.BinaryOperator} that aggregates {@link DoublesUnion}s. * It does this by extracting a {@link com.yahoo.sketches.quantiles.DoublesSketch} from each {@link DoublesUnion} * and merges that using {@link DoublesUnion#update(com.yahoo.sketches.quantiles.DoublesSketch)}. */ @Since("1.0.0") @Summary("Aggregates DoublesUnions") public class DoublesUnionAggregator extends KorypheBinaryOperator<DoublesUnion> { @Override protected DoublesUnion _apply(final DoublesUnion a, final DoublesUnion b) { a.update(b.getResult()); return a; } }
/** * A {@code StringsUnionAggregator} is a {@link java.util.function.BinaryOperator} that aggregates {@link ItemsUnion}s * of {@link String}s. It does this by extracting a {@link com.yahoo.sketches.quantiles.ItemsSketch} from each * {@link ItemsUnion} and merges that using {@link ItemsUnion#update(com.yahoo.sketches.quantiles.ItemsSketch)}. */ @Since("1.0.0") @Summary("Aggregates ItemUnions of Strings") public class StringsUnionAggregator extends KorypheBinaryOperator<ItemsUnion<String>> { @Override protected ItemsUnion<String> _apply(final ItemsUnion<String> a, final ItemsUnion<String> b) { a.update(b.getResult()); return a; } }
/** * A {@code ReservoirItemsSketchAggregator} is a {@link java.util.function.BinaryOperator} that aggregates * {@link ReservoirItemsSketch}s using a {@link ReservoirItemsUnion}. */ @Since("1.0.0") @Summary("Aggregates ReservoirItemsSketches") public class ReservoirItemsSketchAggregator<T> extends KorypheBinaryOperator<ReservoirItemsSketch<T>> { @Override protected ReservoirItemsSketch<T> _apply(final ReservoirItemsSketch<T> a, final ReservoirItemsSketch<T> b) { final ReservoirItemsUnion<T> union = ReservoirItemsUnion.newInstance(a.getK()); union.update(a); union.update(b); return union.getResult(); } }
/** * A {@code ReservoirLongsUnionAggregator} is a {@link java.util.function.BinaryOperator} that aggregates * {@link ReservoirLongsUnion}s. It does this by extracting a {@link com.yahoo.sketches.sampling.ReservoirLongsSketch} * from each {@link ReservoirLongsUnion} and merges that using * {@link ReservoirLongsUnion#update(com.yahoo.sketches.sampling.ReservoirLongsSketch)}. */ @Since("1.0.0") @Summary("Aggregates ReservoirLongsUnions") public class ReservoirLongsUnionAggregator extends KorypheBinaryOperator<ReservoirLongsUnion> { @Override protected ReservoirLongsUnion _apply(final ReservoirLongsUnion a, final ReservoirLongsUnion b) { a.update(b.getResult()); return a; } }
/** * A {@code HllSketchAggregator} is a {@link java.util.function.BinaryOperator} that takes in * {@link HllSketch}s and merges them together using a {@link Union}. */ @Since("1.0.0") @Summary("Aggregates HllSketches together using a Union") public class HllSketchAggregator extends KorypheBinaryOperator<HllSketch> { @Override protected HllSketch _apply(final HllSketch a, final HllSketch b) { final Union union = new Union(a.getLgConfigK()); union.update(a); union.update(b); return union.getResult(); } }
/** * A {@code DoublesSketchAggregator} is a {@link java.util.function.BinaryOperator} that aggregates * {@link DoublesSketch}s using a {@link DoublesUnion}. */ @Since("1.0.0") @Summary("Aggregates DoublesSketches using a DoublesUnion") public class DoublesSketchAggregator extends KorypheBinaryOperator<DoublesSketch> { @Override protected DoublesSketch _apply(final DoublesSketch a, final DoublesSketch b) { final DoublesUnion union = DoublesUnion.builder().setMaxK(a.getK()).build(); union.update(a); union.update(b); return union.getResult(); } }
/** * A {@code SketchAggregator} is a {@link java.util.function.BinaryOperator} that aggregates {@link Sketch}s * using a {@link Union}. */ @Since("1.0.0") @Summary("Aggregates Sketches using a Union") public class SketchAggregator extends KorypheBinaryOperator<Sketch> { @Override protected Sketch _apply(final Sketch a, final Sketch b) { final Union union = Sketches.setOperationBuilder().buildUnion(); union.update(a); union.update(b); return union.getResult(); } }
/** * An {@code ExtractWalkEntities} is a utility {@link KorypheFunction} for extracting the {@link java.util.List} of * {@link Set}s of Gaffer {@link Entity}s, from a provided {@link Walk} object. */ @Since("1.2.0") @Summary("Extracts the sets of entities from a Walk") public class ExtractWalkEntities extends KorypheFunction<Walk, Iterable<Set<Entity>>> { @Override public Iterable<Set<Entity>> apply(final Walk walk) { if (null == walk) { throw new IllegalArgumentException("Walk cannot be null"); } return walk.getEntities(); } }
/** * A {@code StringsSketchAggregator} is a {@link java.util.function.BinaryOperator} that aggregates * {@link ItemsSketch}s of {@link String}s using an {@link ItemsUnion}. */ @Since("1.0.0") @Summary("Aggregates ItemsSketches of Strings using an ItemsUnion") public class StringsSketchAggregator extends KorypheBinaryOperator<ItemsSketch<String>> { @Override protected ItemsSketch<String> _apply(final ItemsSketch<String> a, final ItemsSketch<String> b) { final ItemsUnion<String> union = ItemsUnion.getInstance(Ordering.<String>natural()); union.update(a); union.update(b); return union.getResult(); } }
/** * An {@code ExtractWalkEdges} is a utility {@link KorypheFunction} for extracting the {@link java.util.List} of * {@link Set}s of Gaffer {@link Edge}s, from a provided {@link Walk} object. */ @Since("1.2.0") @Summary("Extracts the sets of edges from a Walk") public class ExtractWalkEdges extends KorypheFunction<Walk, Iterable<Set<Edge>>> { @Override public Iterable<Set<Edge>> apply(final Walk walk) { if (null == walk) { throw new IllegalArgumentException("Walk cannot be null"); } return walk.getEdges(); } }