Beispiel #1
0
  protected void compactBucket(Bucket bucket) {
    LongsArray singles = bucket.singles;
    Long2ObjectOpenHashMap<LongsArray> dupes = bucket.dupes;
    long[] a = singles.a;
    int n = singles.n;

    Long2ObjectOpenHashMap<LongsArray> dupesNew = new Long2ObjectOpenHashMap<LongsArray>();
    dupesNew.defaultReturnValue(null);
    for (int i = 0; i < n; i += 2) {
      long v1 = a[i];
      long v2 = a[i + 1];
      long xyKey = xyToKey(x(v1, v2), y(v1, v2));

      LongsArray vs = dupesNew.get(xyKey);
      if (vs == null) {
        vs = new LongsArray(new long[16], 0);
        dupesNew.put(xyKey, vs);
      }
      vs.append(a, i, i + 2);
    }

    singles.n = 0;
    int dupeThreshold = 2 * max(2, (int) (0.1 * maxBucketSize));
    for (Entry<LongsArray> en : dupesNew.long2ObjectEntrySet()) {
      LongsArray vs = en.getValue();
      if (vs.n >= dupeThreshold) {
        long xyKey = en.getLongKey();
        dupes.put(xyKey, vs);
      } else {
        singles.append(vs);
      }
    }
  }
Beispiel #2
0
  protected void compactBucket(Bucket bucket) {
    IntsArray singles = bucket.singles;
    Long2ObjectOpenHashMap<IntsArray> dupes = bucket.dupes;
    int[] a = singles.a;
    int n = singles.n;

    Long2ObjectOpenHashMap<IntsArray> dupesNew = new Long2ObjectOpenHashMap<IntsArray>();
    dupesNew.defaultReturnValue(null);
    for (int i = 0; i < n; i++) {
      int v = a[i];
      long xyKey = xyToKey(x(v), y(v));

      IntsArray vs = dupesNew.get(xyKey);
      if (vs == null) {
        vs = new IntsArray(new int[8], 0);
        dupesNew.put(xyKey, vs);
      }
      vs.append(v);
    }

    singles.n = 0;
    int dupeThreshold = max(2, (int) (0.1 * maxBucketSize));
    for (Entry<IntsArray> en : dupesNew.long2ObjectEntrySet()) {
      IntsArray vs = en.getValue();
      if (vs.n >= dupeThreshold) {
        long xyKey = en.getLongKey();
        dupes.put(xyKey, vs);
      } else {
        singles.append(vs);
      }
    }
  }