本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.computer.KeyValue类的典型用法代码示例。如果您正苦于以下问题:Java KeyValue类的具体用法?Java KeyValue怎么用?Java KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyValue类属于org.apache.tinkerpop.gremlin.process.computer包,在下文中一共展示了KeyValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: next
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public KeyValue next() {
try {
if (this.available) {
this.available = false;
return new KeyValue<>(this.key.get(), this.value.get());
} else {
while (true) {
if (this.readers.isEmpty())
throw new NoSuchElementException();
if (this.readers.peek().next(this.key, this.value)) {
return new KeyValue<>(this.key.get(), this.value.get());
} else
this.readers.remove().close();
}
}
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:ObjectWritableIterator.java
示例2: writeMemoryRDD
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> writeMemoryRDD(final Configuration configuration, final String memoryKey, JavaPairRDD<K, V> memoryRDD) {
final org.apache.hadoop.conf.Configuration hadoopConfiguration = ConfUtil.makeHadoopConfiguration(configuration);
final String outputLocation = hadoopConfiguration.get(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION);
if (null != outputLocation) {
// map back to a Hadoop stream for output
memoryRDD.mapToPair(keyValue -> new Tuple2<>(new ObjectWritable<>(keyValue._1()), new ObjectWritable<>(keyValue._2())))
.saveAsNewAPIHadoopFile(Constants.getMemoryLocation(outputLocation, memoryKey),
ObjectWritable.class,
ObjectWritable.class,
SequenceFileOutputFormat.class, hadoopConfiguration);
try {
return (Iterator) new ObjectWritableIterator(hadoopConfiguration, new Path(Constants.getMemoryLocation(outputLocation, memoryKey)));
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
return Collections.emptyIterator();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:OutputFormatRDD.java
示例3: head
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> head(final String location, final String memoryKey, final Class readerClass, final int totalLines) {
final Configuration configuration = new BaseConfiguration();
configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, location);
configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, readerClass.getCanonicalName());
try {
if (InputRDD.class.isAssignableFrom(readerClass)) {
return IteratorUtils.map(((InputRDD) readerClass.getConstructor().newInstance()).readMemoryRDD(configuration, memoryKey, new JavaSparkContext(Spark.getContext())).take(totalLines).iterator(), tuple -> new KeyValue(tuple._1(), tuple._2()));
} else if (InputFormat.class.isAssignableFrom(readerClass)) {
return IteratorUtils.map(new InputFormatRDD().readMemoryRDD(configuration, memoryKey, new JavaSparkContext(Spark.getContext())).take(totalLines).iterator(), tuple -> new KeyValue(tuple._1(), tuple._2()));
}
} catch (final Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
throw new IllegalArgumentException("The provided parserClass must be an " + InputFormat.class.getCanonicalName() + " or an " + InputRDD.class.getCanonicalName() + ": " + readerClass.getCanonicalName());
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:SparkContextStorage.java
示例4: complete
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
protected void complete(final MapReduce<?, ?, OK, OV, ?> mapReduce) {
if (mapReduce.getReduceKeySort().isPresent()) {
final Comparator<OK> comparator = mapReduce.getReduceKeySort().get();
final List<KeyValue<OK, OV>> list = new ArrayList<>(this.reduceQueue);
Collections.sort(list, Comparator.comparing(KeyValue::getKey, comparator));
this.reduceQueue.clear();
this.reduceQueue.addAll(list);
}
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:10,代码来源:TinkerReduceEmitter.java
示例5: emit
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public void emit(K key, V value) {
if (this.doReduce)
this.reduceMap.computeIfAbsent(key, k -> new ConcurrentLinkedQueue<>()).add(value);
else
this.mapQueue.add(new KeyValue<>(key, value));
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:8,代码来源:TinkerMapEmitter.java
示例6: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Map<Serializable, Set<String>> generateFinalResult(Iterator<KeyValue<Serializable, Set<String>>> keyValues) {
if (this.persistentProperties.containsKey(CLUSTER_SIZE)) {
long clusterSize = (long) persistentProperties.get(CLUSTER_SIZE);
keyValues = IteratorUtils.filter(keyValues, pair -> Long.valueOf(pair.getValue().size()).equals(clusterSize));
}
final Map<Serializable, Set<String>> clusterPopulation = Utility.keyValuesToMap(keyValues);
clusterPopulation.remove(NullObject.instance());
return clusterPopulation;
}
开发者ID:graknlabs,项目名称:grakn,代码行数:11,代码来源:ClusterMemberMapReduce.java
示例7: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Map<Serializable, Long> generateFinalResult(Iterator<KeyValue<Serializable, Long>> keyValues) {
if (this.persistentProperties.containsKey(CLUSTER_SIZE)) {
long clusterSize = (long) persistentProperties.get(CLUSTER_SIZE);
keyValues = IteratorUtils.filter(keyValues, pair -> pair.getValue().equals(clusterSize));
}
final Map<Serializable, Long> clusterPopulation = Utility.keyValuesToMap(keyValues);
clusterPopulation.remove(NullObject.instance());
return clusterPopulation;
}
开发者ID:graknlabs,项目名称:grakn,代码行数:11,代码来源:ClusterSizeMapReduce.java
示例8: head
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> head(final String location, final String memoryKey, final Class readerClass, final int totalLines) {
if (!readerClass.equals(SequenceFileInputFormat.class))
throw new IllegalArgumentException("Only " + SequenceFileInputFormat.class.getCanonicalName() + " memories are supported");
final Configuration configuration = new Configuration();
try {
return IteratorUtils.limit((Iterator) new ObjectWritableIterator(configuration, new Path(Constants.getMemoryLocation(location, memoryKey))), totalLines);
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:FileSystemStorage.java
示例9: writeMemoryRDD
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> writeMemoryRDD(final Configuration configuration, final String memoryKey, final JavaPairRDD<K, V> memoryRDD) {
if (!configuration.getBoolean(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false))
LOGGER.warn("The SparkContext should be persisted in order for the RDD to persist across jobs. To do so, set " + Constants.GREMLIN_SPARK_PERSIST_CONTEXT + " to true");
if (!configuration.containsKey(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION))
throw new IllegalArgumentException("There is no provided " + Constants.GREMLIN_HADOOP_OUTPUT_LOCATION + " to write the persisted RDD to");
final String memoryRDDName = Constants.getMemoryLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION), memoryKey);
Spark.removeRDD(memoryRDDName);
memoryRDD.setName(memoryRDDName).persist(StorageLevel.fromString(configuration.getString(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_ONLY")));
Spark.refresh(); // necessary to do really fast so the Spark GC doesn't clear out the RDD
return IteratorUtils.map(memoryRDD.collect().iterator(), tuple -> new KeyValue<>(tuple._1(), tuple._2()));
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:PersistedOutputRDD.java
示例10: emit
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public void emit(K key, V value) {
if (doReduce)
reduceMap.computeIfAbsent(key, k -> new ConcurrentLinkedQueue<>()).add(value);
else
mapQueue.add(new KeyValue<>(key, value));
}
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:8,代码来源:DuctileMapEmitter.java
示例11: complete
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
protected void complete(MapReduce<?, ?, OK, OV, ?> mapReduce) {
if (mapReduce.getReduceKeySort().isPresent()) {
Comparator<OK> comparator = mapReduce.getReduceKeySort().get();
List<KeyValue<OK, OV>> list = new ArrayList<>(reduceQueue);
Collections.sort(list, Comparator.comparing(KeyValue::getKey, comparator));
reduceQueue.clear();
reduceQueue.addAll(list);
}
}
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:10,代码来源:DuctileReduceEmitter.java
示例12: emit
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public void emit(final OK key, final OV value) {
this.reduceQueue.add(new KeyValue<>(key, value));
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:5,代码来源:TinkerReduceEmitter.java
示例13: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Map<Serializable, T> generateFinalResult(Iterator<KeyValue<Serializable, T>> iterator) {
return Utility.keyValuesToMap(iterator);
}
开发者ID:graknlabs,项目名称:grakn,代码行数:5,代码来源:GraknMapReduce.java
示例14: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Map<Serializable, Set<String>> generateFinalResult(Iterator<KeyValue<Serializable, Set<String>>> keyValues) {
final Map<Serializable, Set<String>> clusterPopulation = Utility.keyValuesToMap(keyValues);
clusterPopulation.remove(NullObject.instance());
return clusterPopulation;
}
开发者ID:graknlabs,项目名称:grakn,代码行数:7,代码来源:DegreeDistributionMapReduce.java
示例15: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Iterator<KeyValue<Object, Double>> generateFinalResult(final Iterator<KeyValue<Object, Double>> keyValues) {
return keyValues;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:PageRankMapReduce.java
示例16: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Map<Serializable, Long> generateFinalResult(final Iterator<KeyValue<Serializable, Long>> keyValues) {
final Map<Serializable, Long> clusterPopulation = new HashMap<>();
keyValues.forEachRemaining(pair -> clusterPopulation.put(pair.getKey(), pair.getValue()));
return clusterPopulation;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:7,代码来源:ClusterPopulationMapReduce.java
示例17: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Integer generateFinalResult(final Iterator<KeyValue<NullObject, Integer>> keyValues) {
return keyValues.next().getValue();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:ClusterCountMapReduce.java
示例18: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Long generateFinalResult(final Iterator<KeyValue<String, Long>> keyValues) {
return keyValues.next().getValue();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:CombineIteratorTest.java
示例19: generateFinalResult
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public Iterator<KeyValue<Object, Long>> generateFinalResult(final Iterator<KeyValue<Object, Long>> keyValues) {
return keyValues;
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:ShortestDistanceMapReduce.java
示例20: emit
import org.apache.tinkerpop.gremlin.process.computer.KeyValue; //导入依赖的package包/类
@Override
public void emit(OK key, OV value) {
reduceQueue.add(new KeyValue<>(key, value));
}
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:5,代码来源:DuctileReduceEmitter.java
注:本文中的org.apache.tinkerpop.gremlin.process.computer.KeyValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论