@Test public void testCheckStandalone1() { HistogramSegment segment = new HistogramSegment("g8".getBytes(), 0); segment.merge((short)11); assertFalse(segment.duplicate); assertFalse(segment.leftUpdated); assertTrue(segment.centerAdded); assertSegEquals((short)11, (short)11,(short)1, segment.pps.get(0)); assertFalse(segment.rightUpdated); assertFalse(segment.rightDeleted); }
public void merge(int dtime1) { this.dtime = dtime1; for (int i = 0; i < pps.size(); i++) { HistogramSegment.SegRecord r = pps.get(i); if (dtime >= r.dstart) { if (dtime <= r.dstop) { duplicate = true; return; } left = r; leftIndex = i; continue; } if (dtime < r.dstart) { rightIndex = i; right = r; break; } } if (leftIndex != -1) { checkMergeLeft(); } if (rightIndex != -1) { checkMergeRight(); } if (mergeLeft && mergeRight) { selectBestMerge(); } if (mergeLeft && mergeRight) { pps.set(leftIndex, new SegRecord(left.dstart, right.dstop, (short) (left.num + right.num + 1))); pps.remove(rightIndex); leftUpdated = true; rightDeleted = true; } else if (mergeLeft) { left.dstop = dtime; left.num++; leftUpdated = true; } else if (mergeRight) { right.dstart = dtime; right.num++; rightUpdated = true; } else { HistogramSegment.SegRecord center = new SegRecord(dtime, dtime, (short) 1); if (leftIndex != -1) { pps.add(leftIndex + 1, center); } else if (rightIndex != -1) { pps.add(rightIndex, center); } else { pps.add(center); } centerAdded = true; } }
HistogramSegment { public void merge(int dtime1) { this.dtime = dtime1; for (int i = 0; i < pps.size(); i++) { HistogramSegment.SegRecord r = pps.get(i); if (dtime >= r.dstart) { if (dtime <= r.dstop) { duplicate = true; return; } left = r; leftIndex = i; continue; } if (dtime < r.dstart) { rightIndex = i; right = r; break; } } if (leftIndex != -1) { checkMergeLeft(); } if (rightIndex != -1) { checkMergeRight(); } if (mergeLeft && mergeRight) { selectBestMerge(); } if (mergeLeft && mergeRight) { pps.set(leftIndex, new SegRecord(left.dstart, right.dstop, (short) (left.num + right.num + 1))); pps.remove(rightIndex); leftUpdated = true; rightDeleted = true; } else if (mergeLeft) { left.dstop = dtime; left.num++; leftUpdated = true; } else if (mergeRight) { right.dstart = dtime; right.num++; rightUpdated = true; } else { HistogramSegment.SegRecord center = new SegRecord(dtime, dtime, (short) 1); if (leftIndex != -1) { pps.add(leftIndex + 1, center); } else if (rightIndex != -1) { pps.add(rightIndex, center); } else { pps.add(center); } centerAdded = true; } } }
HistogramSegment { public void merge(int dtime1) { this.dtime = dtime1; for (int i = 0; i < pps.size(); i++) { HistogramSegment.SegRecord r = pps.get(i); if (dtime >= r.dstart) { if (dtime <= r.dstop) { duplicate = true; return; } left = r; leftIndex = i; continue; } if (dtime < r.dstart) { rightIndex = i; right = r; break; } } if (leftIndex != -1) { checkMergeLeft(); } if (rightIndex != -1) { checkMergeRight(); } if (mergeLeft && mergeRight) { selectBestMerge(); } if (mergeLeft && mergeRight) { pps.set(leftIndex, new SegRecord(left.dstart, right.dstop, (short) (left.num + right.num + 1))); pps.remove(rightIndex); leftUpdated = true; rightDeleted = true; } else if (mergeLeft) { left.dstop = dtime; left.num++; leftUpdated = true; } else if (mergeRight) { right.dstart = dtime; right.num++; rightUpdated = true; } else { HistogramSegment.SegRecord center = new SegRecord(dtime, dtime, (short) 1); if (leftIndex != -1) { pps.add(leftIndex + 1, center); } else if (rightIndex != -1) { pps.add(rightIndex, center); } else { pps.add(center); } centerAdded = true; } } HistogramSegment(byte[] columnv, long sstart);  HistogramSegment(byte[] columnv, long sstart, byte[] val);  HistogramSegment(byte[] key, byte[] val); }
HistogramSegment { public void merge(int dtime1) { this.dtime = dtime1; for (int i = 0; i < pps.size(); i++) { HistogramSegment.SegRecord r = pps.get(i); if (dtime >= r.dstart) { if (dtime <= r.dstop) { duplicate = true; return; } left = r; leftIndex = i; continue; } if (dtime < r.dstart) { rightIndex = i; right = r; break; } } if (leftIndex != -1) { checkMergeLeft(); } if (rightIndex != -1) { checkMergeRight(); } if (mergeLeft && mergeRight) { selectBestMerge(); } if (mergeLeft && mergeRight) { pps.set(leftIndex, new SegRecord(left.dstart, right.dstop, (short) (left.num + right.num + 1))); pps.remove(rightIndex); leftUpdated = true; rightDeleted = true; } else if (mergeLeft) { left.dstop = dtime; left.num++; leftUpdated = true; } else if (mergeRight) { right.dstart = dtime; right.num++; rightUpdated = true; } else { HistogramSegment.SegRecord center = new SegRecord(dtime, dtime, (short) 1); if (leftIndex != -1) { pps.add(leftIndex + 1, center); } else if (rightIndex != -1) { pps.add(rightIndex, center); } else { pps.add(center); } centerAdded = true; } } HistogramSegment(byte[] columnv, long sstart);  HistogramSegment(byte[] columnv, long sstart, byte[] val);  HistogramSegment(byte[] key, byte[] val); static long getSstart(byte[] key); byte[] key(); static byte[] key(long sstart, byte[] columnv); byte[] val(); static long segmentStart(long instant); void merge(int dtime1); @Override String toString(); }
HistogramSegment { public void merge(int dtime1) { this.dtime = dtime1; for (int i = 0; i < pps.size(); i++) { HistogramSegment.SegRecord r = pps.get(i); if (dtime >= r.dstart) { if (dtime <= r.dstop) { duplicate = true; return; } left = r; leftIndex = i; continue; } if (dtime < r.dstart) { rightIndex = i; right = r; break; } } if (leftIndex != -1) { checkMergeLeft(); } if (rightIndex != -1) { checkMergeRight(); } if (mergeLeft && mergeRight) { selectBestMerge(); } if (mergeLeft && mergeRight) { pps.set(leftIndex, new SegRecord(left.dstart, right.dstop, (short) (left.num + right.num + 1))); pps.remove(rightIndex); leftUpdated = true; rightDeleted = true; } else if (mergeLeft) { left.dstop = dtime; left.num++; leftUpdated = true; } else if (mergeRight) { right.dstart = dtime; right.num++; rightUpdated = true; } else { HistogramSegment.SegRecord center = new SegRecord(dtime, dtime, (short) 1); if (leftIndex != -1) { pps.add(leftIndex + 1, center); } else if (rightIndex != -1) { pps.add(rightIndex, center); } else { pps.add(center); } centerAdded = true; } } HistogramSegment(byte[] columnv, long sstart);  HistogramSegment(byte[] columnv, long sstart, byte[] val);  HistogramSegment(byte[] key, byte[] val); static long getSstart(byte[] key); byte[] key(); static byte[] key(long sstart, byte[] columnv); byte[] val(); static long segmentStart(long instant); void merge(int dtime1); @Override String toString(); static final long GROUPING_FACTOR; }