spatialhadoop2.1源码阅读(一) shadoop脚本文件

1. bin/shadoop文件内容如下:

bin=`dirname "$0"`
bin=`cd "$bin" > /dev/null; pwd`
# Call Hadoop with the operations.Main as the main class
. "$bin"/hadoop edu.umn.cs.spatialHadoop.operations.Main $@


该文件调用了edu.umn.cs.spatialHadoop.operations.Main ,并传入参数

2.edu.umn.cs.spatialHadoop.operations.Main 类中主要实现了两部分

第一部分加载默认配置文件,调用hadoop 提供的Configuration类

代码如下:

 static {
    // Load configuration from files
    Configuration.addDefaultResource("spatial-default.xml");
    Configuration.addDefaultResource("spatial-site.xml");
  }
第二部分为main函数,主要代码如下

 ProgramDriver pgd = new ProgramDriver();
    try {
      
      pgd.addClass("rangequery", RangeQuery.class,
          "Finds all objects in the query range given by a rectangle");

      pgd.addClass("knn", KNN.class,
          "Finds the k nearest neighbor in a file to a point");

      pgd.addClass("dj", DistributedJoin.class,
          "Computes the spatial join between two input files using the " +
          "distributed join algorithm");
      
      pgd.addClass("sjmr", SJMR.class,
          "Computes the spatial join between two input files using the " +
          "SJMR algorithm");
      
      pgd.addClass("index", Repartition.class,
          "Builds an index on an input file");
      
      pgd.addClass("mbr", FileMBR.class,
          "Finds the minimal bounding rectangle of an input file");
      
      pgd.addClass("readfile", ReadFile.class,
          "Retrieve some information about the global index of a file");

      pgd.addClass("sample", Sampler.class,
          "Reads a random sample from the input file");

      pgd.addClass("generate", RandomSpatialGenerator.class,
          "Generates a random file containing spatial data");

      pgd.addClass("union", Union.class,
          "Computes the union of input shapes");

      pgd.addClass("plot", Plot.class,
          "Plots a file to an image");

      pgd.addClass("plotp", PlotPyramid.class,
          "Plots a file to a set of images used with Google-Maps-like engine");

      pgd.addClass("hdfplot", HDFPlot.class,
          "Plots NASA datasets in the spatiotemporal range provided by user");
      
      pgd.addClass("hdfx", HDFToText.class,
          "Extracts data from a set of HDF files to text files");

      pgd.addClass("skyline", Skyline.class,
          "Computes the skyline of an input set of points");
      
      pgd.addClass("convexhull", ConvexHull.class,
          "Computes the convex hull of an input set of points");

      pgd.addClass("farthestpair", FarthestPair.class,
          "Computes the farthest pair of point of an input set of points");

      pgd.addClass("closestpair", ClosestPair.class,
          "Computes the closest pair of point of an input set of points");

      pgd.driver(args);


首先实例化ProgramDriver对象,该类由hadoop common提供,主要提供了以反射的方式调用注册在对象中的类,例如

pgd.addClass("generate", RandomSpatialGenerator.class,
          "Generates a random file containing spatial data");
ProgramDriver对象中注册generate对象对应的处理类RandomSpatialGenerator.class。

最后 pgd.driver(args);根据参数调用某处理类的main函数。(所有的处理类均实现了main函数)。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值