Esempio n. 1
0
  @SuppressWarnings("unchecked")
  private static String compare(List<Slicer> slicer, Collection<SDGNode> criteria) {
    int[] size = new int[slicer.size()];
    long[] time = new long[slicer.size()];
    Collection<SDGNode>[] slices = new Collection[slicer.size()];
    int s = 0;
    int diff = Integer.MAX_VALUE;

    int ctr = 0;

    for (SDGNode crit : criteria) {
      ctr++;
      if ((ctr % 1) != 0) continue;

      for (int i = 0; i < slicer.size(); i++) {
        long tmp = System.currentTimeMillis();
        slices[i] = slicer.get(i).slice(Collections.singleton(crit));
        time[i] += System.currentTimeMillis() - tmp;
        size[i] += slices[i].size();

        if (i == 1
            && slices[0].size() != slices[1].size()
            && Math.abs(slices[0].size() - slices[1].size()) < diff) {
          diff = Math.abs(slices[0].size() - slices[1].size());
          s = crit.getId();
        }
      }
      //            System.out.println("************************************** ");
      if (ctr % 10 == 0) {
        System.out.print(".");
      }
      if (ctr % 100 == 0) {
        System.out.print(ctr);
      }
      if (ctr % 1000 == 0) {
        System.out.println();
      }
    }

    String str = "\n";
    for (int i = 0; i < slicer.size(); i++) {
      str +=
          slicer.get(i).getClass().getName()
              + ": "
              + size[i]
              + "              time:"
              + time[i]
              + "\n";
    }

    str += s + ": " + diff + "\n";

    return str;
  }
Esempio n. 2
0
 public int hashCode() {
   return context.hashCode() | (node.getId() << 16);
 }