コード例 #1
0
 public long getTotalSize(Host catalog_host) {
   long total = 0;
   for (SiteEntry site : this.host_site_xref.get(catalog_host)) {
     total += site.getEstimatedSize();
   } // FOR
   return (total);
 }
コード例 #2
0
  public String toString() {
    StringBuilder buffer = new StringBuilder();

    buffer.append("Hosts:     ").append(this.getHosts().size()).append("\n");
    buffer.append("Sites:     ").append(this.sites.size()).append("\n");
    buffer.append("Fragments: ").append(this.fragments.size()).append("\n");

    SortedSet<String> hosts = new TreeSet<String>();
    hosts.addAll(this.getHosts());

    for (String host_key : hosts) {
      buffer.append("\nHost ").append(CatalogKey.getNameFromKey(host_key)).append("\n");
      for (SiteEntry site : this.host_site_xref.get(host_key)) {
        buffer.append(SPACER).append("Site ").append(site.getId()).append("\n");
        for (FragmentEntry fragment : site.getFragments()) {
          buffer
              .append(SPACER)
              .append(SPACER)
              .append("Fragment ")
              .append(fragment)
              .append(" Size=")
              .append(fragment.getEstimatedSize())
              .append(" Heat=")
              .append(fragment.getEstimatedHeat())
              .append("\n");
        } // FOR
      } // FOR
      buffer.append("--------------------");
    } // FOR
    return (buffer.toString());
  }
コード例 #3
0
  /**
   * Merge the source SiteEntry into the target SiteEntry
   *
   * @param source
   * @param target
   */
  public void merge(SiteEntry source, SiteEntry target) {
    // Copy over all the fragments
    for (FragmentEntry fragment : source.getFragments()) {
      this.assign(target, fragment);
    } // FOR

    // Remove all references to the source SiteEntry
    this.site_id_xref.remove(source.getId());
    this.host_site_xref.get(source.getHostKey()).remove(source);
  }
コード例 #4
0
 /**
  * Assign the SiteEntry to a particular Host
  *
  * @param catalog_host
  * @param site
  */
 public void assign(Host catalog_host, SiteEntry site) {
   assert (catalog_host != null);
   assert (site != null);
   if (site.getHostKey() != null) {
     this.host_site_xref.get(site.getHostKey()).remove(site);
   }
   String host_key = CatalogKey.createKey(catalog_host);
   site.setHostKey(host_key);
   if (!this.host_site_xref.containsKey(host_key)) {
     this.host_site_xref.put(host_key, new TreeSet<SiteEntry>());
   }
   this.host_site_xref.get(host_key).add(site);
   this.site_id_xref.put(site.getId(), site);
   this.sites.add(site);
 }
コード例 #5
0
 /**
  * Assign the FragmentEntry to a particular SiteEntry
  *
  * @param site
  * @param fragment
  */
 public void assign(SiteEntry site, FragmentEntry fragment) {
   assert (site != null);
   assert (fragment != null);
   site.add(fragment);
   this.fragment_site_xref.put(fragment, site);
   this.fragments.add(fragment);
 }
コード例 #6
0
 public void apply(Database catalog_db, WorkloadStatistics stats, AbstractHasher hasher) {
   //
   // We need to estimate how big each partition is
   //
   MemoryEstimator estimator = new MemoryEstimator(stats, hasher);
   for (SiteEntry site : this.sites) {
     long site_size = 0l;
     for (FragmentEntry fragment : site.getFragments()) {
       Table catalog_tbl = fragment.getTable(catalog_db);
       Column partition_col = catalog_tbl.getPartitioncolumn();
       long size = estimator.estimate(catalog_tbl, partition_col, fragment.getHashKey());
       site_size += size;
       fragment.setEstimatedSize(size);
     } // FOR
     site.setEstimatedSize(site_size);
   } // FOR
 }
コード例 #7
0
  public void initialize() {
    for (SiteEntry site : this.sites) {
      String host_key = site.getHostKey();
      if (!this.host_site_xref.containsKey(host_key)) {
        this.host_site_xref.put(host_key, new TreeSet<SiteEntry>());
      }
      this.host_site_xref.get(host_key).add(site);

      for (FragmentEntry fragment : site.getFragments()) {
        this.fragments.add(fragment);
        this.fragment_site_xref.put(fragment, site);

        String table_key = fragment.getTableKey();
        if (!this.table_fragment_xref.containsKey(table_key)) {
          this.table_fragment_xref.put(table_key, new HashSet<FragmentEntry>());
        }
        this.table_fragment_xref.get(table_key).add(fragment);
      } // FOR
    } // FOR
  }