@Override public boolean filter(Tuple2<GradoopId, T> tuple2) throws Exception { return graphIds.contains(tuple2.f0); } }
@Override public Tuple2<T, GradoopId> map(Tuple1<T> input) { reuseTuple.f0 = input.f0; reuseTuple.f1 = GradoopId.get(); return reuseTuple; } }
@Override public GradoopIdSet reduce(GradoopIdSet in1, GradoopIdSet in2) { in1.addAll(in2); return in1; } }
@Override public void addGraphId(GradoopId graphId) { if (graphIds == null) { graphIds = new GradoopIdSet(); } graphIds.add(graphId); }
/** * Creates a new instance from multiple GradoopIDs. * * @param ids given ids * @return gradoop id set */ public static GradoopIdSet fromExisting(Collection<GradoopId> ids) { return new GradoopIdSet(ids); }
/** * Compares the given GradoopIds and returns the smaller one. It both are equal, the first * argument is returned. * * @param first first GradoopId * @param second second GradoopId * @return smaller GradoopId or first if equal */ public static GradoopId min(GradoopId first, GradoopId second) { int comparison = first.compareTo(second); return comparison == 0 ? first : (comparison < 0 ? first : second); }
/** * Returns the Gradoop ID represented by a byte array * * @param bytes byte representation * @return Gradoop ID */ public static GradoopId fromByteArray(byte[] bytes) { return new GradoopId(bytes); }
/** * Returns the timestamp component of the id. * * @return the timestamp */ private int getTimeStamp() { return makeInt(bytes[0], bytes[1], bytes[2], bytes[3]); }
/** * Initializes the set with the given byte array. * * @param bytes bytes representing multiple gradoop ids */ private GradoopIdSet(byte[] bytes) { this.ids = readIds(bytes); }
/** * Returns the byte representation of that set. * * @return byte array representation */ public byte[] toByteArray() { return writeIds(ids); }
@Override public Tuple2<T, GradoopId> map(T input) { reuseTuple.f0 = input; reuseTuple.f1 = GradoopId.get(); return reuseTuple; } }
/** * Creates a new instance from multiple GradoopIDs represented as byte array. * * @param bytes byte array representing multiple gradoop ids * @return gradoop id set */ public static GradoopIdSet fromByteArray(byte[] bytes) { return new GradoopIdSet(bytes); }
@Override public boolean filter(Tuple2<GradoopId, T> tuple2) throws Exception { return graphIds.contains(tuple2.f0); } }
@Override public GradoopIdSet reduce(GradoopIdSet in1, GradoopIdSet in2) { in1.addAll(in2); return in1; } }
/** * Returns the machine identifier component of the id. * * @return the machine identifier */ private int getMachineIdentifier() { return makeInt((byte) 0, bytes[4], bytes[5], bytes[6]); }
@Override public Tuple2<T, GradoopId> map(T input) { reuseTuple.f0 = input; reuseTuple.f1 = GradoopId.get(); return reuseTuple; } }
/** * Returns the process identifier component of the id. * * @return the process identifier */ private short getProcessIdentifier() { return (short) makeInt((byte) 0, (byte) 0, bytes[7], bytes[8]); }
@Override public Tuple2<T, GradoopId> map(Tuple1<T> input) { reuseTuple.f0 = input.f0; reuseTuple.f1 = GradoopId.get(); return reuseTuple; } }
/** * Returns the counter component of the id. * * @return the counter */ private int getCounter() { return makeInt((byte) 0, bytes[9], bytes[10], bytes[11]); }