forked from dbs-leipzig/gradoop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dbs-leipzig#1433] Handle edges between retained vertices.
- Loading branch information
Showing
10 changed files
with
327 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...radoop/flink/model/impl/operators/keyedgrouping/functions/BuildTuplesFromEdgesWithId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright © 2014 - 2019 Leipzig University (Database Research Group) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.gradoop.flink.model.impl.operators.keyedgrouping.functions; | ||
|
||
import org.apache.flink.api.java.tuple.Tuple; | ||
import org.gradoop.common.model.api.entities.Edge; | ||
import org.gradoop.flink.model.api.functions.AggregateFunction; | ||
import org.gradoop.flink.model.api.functions.KeyFunction; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Build a tuple-based representation of edges for grouping with an additional source ID field at position | ||
* {@value GroupingConstants#EDGE_TUPLE_ID}. All other fields will be shifted by | ||
* {@value GroupingConstants#EDGE_RETENTION_OFFSET}. | ||
* | ||
* @param <E> The edge type. | ||
*/ | ||
public class BuildTuplesFromEdgesWithId<E extends Edge> extends BuildTuplesFromEdges<E> { | ||
|
||
/** | ||
* Initialize this function, setting the grouping keys and aggregate functions. | ||
* | ||
* @param keys The edge grouping keys. | ||
* @param aggregateFunctions The edge aggregate functions. | ||
*/ | ||
public BuildTuplesFromEdgesWithId(List<KeyFunction<E, ?>> keys, | ||
List<AggregateFunction> aggregateFunctions) { | ||
super(keys, aggregateFunctions, GroupingConstants.EDGE_RETENTION_OFFSET); | ||
} | ||
|
||
@Override | ||
public Tuple map(E element) throws Exception { | ||
final Tuple tuple = super.map(element); | ||
tuple.setField(element.getId(), GroupingConstants.EDGE_TUPLE_ID); | ||
return tuple; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...radoop/flink/model/impl/operators/keyedgrouping/functions/CreateElementMappingToSelf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright © 2014 - 2019 Leipzig University (Database Research Group) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.gradoop.flink.model.impl.operators.keyedgrouping.functions; | ||
|
||
import org.apache.flink.api.common.functions.MapFunction; | ||
import org.apache.flink.api.java.tuple.Tuple2; | ||
import org.gradoop.common.model.api.entities.Identifiable; | ||
import org.gradoop.common.model.impl.id.GradoopId; | ||
|
||
/** | ||
* Create a mapping (in the form of a {@link Tuple2}) from the ID of an element to itself. | ||
* | ||
* @param <E> The element type. | ||
*/ | ||
public class CreateElementMappingToSelf<E extends Identifiable> | ||
implements MapFunction<E, Tuple2<GradoopId, GradoopId>> { | ||
|
||
/** | ||
* Reduce object instantiations. | ||
*/ | ||
private final Tuple2<GradoopId, GradoopId> reuse = new Tuple2<>(); | ||
|
||
@Override | ||
public Tuple2<GradoopId, GradoopId> map(E element) { | ||
reuse.f0 = element.getId(); | ||
reuse.f1 = element.getId(); | ||
return reuse; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...va/org/gradoop/flink/model/impl/operators/keyedgrouping/functions/FilterEdgesToGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright © 2014 - 2019 Leipzig University (Database Research Group) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.gradoop.flink.model.impl.operators.keyedgrouping.functions; | ||
|
||
import org.apache.flink.api.common.functions.FilterFunction; | ||
import org.apache.flink.api.java.tuple.Tuple; | ||
import org.gradoop.common.model.impl.id.GradoopId; | ||
|
||
/** | ||
* A filter function accepting all edges that were not marked for retention. | ||
* | ||
* @param <T> The edge tuple type. | ||
*/ | ||
public class FilterEdgesToGroup<T extends Tuple> implements FilterFunction<T> { | ||
|
||
@Override | ||
public boolean filter(T tuple) { | ||
return tuple.getField(GroupingConstants.EDGE_TUPLE_ID).equals(GradoopId.NULL_VALUE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...a/org/gradoop/flink/model/impl/operators/keyedgrouping/functions/PickRetainedEdgeIDs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright © 2014 - 2019 Leipzig University (Database Research Group) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.gradoop.flink.model.impl.operators.keyedgrouping.functions; | ||
|
||
import org.apache.flink.api.common.functions.FlatMapFunction; | ||
import org.apache.flink.api.java.tuple.Tuple; | ||
import org.apache.flink.util.Collector; | ||
import org.gradoop.common.model.impl.id.GradoopId; | ||
|
||
/** | ||
* Picks the ID from a tuple if that ID is not {@link GradoopId#NULL_VALUE}. | ||
* | ||
* @param <T> The input tuple type. | ||
*/ | ||
public class PickRetainedEdgeIDs<T extends Tuple> implements FlatMapFunction<T, GradoopId> { | ||
|
||
@Override | ||
public void flatMap(T tuple, Collector<GradoopId> collector) { | ||
final GradoopId id = tuple.getField(GroupingConstants.EDGE_TUPLE_ID); | ||
if (!id.equals(GradoopId.NULL_VALUE)) { | ||
collector.collect(id); | ||
} | ||
} | ||
} |
Oops, something went wrong.