Here you can find the source of reduceSet(Iterator
Parameter | Description |
---|---|
values | the aggregated values associated with the key |
T | the type of the set |
static <T> Set<T> reduceSet(Iterator<Set<T>> values)
//package com.java2s; /*//from ww w .j a v a2 s.co m * Grakn - A Distributed Semantic Database * Copyright (C) 2016 Grakn Labs Limited * * Grakn is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Grakn is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Grakn. If not, see <http://www.gnu.org/licenses/gpl.txt>. */ import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class Main { /** * A helper method for set MapReduce. It simply combines sets into one set. * * @param values the aggregated values associated with the key * @param <T> the type of the set * @return the combined set */ static <T> Set<T> reduceSet(Iterator<Set<T>> values) { Set<T> set = new HashSet<>(); while (values.hasNext()) { set.addAll(values.next()); } return set; } }