关闭

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

标签: spatialhadoop
564人阅读 评论(0) 收藏 举报
分类:

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
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:5642次
    • 积分:218
    • 等级:
    • 排名:千里之外
    • 原创:17篇
    • 转载:4篇
    • 译文:0篇
    • 评论:0条
    文章分类