當前位置: 首頁>>代碼示例>>Java>>正文


Java StorageLevel.MEMORY_ONLY屬性代碼示例

本文整理匯總了Java中org.apache.spark.storage.StorageLevel.MEMORY_ONLY屬性的典型用法代碼示例。如果您正苦於以下問題:Java StorageLevel.MEMORY_ONLY屬性的具體用法?Java StorageLevel.MEMORY_ONLY怎麽用?Java StorageLevel.MEMORY_ONLY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.spark.storage.StorageLevel的用法示例。


在下文中一共展示了StorageLevel.MEMORY_ONLY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildHeatMap

/**
 * Builds the heat map.
 *
 * @param outputPath the output path
 * @return true, if successful
 */
public static boolean buildHeatMap(String outputPath)
{
	try{
		RectangleRDD spatialRDD = new RectangleRDD(sparkContext, RectangleInputLocation, RectangleSplitter, false, RectangleNumPartitions, StorageLevel.MEMORY_ONLY());
		HeatMap visualizationOperator = new HeatMap(1000,600,USMainLandBoundary,false,2);
		visualizationOperator.Visualize(sparkContext, spatialRDD);
		GeoSparkVizImageGenerator imageGenerator = new GeoSparkVizImageGenerator();
		imageGenerator.SaveRasterImageAsLocalFile(visualizationOperator.rasterImage, outputPath,ImageType.PNG);
	}
	catch(Exception e)
	{
		e.printStackTrace();
		return false;
	}
	return true;		
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:22,代碼來源:Example.java

示例2: testPolygonDistanceJoinWithCRSTransformation

/**
 * Test polygon distance join with CRS transformation.
 *
 * @throws Exception the exception
 */
@Test
public void testPolygonDistanceJoinWithCRSTransformation() throws Exception{
    PolygonRDD queryRDD = new PolygonRDD(sc, InputLocationQueryPolygon, splitter, true, numPartitions, StorageLevel.MEMORY_ONLY(), "epsg:4326", "epsg:3857");
	CircleRDD windowRDD = new CircleRDD(queryRDD,0.1);
	PolygonRDD objectRDD = new PolygonRDD(sc, InputLocationQueryPolygon, splitter, true, numPartitions, StorageLevel.MEMORY_ONLY(), "epsg:4326", "epsg:3857");
	objectRDD.rawSpatialRDD.repartition(4);
	objectRDD.spatialPartitioning(GridType.RTREE);
	objectRDD.buildIndex(IndexType.RTREE,true);
	windowRDD.spatialPartitioning(objectRDD.grids);

	List<Tuple2<Geometry, HashSet<Polygon>>> results = JoinQuery.DistanceJoinQuery(objectRDD, windowRDD, true,false).collect();
	assertEquals(5467, results.size());

	for (Tuple2<Geometry, HashSet<Polygon>> tuple : results) {
	    for (Polygon polygon : tuple._2()) {
	        assertTrue(new Circle(tuple._1(), 0.1).covers(polygon));
        }
    }
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:24,代碼來源:CRSTransformationTest.java

示例3: testSaveAsDistributedFile

/**
 * Test save as distributed file.
 *
 * @throws Exception the exception
 */
@Test
public void testSaveAsDistributedFile() throws Exception {
	PointRDD spatialRDD = new PointRDD(sparkContext, PointInputLocation, PointOffset, PointSplitter, false, PointNumPartitions, StorageLevel.MEMORY_ONLY());
	ScatterPlot visualizationOperator = new ScatterPlot(1000,600,USMainLandBoundary,false,2,2,true,false);
	visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.GREEN, true);
	visualizationOperator.Visualize(sparkContext, spatialRDD);
	ImageGenerator imageGenerator = new  ImageGenerator();
	
       String scatterPlotOutputPath = System.getProperty("user.dir") + "/target/scatterplot/";

	imageGenerator.SaveRasterImageAsLocalFile(visualizationOperator.distributedRasterImage, scatterPlotOutputPath+"PointRDD-parallel-raster",ImageType.PNG);
	
	visualizationOperator = new ScatterPlot(1000,600,USMainLandBoundary,false,-1,-1,true,true);
	visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.GREEN, true);
	visualizationOperator.Visualize(sparkContext, spatialRDD);
	imageGenerator = new  ImageGenerator();
	imageGenerator.SaveVectorImageAsLocalFile(visualizationOperator.distributedVectorImage, scatterPlotOutputPath+"PointRDD-parallel-vector",ImageType.SVG);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:23,代碼來源:ScatterplotTest.java

示例4: testRTreeSpatialPartitioing

/**
 * Test R tree spatial partitioing.
 *
 * @throws Exception the exception
 */
/*
 *  This test case test whether the STR-Tree grid can be build correctly.
 */
@Test
public void testRTreeSpatialPartitioing() throws Exception {
	LineStringRDD spatialRDD = new LineStringRDD(sc, InputLocation, splitter, true, 10,StorageLevel.MEMORY_ONLY());
    spatialRDD.spatialPartitioning(GridType.RTREE);
    for (Envelope d : spatialRDD.grids) {
    	//System.out.println("PointRDD spatial partitioning grids: "+d.grid);
    }
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:16,代碼來源:LineStringRDDTest.java

示例5: buildScatterPlot

/**
 * Builds the scatter plot.
 *
 * @param outputPath the output path
 * @return true, if successful
 */
public static boolean buildScatterPlot(String outputPath)
{
	try{
		PolygonRDD spatialRDD = new PolygonRDD(sparkContext, PolygonInputLocation, PolygonSplitter, false, PolygonNumPartitions, StorageLevel.MEMORY_ONLY());
		ScatterPlot visualizationOperator = new ScatterPlot(1000,600,USMainLandBoundary,false);
		visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.GREEN, true);
		visualizationOperator.Visualize(sparkContext, spatialRDD);
		GeoSparkVizImageGenerator imageGenerator = new GeoSparkVizImageGenerator();
		imageGenerator.SaveRasterImageAsLocalFile(visualizationOperator.rasterImage, outputPath, ImageType.PNG);
		
		visualizationOperator = new ScatterPlot(1000,600,USMainLandBoundary,false,-1,-1,false,true);
		visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.GREEN, true);
		visualizationOperator.Visualize(sparkContext, spatialRDD);
		imageGenerator = new GeoSparkVizImageGenerator();
		imageGenerator.SaveVectorImageAsLocalFile(visualizationOperator.vectorImage, outputPath,ImageType.SVG);
		
		visualizationOperator = new ScatterPlot(1000,600,USMainLandBoundary,false,-1,-1,true,true);
		visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.GREEN, true);
		visualizationOperator.Visualize(sparkContext, spatialRDD);
		imageGenerator = new GeoSparkVizImageGenerator();
		imageGenerator.SaveVectorImageAsLocalFile(visualizationOperator.distributedVectorImage, "file://"+outputPath+"-distributed",ImageType.SVG);
	}
	catch(Exception e)
	{
		e.printStackTrace();
		return false;
	}
	return true;
	
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:36,代碼來源:Example.java

