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#1559] Changed the operator to first get all the absolute…
… degree trees, calculate the cross product with every timestamp and then get the degree by grouping
- Loading branch information
1 parent
0b6a5c5
commit 234f8b9
Showing
12 changed files
with
537 additions
and
83 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...p-examples-temporal/src/main/java/org/gradoop/examples/metric/DegreeEvolutionExample.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,36 @@ | ||
package org.gradoop.examples.metric; | ||
|
||
import org.apache.flink.api.java.DataSet; | ||
import org.apache.flink.api.java.ExecutionEnvironment; | ||
import org.apache.flink.api.java.tuple.Tuple1; | ||
import org.apache.flink.api.java.tuple.Tuple2; | ||
import org.gradoop.common.model.api.entities.Identifiable; | ||
import org.gradoop.flink.model.impl.operators.sampling.functions.VertexDegree; | ||
import org.gradoop.temporal.io.impl.csv.TemporalCSVDataSource; | ||
import org.gradoop.temporal.model.api.TimeDimension; | ||
import org.gradoop.temporal.model.impl.TemporalGraph; | ||
import org.gradoop.temporal.model.impl.operators.metric.functions.GetTimestamps; | ||
import org.gradoop.temporal.model.impl.pojo.TemporalEdge; | ||
import org.gradoop.temporal.model.impl.pojo.TemporalVertex; | ||
import org.gradoop.temporal.util.TemporalGradoopConfig; | ||
|
||
import static java.lang.Long.MAX_VALUE; | ||
import static java.lang.Long.MIN_VALUE; | ||
import static org.apache.flink.api.java.ExecutionEnvironment.getExecutionEnvironment; | ||
|
||
public class DegreeEvolutionExample { | ||
|
||
|
||
public static void main(String[] args) throws Exception { | ||
ExecutionEnvironment env = getExecutionEnvironment(); | ||
|
||
TemporalGraph graph = new TemporalCSVDataSource("2018-citibike-csv-1", TemporalGradoopConfig.createConfig(env)) | ||
.getTemporalGraph(); | ||
|
||
|
||
|
||
final DataSet<Tuple1<Long>> resultDataSet = graph.getEdges().flatMap(new GetTimestamps(TimeDimension.VALID_TIME, VertexDegree.BOTH)).distinct(); | ||
|
||
resultDataSet.print(); | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
...gradoop/temporal/model/impl/operators/metric/functions/FlatMapAbsoluteTreesToDataSet.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,19 @@ | ||
package org.gradoop.temporal.model.impl.operators.metric.functions; | ||
|
||
import org.apache.flink.api.common.functions.FlatMapFunction; | ||
import org.apache.flink.api.java.tuple.Tuple2; | ||
import org.apache.flink.util.Collector; | ||
import org.gradoop.common.model.impl.id.GradoopId; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
// FlatMap function to convert Tuple2<GradoopID, TreeMap<Long, Integer>> to Tuple2<Long, Integer> | ||
public class FlatMapAbsoluteTreesToDataSet implements FlatMapFunction<Tuple2<GradoopId, TreeMap<Long, Integer>>, Tuple2<Long, Integer>> { | ||
@Override | ||
public void flatMap(Tuple2<GradoopId, TreeMap<Long, Integer>> input, Collector<Tuple2<Long, Integer>> out) { | ||
for (Map.Entry<Long, Integer> entry : input.f1.entrySet()) { | ||
out.collect(new Tuple2<>(entry.getKey(), entry.getValue())); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...c/main/java/org/gradoop/temporal/model/impl/operators/metric/functions/GetTimestamps.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,68 @@ | ||
/* | ||
* Copyright © 2014 - 2021 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.temporal.model.impl.operators.metric.functions; | ||
|
||
import org.apache.flink.api.common.functions.FlatMapFunction; | ||
import org.apache.flink.api.java.functions.FunctionAnnotation; | ||
import org.apache.flink.api.java.tuple.Tuple1; | ||
import org.apache.flink.api.java.tuple.Tuple3; | ||
import org.apache.flink.util.Collector; | ||
import org.gradoop.common.model.impl.id.GradoopId; | ||
import org.gradoop.flink.model.impl.operators.sampling.functions.VertexDegree; | ||
import org.gradoop.temporal.model.api.TimeDimension; | ||
import org.gradoop.temporal.model.impl.pojo.TemporalEdge; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* A flat map function extracting the id and temporal interval from an {@link TemporalEdge} instance. | ||
*/ | ||
//@FunctionAnnotation.ForwardedFields("id->f0") | ||
public class GetTimestamps implements FlatMapFunction<TemporalEdge, Tuple1<Long>> { | ||
|
||
/** | ||
* The time dimension to consider. | ||
*/ | ||
private final TimeDimension timeDimension; | ||
|
||
/** | ||
* The degree type to consider. | ||
*/ | ||
private final VertexDegree degreeType; | ||
|
||
/** | ||
* Creates an instance of this flat map transformation. | ||
* | ||
* @param timeDimension the time dimension to consider | ||
* @param degreeType the degree type to consider | ||
*/ | ||
public GetTimestamps(TimeDimension timeDimension, VertexDegree degreeType) { | ||
this.timeDimension = Objects.requireNonNull(timeDimension); | ||
this.degreeType = Objects.requireNonNull(degreeType); | ||
} | ||
|
||
@Override | ||
public void flatMap(TemporalEdge temporalEdge, Collector<Tuple1<Long>> collector) throws | ||
Exception { | ||
Long from = timeDimension | ||
.equals(TimeDimension.VALID_TIME) ? temporalEdge.getValidFrom() : temporalEdge.getTxFrom(); | ||
Long to = timeDimension | ||
.equals(TimeDimension.VALID_TIME) ? temporalEdge.getValidTo() : temporalEdge.getTxTo(); | ||
|
||
collector.collect(new Tuple1<>(from)); | ||
collector.collect(new Tuple1<>(to)); | ||
} | ||
} |
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
Oops, something went wrong.