本文整理汇总了Java中org.apache.spark.Partition类的典型用法代码示例。如果您正苦于以下问题:Java Partition类的具体用法?Java Partition怎么用?Java Partition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Partition类属于org.apache.spark包,在下文中一共展示了Partition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkUserPartition
import org.apache.spark.Partition; //导入依赖的package包/类
protected void checkUserPartition(JavaRDD<String> userRDD) {
System.out.println("hhhhh");
List<Partition> partitios = userRDD.partitions();
System.out.println(partitios.size());
int[] partitionIds = new int[partitios.size()];
for (int i = 0; i < partitios.size(); i++) {
int index = partitios.get(i).index();
partitionIds[i] = index;
}
List<String>[] userIPs = userRDD.collectPartitions(partitionIds);
for (int i = 0; i < userIPs.length; i++) {
List<String> iuser = userIPs[i];
System.out.println(i + " partition");
System.out.println(iuser.toString());
}
}
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:18,代码来源:LogAbstract.java
示例2: getPartitions
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Partition[] getPartitions() {
try {
final List<? extends Source<T>> partitionedSources =
microbatchSource.split(options.get());
final Partition[] partitions = new CheckpointableSourcePartition[partitionedSources.size()];
for (int i = 0; i < partitionedSources.size(); i++) {
partitions[i] =
new CheckpointableSourcePartition<>(
id(), i, partitionedSources.get(i), EmptyCheckpointMark.get());
}
return partitions;
} catch (Exception e) {
throw new RuntimeException("Failed to create partitions.", e);
}
}
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:SourceRDD.java
示例3: initIterator
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public void initIterator(Partition dp, S config) {
int id = config.getRddId();
NewHadoopPartition split = (NewHadoopPartition) dp;
TaskAttemptID attemptId = DeepSparkHadoopMapReduceUtil
.newTaskAttemptID(jobTrackerId, id, true, split.index(), 0);
Configuration configuration = getHadoopConfig(config);
TaskAttemptContext hadoopAttemptContext = DeepSparkHadoopMapReduceUtil
.newTaskAttemptContext(configuration, attemptId);
try {
reader = inputFormat.createRecordReader(split.serializableHadoopSplit().value(), hadoopAttemptContext);
reader.initialize(split.serializableHadoopSplit().value(), hadoopAttemptContext);
} catch (IOException | InterruptedException e) {
throw new DeepGenericException(e);
}
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:23,代码来源:GenericHadoopExtractor.java
示例4: getPartitions
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Partition[] getPartitions(ExtractorConfig<T> config) {
GetPartitionsAction<T> getPartitionsAction = new GetPartitionsAction<>(config);
channel.writeAndFlush(getPartitionsAction);
Response response;
boolean interrupted = false;
for (; ; ) {
try {
response = answer.take();
break;
} catch (InterruptedException ignore) {
interrupted = true;
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
return ((GetPartitionsResponse) response).getPartitions();
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:25,代码来源:ExtractorClientHandler.java
示例5: initIterator
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public void initIterator(Partition dp, ExtractorConfig<T> config) {
InitIteratorAction<T> initIteratorAction = new InitIteratorAction<>(dp, config);
channel.writeAndFlush(initIteratorAction);
Response response;
boolean interrupted = false;
for (; ; ) {
try {
response = answer.take();
break;
} catch (InterruptedException ignore) {
interrupted = true;
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
return;
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:23,代码来源:ExtractorClientHandler.java
示例6: getPartitions
import org.apache.spark.Partition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Partition[] getPartitions(S config) {
jdbcDeepJobConfig = initConfig(config, jdbcDeepJobConfig);
int upperBound = jdbcDeepJobConfig.getUpperBound();
int lowerBound = jdbcDeepJobConfig.getLowerBound();
int numPartitions = jdbcDeepJobConfig.getNumPartitions();
int length = 1 + upperBound - lowerBound;
Partition [] result = new Partition[numPartitions];
for(int i=0; i<numPartitions; i++) {
int start = lowerBound + lowerBound + ((i * length) / numPartitions);
int end = lowerBound + (((i + 1) * length) / numPartitions) - 1;
result[i] = new JdbcPartition(i, start, end);
}
return result;
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:20,代码来源:JdbcNativeExtractor.java
示例7: init
import org.apache.spark.Partition; //导入依赖的package包/类
/**
* Initialized the reader
*
* @param p
* Spark partition.
* @throws Exception
*/
public void init(Partition p) throws Exception {
Class.forName(jdbcDeepJobConfig.getDriverClass());
conn = DriverManager.getConnection(jdbcDeepJobConfig.getConnectionUrl(),
jdbcDeepJobConfig.getUsername(),
jdbcDeepJobConfig.getPassword());
Statement statement = conn.createStatement();
SelectQuery query = jdbcDeepJobConfig.getQuery();
JdbcPartition jdbcPartition = (JdbcPartition)p;
if(jdbcDeepJobConfig.getNumPartitions() > 1) {
Column partitionKey = jdbcDeepJobConfig.getPartitionKey();
query.getWhereClause().addCondition(BinaryCondition.lessThan(partitionKey, jdbcPartition.upper(), true))
.addCondition(BinaryCondition.greaterThan(partitionKey, jdbcPartition.lower(), true));
}
resultSet = statement.executeQuery(query.toString());
// Fetches first element
this.hasNext = resultSet.next();
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:25,代码来源:JdbcReader.java
示例8: coalesce
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public PartitionGroup[] coalesce(int maxPartitions, RDD<?> parent) {
if (maxPartitions != parent.getNumPartitions()) {
throw new IllegalArgumentException("Cannot use " + getClass().getSimpleName() +
" with a different number of partitions to the parent RDD.");
}
List<Partition> partitions = Arrays.asList(parent.getPartitions());
PartitionGroup[] groups = new PartitionGroup[partitions.size()];
for (int i = 0; i < partitions.size(); i++) {
Seq<String> preferredLocations = parent.getPreferredLocations(partitions.get(i));
scala.Option<String> preferredLocation = scala.Option.apply
(preferredLocations.isEmpty() ? null : preferredLocations.apply(0));
PartitionGroup group = new PartitionGroup(preferredLocation);
List<Partition> partitionsInGroup =
partitions.subList(i, maxEndPartitionIndexes.get(i) + 1);
group.partitions().append(JavaConversions.asScalaBuffer(partitionsInGroup));
groups[i] = group;
}
return groups;
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:RangePartitionCoalescer.java
示例9: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Iterator<double[]> compute(final Partition partition, final TaskContext context) {
ProgrammingError.throwIfNull(partition, context);
if (partition instanceof Partition2D) {
return this.compute((Partition2D) partition, context);
} else {
throw new IllegalArgumentException();
}
}
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:10,代码来源:PrimitiveBlockMatrixRDD.java
示例10: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Iterator<MatrixStore<N>> compute(final Partition partition, final TaskContext context) {
ProgrammingError.throwIfNull(partition, context);
if (partition instanceof Partition2D) {
return this.compute((Partition2D) partition, context);
} else {
throw new IllegalArgumentException();
}
}
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:10,代码来源:OtherBlockMatrixRDD.java
示例11: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public scala.collection.Iterator<TReturn> compute(Partition split, TaskContext context) {
String regionEdgesFamilyPath = this.regionsPaths.get(split.index());
log.info("Running Mizo on region #{} located at: {}", split.index(), regionEdgesFamilyPath);
return createRegionIterator(createRegionRelationsIterator(regionEdgesFamilyPath));
}
开发者ID:imri,项目名称:mizo,代码行数:8,代码来源:MizoRDD.java
示例12: getPartitions
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Partition[] getPartitions() {
return Iterators.toArray(IntStream
.range(0, this.regionsPaths.size())
.mapToObj(i -> (Partition) () -> i)
.iterator(), Partition.class);
}
开发者ID:imri,项目名称:mizo,代码行数:8,代码来源:MizoRDD.java
示例13: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public scala.collection.Iterator<WindowedValue<T>> compute(final Partition split,
final TaskContext context) {
final MetricsContainer metricsContainer = metricsAccum.localValue().getContainer(stepName);
@SuppressWarnings("unchecked")
final BoundedSource.BoundedReader<T> reader = createReader((SourcePartition<T>) split);
final Iterator<WindowedValue<T>> readerIterator =
new ReaderToIteratorAdapter<>(metricsContainer, reader);
return new InterruptibleIterator<>(context, JavaConversions.asScalaIterator(readerIterator));
}
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:SourceRDD.java
示例14: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public scala.collection.Iterator<Map.Entry<Key, Value>> compute(final Partition split, final TaskContext context) {
final ByteArrayInputStream bais = new ByteArrayInputStream(serialisedConfiguration);
final Configuration configuration = new Configuration();
try {
configuration.readFields(new DataInputStream(bais));
bais.close();
} catch (final IOException e) {
throw new RuntimeException("IOException deserialising Configuration from byte array", e);
}
return new InterruptibleIterator<>(context,
JavaConversions.asScalaIterator(new RFileReaderIterator(split, context, configuration, auths)));
}
开发者ID:gchq,项目名称:Gaffer,代码行数:14,代码来源:RFileReaderRDD.java
示例15: RFileReaderIterator
import org.apache.spark.Partition; //导入依赖的package包/类
public RFileReaderIterator(final Partition partition,
final TaskContext taskContext,
final Configuration configuration,
final Set<String> auths) {
this.partition = partition;
this.taskContext = taskContext;
this.configuration = configuration;
this.auths = auths;
try {
init();
} catch (final IOException e) {
throw new RuntimeException("IOException initialising RFileReaderIterator", e);
}
}
开发者ID:gchq,项目名称:Gaffer,代码行数:15,代码来源:RFileReaderIterator.java
示例16: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Iterator<IndexedContent> compute(Partition split, TaskContext context) {
try {
Path path = new Path(partitions[split.index()].getPath());
java.util.Iterator<Content> iterator = new ContentIterator(path, NutchConfiguration.create(), contentTypeFilter);
return new IndexedContentIterator(iterator);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
开发者ID:thammegowda,项目名称:autoextractor,代码行数:12,代码来源:IndexedNutchContentRDD.java
示例17: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Iterator<Content> compute(Partition split, TaskContext context) {
try {
Path path = new Path(partitions[split.index()].getPath());
return new ContentIterator(path, NutchConfiguration.create(), contentTypeFilter);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
开发者ID:thammegowda,项目名称:autoextractor,代码行数:11,代码来源:NutchContentRDD.java
示例18: getPartitions
import org.apache.spark.Partition; //导入依赖的package包/类
protected Partition[] getPartitions(GetPartitionsAction<T> getPartitionsAction) {
if (extractor == null) {
this.initExtractor(getPartitionsAction.getConfig());
}
return extractor.getPartitions(getPartitionsAction.getConfig());
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:9,代码来源:ExtractorServerHandler.java
示例19: getPreferredLocations
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Seq<String> getPreferredLocations(Partition split) {
initExtractorClient();
List<String> locations = extractorClient.getPreferredLocations(split);
if (locations == null || locations.isEmpty()) {
return super.getPreferredLocations(split);
}
return asScalaBuffer(locations);
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:13,代码来源:DeepRDD.java
示例20: compute
import org.apache.spark.Partition; //导入依赖的package包/类
@Override
public Iterator<T> compute(Partition split, TaskContext context) {
initExtractorClient();
extractorClient.initIterator(split, config.getValue());
context.addTaskCompletionListener(new AbstractFunction1<TaskContext, BoxedUnit>() {
@Override
public BoxedUnit apply(TaskContext v1) {
extractorClient.close();
return null;
}
});
java.util.Iterator<T> iterator = new java.util.Iterator<T>() {
@Override
public boolean hasNext() {
return extractorClient.hasNext();
}
@Override
public T next() {
return extractorClient.next();
}
@Override
public void remove() {
throw new DeepIOException(
"Method not implemented (and won't be implemented anytime soon!!!)");
}
};
return new InterruptibleIterator<>(context, asScalaIterator(iterator));
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:39,代码来源:DeepRDD.java
注:本文中的org.apache.spark.Partition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论