示例6: buildChoroplethMap

/**
 * Builds the choropleth map.
 *
 * @param outputPath the output path
 * @return true, if successful
 */
public static boolean buildChoroplethMap(String outputPath)
{
	try{
		PointRDD spatialRDD = new PointRDD(sparkContext, PointInputLocation, PointOffset, PointSplitter, false, PointNumPartitions, StorageLevel.MEMORY_ONLY());
		PolygonRDD queryRDD = new PolygonRDD(sparkContext, PolygonInputLocation,  PolygonSplitter, false, PolygonNumPartitions, StorageLevel.MEMORY_ONLY());
		spatialRDD.spatialPartitioning(GridType.RTREE);
		queryRDD.spatialPartitioning(spatialRDD.grids);
  		spatialRDD.buildIndex(IndexType.RTREE,true);
		JavaPairRDD<Polygon,Long> joinResult = JoinQuery.SpatialJoinQueryCountByKey(spatialRDD,queryRDD,true,false);

		ChoroplethMap visualizationOperator = new ChoroplethMap(1000,600,USMainLandBoundary,false);
		visualizationOperator.CustomizeColor(255, 255, 255, 255, Color.RED, true);
		visualizationOperator.Visualize(sparkContext, joinResult);
		
		ScatterPlot frontImage = new ScatterPlot(1000,600,USMainLandBoundary,false);
		frontImage.CustomizeColor(0, 0, 0, 255, Color.GREEN, true);
		frontImage.Visualize(sparkContext, queryRDD);
		
		RasterOverlayOperator overlayOperator = new RasterOverlayOperator(visualizationOperator.rasterImage);
		overlayOperator.JoinImage(frontImage.rasterImage);
		
		GeoSparkVizImageGenerator imageGenerator = new GeoSparkVizImageGenerator();
		imageGenerator.SaveRasterImageAsLocalFile(overlayOperator.backRasterImage, outputPath,ImageType.PNG);
	}
	catch(Exception e)
	{
		e.printStackTrace();
		return false;
	}
	return true;		
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:37,代碼來源:Example.java

示例7: testRectangleRDDVisualization

/**
 * Test rectangle RDD visualization.
 *
 * @throws Exception the exception
 */
@Test
public void testRectangleRDDVisualization() throws Exception {
	RectangleRDD spatialRDD = new RectangleRDD(sparkContext, RectangleInputLocation, RectangleSplitter, false, RectangleNumPartitions, StorageLevel.MEMORY_ONLY());
	HeatMap visualizationOperator = new HeatMap(800,500,USMainLandBoundary,false,2, 4,4,false,true);
	visualizationOperator.Visualize(sparkContext, spatialRDD);
	
	ImageGenerator imageGenerator = new ImageGenerator();
	imageGenerator.SaveRasterImageAsLocalFile(visualizationOperator.distributedRasterImage, "./target/heatmap/RectangleRDD",ImageType.PNG, 0, 4, 4);
	ImageStitcher.stitchImagePartitionsFromLocalFile("./target/heatmap/RectangleRDD", 800, 500,0,4,4);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:15,代碼來源:HeatmapTest.java

示例8: testConstructor

/**
 * Test constructor.
 *
 * @throws Exception the exception
 */
/*
    This test case will load a sample data file and
 */
@Test
public void testConstructor() throws Exception {
    LineStringRDD spatialRDD = new LineStringRDD(sc, InputLocation, splitter, true, numPartitions,StorageLevel.MEMORY_ONLY());
    assertEquals(inputCount, spatialRDD.approximateTotalCount);
    assertEquals(inputBoundary, spatialRDD.boundaryEnvelope);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:14,代碼來源:LineStringRDDTest.java

示例9: testConstructor

/**
 * Test constructor.
 *
 * @throws Exception the exception
 */
/*
    This test case will load a sample data file and
 */
@Test
public void testConstructor() throws Exception {
    PolygonRDD spatialRDD = new PolygonRDD(sc, InputLocation, splitter, true, numPartitions,StorageLevel.MEMORY_ONLY());
    assertEquals(inputCount, spatialRDD.approximateTotalCount);
    assertEquals(inputBoundary, spatialRDD.boundaryEnvelope);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:14,代碼來源:PolygonRDDTest.java

示例10: testInsideLineStringJoinCorrectness

/**
 * Test inside line string join correctness.
 *
 * @throws Exception the exception
 */
@Test
public void testInsideLineStringJoinCorrectness() throws Exception{
    PolygonRDD windowRDD = new PolygonRDD(sc.parallelize(this.testPolygonWindowSet),StorageLevel.MEMORY_ONLY());
    LineStringRDD objectRDD = new LineStringRDD(sc.parallelize(this.testInsideLineStringSet),StorageLevel.MEMORY_ONLY());
    prepareRDDs(objectRDD, windowRDD);

    List<Tuple2<Polygon,HashSet<LineString>>> result = JoinQuery.SpatialJoinQuery(objectRDD, windowRDD, true,false).collect();
    verifyJoinResults(result);

    List<Tuple2<Polygon,HashSet<LineString>>> resultNoIndex = JoinQuery.SpatialJoinQuery(objectRDD, windowRDD, false,false).collect();
    verifyJoinResults(resultNoIndex);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:17,代碼來源:JoinQueryCorrectnessChecker.java

示例11: testConstructor

/**
 * Test constructor.
 *
 * @throws Exception the exception
 */
/*
    This test case will load a sample data file and
 */
@Test
public void testConstructor() throws Exception {
    RectangleRDD spatialRDD = new RectangleRDD(sc, InputLocation, offset, splitter, true, numPartitions,StorageLevel.MEMORY_ONLY());
    assertEquals(inputCount, spatialRDD.approximateTotalCount);
    assertEquals(inputBoundary, spatialRDD.boundaryEnvelope);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:14,代碼來源:RectangleRDDTest.java

示例12: testVoronoiSpatialPartitioing

/**
 * Test voronoi spatial partitioing.
 *
 * @throws Exception the exception
 */
/*
 *  This test case test whether the Voronoi grid can be build correctly.
 */
@Test
public void testVoronoiSpatialPartitioing() throws Exception {
	LineStringRDD spatialRDD = new LineStringRDD(sc, InputLocation, splitter, true, 10,StorageLevel.MEMORY_ONLY());
    spatialRDD.spatialPartitioning(GridType.VORONOI);
    for (Envelope d : spatialRDD.grids) {
    	//System.out.println("PointRDD spatial partitioning grids: "+d.grid);
    }
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:16,代碼來源:LineStringRDDTest.java

示例13: testRTreeSpatialPartitioing

/**
 * Test R tree spatial partitioing.
 *
 * @throws Exception the exception
 */
/*
 *  This test case test whether the STR-Tree grid can be build correctly.
 */
@Test
public void testRTreeSpatialPartitioing() throws Exception {
	PolygonRDD spatialRDD = new PolygonRDD(sc, InputLocation, splitter, true, 10,StorageLevel.MEMORY_ONLY());
    spatialRDD.spatialPartitioning(GridType.RTREE);
    for (Envelope d : spatialRDD.grids) {
    	//System.out.println("PointRDD spatial partitioning grids: "+d.grid);
    }

}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:17,代碼來源:PolygonRDDTest.java

示例14: testInsidePolygonDistanceJoinCorrectness

/**
 * Test inside polygon distance join correctness.
 *
 * @throws Exception the exception
 */
@Test
public void testInsidePolygonDistanceJoinCorrectness() throws Exception{
    PolygonRDD centerGeometryRDD = new PolygonRDD(sc.parallelize(this.testPolygonWindowSet),StorageLevel.MEMORY_ONLY());
    CircleRDD windowRDD = new CircleRDD(centerGeometryRDD,0.1);
    PolygonRDD objectRDD = new PolygonRDD(sc.parallelize(this.testInsidePolygonSet),StorageLevel.MEMORY_ONLY());
    prepareRDDs(objectRDD, windowRDD);

    List<Tuple2<Geometry, HashSet<Polygon>>> result = JoinQuery.DistanceJoinQuery(objectRDD, windowRDD, true,false).collect();
    verifyJoinResults(result);

    List<Tuple2<Geometry, HashSet<Polygon>>> resultNoIndex = JoinQuery.DistanceJoinQuery(objectRDD, windowRDD, false,false).collect();
    verifyJoinResults(resultNoIndex);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:18,代碼來源:JoinQueryCorrectnessChecker.java

示例15: testRectangleRDDVisualizationWithTiles

/**
 * Test rectangle RDD visualization with tiles.
 *
 * @throws Exception the exception
 */
@Test
public void testRectangleRDDVisualizationWithTiles() throws Exception {
	RectangleRDD spatialRDD = new RectangleRDD(sparkContext, RectangleInputLocation, RectangleSplitter, false, RectangleNumPartitions, StorageLevel.MEMORY_ONLY());
	HeatMap visualizationOperator = new HeatMap(resolutionX,resolutionY,USMainLandBoundary,false,2,partitionX,partitionY,true,true);
	visualizationOperator.Visualize(sparkContext, spatialRDD);

	ImageGenerator imageGenerator = new  ImageGenerator();
	imageGenerator.SaveRasterImageAsLocalFile(visualizationOperator.distributedRasterImage, "./target/parallelvisualization/RectangleRDDWithTiles",ImageType.PNG,0,partitionX, partitionY);
       ImageStitcher.stitchImagePartitionsFromLocalFile("./target/parallelvisualization/RectangleRDDWithTiles", resolutionX,resolutionY,0,partitionX, partitionY);
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:15,代碼來源:ParallelVisualizationTest.java


注:本文中的org.apache.spark.storage.StorageLevel.MEMORY_ONLY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。