hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [12/51] [partial] hbase-site git commit: Published site at a87d9560fcf4803bdd7a01b6e4ec21435d4e11b9.
Date Mon, 25 Jan 2016 17:03:56 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f8d6f420/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
index f6c7b80..1c21359 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
@@ -422,180 +422,182 @@
 <span class="sourceLineNo">414</span>    node.updateState(procId, isDeleted);<a name="line.414"></a>
 <span class="sourceLineNo">415</span>  }<a name="line.415"></a>
 <span class="sourceLineNo">416</span><a name="line.416"></a>
-<span class="sourceLineNo">417</span>  public void clear() {<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    this.map.clear();<a name="line.418"></a>
-<span class="sourceLineNo">419</span>    resetUpdates();<a name="line.419"></a>
-<span class="sourceLineNo">420</span>  }<a name="line.420"></a>
-<span class="sourceLineNo">421</span><a name="line.421"></a>
-<span class="sourceLineNo">422</span>  public DeleteState isDeleted(long procId) {<a name="line.422"></a>
-<span class="sourceLineNo">423</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.floorEntry(procId);<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    if (entry != null &amp;&amp; entry.getValue().contains(procId)) {<a name="line.424"></a>
-<span class="sourceLineNo">425</span>      BitSetNode node = entry.getValue();<a name="line.425"></a>
-<span class="sourceLineNo">426</span>      DeleteState state = node.isDeleted(procId);<a name="line.426"></a>
-<span class="sourceLineNo">427</span>      return partial &amp;&amp; !node.isUpdated(procId) ? DeleteState.MAYBE : state;<a name="line.427"></a>
-<span class="sourceLineNo">428</span>    }<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    return partial ? DeleteState.MAYBE : DeleteState.YES;<a name="line.429"></a>
-<span class="sourceLineNo">430</span>  }<a name="line.430"></a>
-<span class="sourceLineNo">431</span><a name="line.431"></a>
-<span class="sourceLineNo">432</span>  public long getMinProcId() {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    // TODO: Cache?<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.firstEntry();<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    return entry == null ? 0 : entry.getValue().getMinProcId();<a name="line.435"></a>
-<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
-<span class="sourceLineNo">437</span><a name="line.437"></a>
-<span class="sourceLineNo">438</span>  public void setKeepDeletes(boolean keepDeletes) {<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    this.keepDeletes = keepDeletes;<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    if (!keepDeletes) {<a name="line.440"></a>
-<span class="sourceLineNo">441</span>      Iterator&lt;Map.Entry&lt;Long, BitSetNode&gt;&gt; it = map.entrySet().iterator();<a name="line.441"></a>
-<span class="sourceLineNo">442</span>      while (it.hasNext()) {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>        Map.Entry&lt;Long, BitSetNode&gt; entry = it.next();<a name="line.443"></a>
-<span class="sourceLineNo">444</span>        if (entry.getValue().isEmpty()) {<a name="line.444"></a>
-<span class="sourceLineNo">445</span>          it.remove();<a name="line.445"></a>
-<span class="sourceLineNo">446</span>        }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>      }<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    }<a name="line.448"></a>
-<span class="sourceLineNo">449</span>  }<a name="line.449"></a>
-<span class="sourceLineNo">450</span><a name="line.450"></a>
-<span class="sourceLineNo">451</span>  public void setPartialFlag(boolean isPartial) {<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    if (this.partial &amp;&amp; !isPartial) {<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.453"></a>
-<span class="sourceLineNo">454</span>        entry.getValue().unsetPartialFlag();<a name="line.454"></a>
-<span class="sourceLineNo">455</span>      }<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    }<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    this.partial = isPartial;<a name="line.457"></a>
-<span class="sourceLineNo">458</span>  }<a name="line.458"></a>
-<span class="sourceLineNo">459</span><a name="line.459"></a>
-<span class="sourceLineNo">460</span>  public boolean isEmpty() {<a name="line.460"></a>
-<span class="sourceLineNo">461</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>      if (entry.getValue().isEmpty() == false) {<a name="line.462"></a>
-<span class="sourceLineNo">463</span>        return false;<a name="line.463"></a>
-<span class="sourceLineNo">464</span>      }<a name="line.464"></a>
-<span class="sourceLineNo">465</span>    }<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    return true;<a name="line.466"></a>
-<span class="sourceLineNo">467</span>  }<a name="line.467"></a>
-<span class="sourceLineNo">468</span><a name="line.468"></a>
-<span class="sourceLineNo">469</span>  public boolean isUpdated() {<a name="line.469"></a>
-<span class="sourceLineNo">470</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.470"></a>
-<span class="sourceLineNo">471</span>      if (entry.getValue().isUpdated() == false) {<a name="line.471"></a>
-<span class="sourceLineNo">472</span>        return false;<a name="line.472"></a>
-<span class="sourceLineNo">473</span>      }<a name="line.473"></a>
-<span class="sourceLineNo">474</span>    }<a name="line.474"></a>
-<span class="sourceLineNo">475</span>    return true;<a name="line.475"></a>
-<span class="sourceLineNo">476</span>  }<a name="line.476"></a>
-<span class="sourceLineNo">477</span><a name="line.477"></a>
-<span class="sourceLineNo">478</span>  public boolean isTracking(long minId, long maxId) {<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    // TODO: we can make it more precise, instead of looking just at the block<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    return map.floorEntry(minId) != null || map.floorEntry(maxId) != null;<a name="line.480"></a>
-<span class="sourceLineNo">481</span>  }<a name="line.481"></a>
-<span class="sourceLineNo">482</span><a name="line.482"></a>
-<span class="sourceLineNo">483</span>  public void resetUpdates() {<a name="line.483"></a>
-<span class="sourceLineNo">484</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.484"></a>
-<span class="sourceLineNo">485</span>      entry.getValue().resetUpdates();<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    }<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    minUpdatedProcId = Long.MAX_VALUE;<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    maxUpdatedProcId = Long.MIN_VALUE;<a name="line.488"></a>
-<span class="sourceLineNo">489</span>  }<a name="line.489"></a>
-<span class="sourceLineNo">490</span><a name="line.490"></a>
-<span class="sourceLineNo">491</span>  public void undeleteAll() {<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.492"></a>
-<span class="sourceLineNo">493</span>      entry.getValue().undeleteAll();<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    }<a name="line.494"></a>
-<span class="sourceLineNo">495</span>  }<a name="line.495"></a>
-<span class="sourceLineNo">496</span><a name="line.496"></a>
-<span class="sourceLineNo">497</span>  private BitSetNode getOrCreateNode(final long procId) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>    // can procId fit in the left node?<a name="line.498"></a>
-<span class="sourceLineNo">499</span>    BitSetNode leftNode = null;<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    boolean leftCanGrow = false;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>    Map.Entry&lt;Long, BitSetNode&gt; leftEntry = map.floorEntry(procId);<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    if (leftEntry != null) {<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      leftNode = leftEntry.getValue();<a name="line.503"></a>
-<span class="sourceLineNo">504</span>      if (leftNode.contains(procId)) {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        return leftNode;<a name="line.505"></a>
-<span class="sourceLineNo">506</span>      }<a name="line.506"></a>
-<span class="sourceLineNo">507</span>      leftCanGrow = leftNode.canGrow(procId);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>    }<a name="line.508"></a>
-<span class="sourceLineNo">509</span><a name="line.509"></a>
-<span class="sourceLineNo">510</span>    BitSetNode rightNode = null;<a name="line.510"></a>
-<span class="sourceLineNo">511</span>    boolean rightCanGrow = false;<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    Map.Entry&lt;Long, BitSetNode&gt; rightEntry = map.ceilingEntry(procId);<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    if (rightEntry != null) {<a name="line.513"></a>
-<span class="sourceLineNo">514</span>      rightNode = rightEntry.getValue();<a name="line.514"></a>
-<span class="sourceLineNo">515</span>      rightCanGrow = rightNode.canGrow(procId);<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      if (leftNode != null) {<a name="line.516"></a>
-<span class="sourceLineNo">517</span>        if (leftNode.canMerge(rightNode)) {<a name="line.517"></a>
-<span class="sourceLineNo">518</span>          // merge left and right node<a name="line.518"></a>
-<span class="sourceLineNo">519</span>          return mergeNodes(leftNode, rightNode);<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        }<a name="line.520"></a>
-<span class="sourceLineNo">521</span><a name="line.521"></a>
-<span class="sourceLineNo">522</span>        if (leftCanGrow &amp;&amp; rightCanGrow) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          if ((procId - leftNode.getEnd()) &lt;= (rightNode.getStart() - procId)) {<a name="line.523"></a>
-<span class="sourceLineNo">524</span>            // grow the left node<a name="line.524"></a>
-<span class="sourceLineNo">525</span>            return growNode(leftNode, procId);<a name="line.525"></a>
-<span class="sourceLineNo">526</span>          }<a name="line.526"></a>
-<span class="sourceLineNo">527</span>          // grow the right node<a name="line.527"></a>
-<span class="sourceLineNo">528</span>          return growNode(rightNode, procId);<a name="line.528"></a>
-<span class="sourceLineNo">529</span>        }<a name="line.529"></a>
-<span class="sourceLineNo">530</span>      }<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>    // grow the left node<a name="line.533"></a>
-<span class="sourceLineNo">534</span>    if (leftCanGrow) {<a name="line.534"></a>
-<span class="sourceLineNo">535</span>      return growNode(leftNode, procId);<a name="line.535"></a>
-<span class="sourceLineNo">536</span>    }<a name="line.536"></a>
-<span class="sourceLineNo">537</span><a name="line.537"></a>
-<span class="sourceLineNo">538</span>    // grow the right node<a name="line.538"></a>
-<span class="sourceLineNo">539</span>    if (rightCanGrow) {<a name="line.539"></a>
-<span class="sourceLineNo">540</span>      return growNode(rightNode, procId);<a name="line.540"></a>
-<span class="sourceLineNo">541</span>    }<a name="line.541"></a>
-<span class="sourceLineNo">542</span><a name="line.542"></a>
-<span class="sourceLineNo">543</span>    // add new node<a name="line.543"></a>
-<span class="sourceLineNo">544</span>    BitSetNode node = new BitSetNode(procId, partial);<a name="line.544"></a>
-<span class="sourceLineNo">545</span>    map.put(node.getStart(), node);<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    return node;<a name="line.546"></a>
-<span class="sourceLineNo">547</span>  }<a name="line.547"></a>
-<span class="sourceLineNo">548</span><a name="line.548"></a>
-<span class="sourceLineNo">549</span>  private BitSetNode growNode(BitSetNode node, long procId) {<a name="line.549"></a>
-<span class="sourceLineNo">550</span>    map.remove(node.getStart());<a name="line.550"></a>
-<span class="sourceLineNo">551</span>    node.grow(procId);<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    map.put(node.getStart(), node);<a name="line.552"></a>
-<span class="sourceLineNo">553</span>    return node;<a name="line.553"></a>
-<span class="sourceLineNo">554</span>  }<a name="line.554"></a>
-<span class="sourceLineNo">555</span><a name="line.555"></a>
-<span class="sourceLineNo">556</span>  private BitSetNode mergeNodes(BitSetNode leftNode, BitSetNode rightNode) {<a name="line.556"></a>
-<span class="sourceLineNo">557</span>    assert leftNode.getStart() &lt; rightNode.getStart();<a name="line.557"></a>
-<span class="sourceLineNo">558</span>    leftNode.merge(rightNode);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    map.remove(rightNode.getStart());<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    return leftNode;<a name="line.560"></a>
-<span class="sourceLineNo">561</span>  }<a name="line.561"></a>
-<span class="sourceLineNo">562</span><a name="line.562"></a>
-<span class="sourceLineNo">563</span>  public void dump() {<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    System.out.println("map " + map.size());<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    System.out.println("isUpdated " + isUpdated());<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    System.out.println("isEmpty " + isEmpty());<a name="line.566"></a>
-<span class="sourceLineNo">567</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>      entry.getValue().dump();<a name="line.568"></a>
-<span class="sourceLineNo">569</span>    }<a name="line.569"></a>
-<span class="sourceLineNo">570</span>  }<a name="line.570"></a>
-<span class="sourceLineNo">571</span><a name="line.571"></a>
-<span class="sourceLineNo">572</span>  public void writeTo(final OutputStream stream) throws IOException {<a name="line.572"></a>
-<span class="sourceLineNo">573</span>    ProcedureProtos.ProcedureStoreTracker.Builder builder =<a name="line.573"></a>
-<span class="sourceLineNo">574</span>        ProcedureProtos.ProcedureStoreTracker.newBuilder();<a name="line.574"></a>
-<span class="sourceLineNo">575</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.575"></a>
-<span class="sourceLineNo">576</span>      builder.addNode(entry.getValue().convert());<a name="line.576"></a>
-<span class="sourceLineNo">577</span>    }<a name="line.577"></a>
-<span class="sourceLineNo">578</span>    builder.build().writeDelimitedTo(stream);<a name="line.578"></a>
-<span class="sourceLineNo">579</span>  }<a name="line.579"></a>
-<span class="sourceLineNo">580</span><a name="line.580"></a>
-<span class="sourceLineNo">581</span>  public void readFrom(final InputStream stream) throws IOException {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>    ProcedureProtos.ProcedureStoreTracker data =<a name="line.582"></a>
-<span class="sourceLineNo">583</span>        ProcedureProtos.ProcedureStoreTracker.parseDelimitedFrom(stream);<a name="line.583"></a>
-<span class="sourceLineNo">584</span>    map.clear();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: data.getNodeList()) {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>      BitSetNode node = BitSetNode.convert(protoNode);<a name="line.586"></a>
-<span class="sourceLineNo">587</span>      map.put(node.getStart(), node);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>    }<a name="line.588"></a>
-<span class="sourceLineNo">589</span>  }<a name="line.589"></a>
-<span class="sourceLineNo">590</span>}<a name="line.590"></a>
+<span class="sourceLineNo">417</span>  public void reset() {<a name="line.417"></a>
+<span class="sourceLineNo">418</span>    this.keepDeletes = false;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>    this.partial = false;<a name="line.419"></a>
+<span class="sourceLineNo">420</span>    this.map.clear();<a name="line.420"></a>
+<span class="sourceLineNo">421</span>    resetUpdates();<a name="line.421"></a>
+<span class="sourceLineNo">422</span>  }<a name="line.422"></a>
+<span class="sourceLineNo">423</span><a name="line.423"></a>
+<span class="sourceLineNo">424</span>  public DeleteState isDeleted(long procId) {<a name="line.424"></a>
+<span class="sourceLineNo">425</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.floorEntry(procId);<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    if (entry != null &amp;&amp; entry.getValue().contains(procId)) {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      BitSetNode node = entry.getValue();<a name="line.427"></a>
+<span class="sourceLineNo">428</span>      DeleteState state = node.isDeleted(procId);<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      return partial &amp;&amp; !node.isUpdated(procId) ? DeleteState.MAYBE : state;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>    }<a name="line.430"></a>
+<span class="sourceLineNo">431</span>    return partial ? DeleteState.MAYBE : DeleteState.YES;<a name="line.431"></a>
+<span class="sourceLineNo">432</span>  }<a name="line.432"></a>
+<span class="sourceLineNo">433</span><a name="line.433"></a>
+<span class="sourceLineNo">434</span>  public long getMinProcId() {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    // TODO: Cache?<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.firstEntry();<a name="line.436"></a>
+<span class="sourceLineNo">437</span>    return entry == null ? 0 : entry.getValue().getMinProcId();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>  }<a name="line.438"></a>
+<span class="sourceLineNo">439</span><a name="line.439"></a>
+<span class="sourceLineNo">440</span>  public void setKeepDeletes(boolean keepDeletes) {<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    this.keepDeletes = keepDeletes;<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    if (!keepDeletes) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      Iterator&lt;Map.Entry&lt;Long, BitSetNode&gt;&gt; it = map.entrySet().iterator();<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      while (it.hasNext()) {<a name="line.444"></a>
+<span class="sourceLineNo">445</span>        Map.Entry&lt;Long, BitSetNode&gt; entry = it.next();<a name="line.445"></a>
+<span class="sourceLineNo">446</span>        if (entry.getValue().isEmpty()) {<a name="line.446"></a>
+<span class="sourceLineNo">447</span>          it.remove();<a name="line.447"></a>
+<span class="sourceLineNo">448</span>        }<a name="line.448"></a>
+<span class="sourceLineNo">449</span>      }<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    }<a name="line.450"></a>
+<span class="sourceLineNo">451</span>  }<a name="line.451"></a>
+<span class="sourceLineNo">452</span><a name="line.452"></a>
+<span class="sourceLineNo">453</span>  public void setPartialFlag(boolean isPartial) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>    if (this.partial &amp;&amp; !isPartial) {<a name="line.454"></a>
+<span class="sourceLineNo">455</span>      for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.455"></a>
+<span class="sourceLineNo">456</span>        entry.getValue().unsetPartialFlag();<a name="line.456"></a>
+<span class="sourceLineNo">457</span>      }<a name="line.457"></a>
+<span class="sourceLineNo">458</span>    }<a name="line.458"></a>
+<span class="sourceLineNo">459</span>    this.partial = isPartial;<a name="line.459"></a>
+<span class="sourceLineNo">460</span>  }<a name="line.460"></a>
+<span class="sourceLineNo">461</span><a name="line.461"></a>
+<span class="sourceLineNo">462</span>  public boolean isEmpty() {<a name="line.462"></a>
+<span class="sourceLineNo">463</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.463"></a>
+<span class="sourceLineNo">464</span>      if (entry.getValue().isEmpty() == false) {<a name="line.464"></a>
+<span class="sourceLineNo">465</span>        return false;<a name="line.465"></a>
+<span class="sourceLineNo">466</span>      }<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    }<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    return true;<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  public boolean isUpdated() {<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.472"></a>
+<span class="sourceLineNo">473</span>      if (entry.getValue().isUpdated() == false) {<a name="line.473"></a>
+<span class="sourceLineNo">474</span>        return false;<a name="line.474"></a>
+<span class="sourceLineNo">475</span>      }<a name="line.475"></a>
+<span class="sourceLineNo">476</span>    }<a name="line.476"></a>
+<span class="sourceLineNo">477</span>    return true;<a name="line.477"></a>
+<span class="sourceLineNo">478</span>  }<a name="line.478"></a>
+<span class="sourceLineNo">479</span><a name="line.479"></a>
+<span class="sourceLineNo">480</span>  public boolean isTracking(long minId, long maxId) {<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    // TODO: we can make it more precise, instead of looking just at the block<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    return map.floorEntry(minId) != null || map.floorEntry(maxId) != null;<a name="line.482"></a>
+<span class="sourceLineNo">483</span>  }<a name="line.483"></a>
+<span class="sourceLineNo">484</span><a name="line.484"></a>
+<span class="sourceLineNo">485</span>  public void resetUpdates() {<a name="line.485"></a>
+<span class="sourceLineNo">486</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.486"></a>
+<span class="sourceLineNo">487</span>      entry.getValue().resetUpdates();<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    }<a name="line.488"></a>
+<span class="sourceLineNo">489</span>    minUpdatedProcId = Long.MAX_VALUE;<a name="line.489"></a>
+<span class="sourceLineNo">490</span>    maxUpdatedProcId = Long.MIN_VALUE;<a name="line.490"></a>
+<span class="sourceLineNo">491</span>  }<a name="line.491"></a>
+<span class="sourceLineNo">492</span><a name="line.492"></a>
+<span class="sourceLineNo">493</span>  public void undeleteAll() {<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.494"></a>
+<span class="sourceLineNo">495</span>      entry.getValue().undeleteAll();<a name="line.495"></a>
+<span class="sourceLineNo">496</span>    }<a name="line.496"></a>
+<span class="sourceLineNo">497</span>  }<a name="line.497"></a>
+<span class="sourceLineNo">498</span><a name="line.498"></a>
+<span class="sourceLineNo">499</span>  private BitSetNode getOrCreateNode(final long procId) {<a name="line.499"></a>
+<span class="sourceLineNo">500</span>    // can procId fit in the left node?<a name="line.500"></a>
+<span class="sourceLineNo">501</span>    BitSetNode leftNode = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>    boolean leftCanGrow = false;<a name="line.502"></a>
+<span class="sourceLineNo">503</span>    Map.Entry&lt;Long, BitSetNode&gt; leftEntry = map.floorEntry(procId);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>    if (leftEntry != null) {<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      leftNode = leftEntry.getValue();<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      if (leftNode.contains(procId)) {<a name="line.506"></a>
+<span class="sourceLineNo">507</span>        return leftNode;<a name="line.507"></a>
+<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      leftCanGrow = leftNode.canGrow(procId);<a name="line.509"></a>
+<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
+<span class="sourceLineNo">511</span><a name="line.511"></a>
+<span class="sourceLineNo">512</span>    BitSetNode rightNode = null;<a name="line.512"></a>
+<span class="sourceLineNo">513</span>    boolean rightCanGrow = false;<a name="line.513"></a>
+<span class="sourceLineNo">514</span>    Map.Entry&lt;Long, BitSetNode&gt; rightEntry = map.ceilingEntry(procId);<a name="line.514"></a>
+<span class="sourceLineNo">515</span>    if (rightEntry != null) {<a name="line.515"></a>
+<span class="sourceLineNo">516</span>      rightNode = rightEntry.getValue();<a name="line.516"></a>
+<span class="sourceLineNo">517</span>      rightCanGrow = rightNode.canGrow(procId);<a name="line.517"></a>
+<span class="sourceLineNo">518</span>      if (leftNode != null) {<a name="line.518"></a>
+<span class="sourceLineNo">519</span>        if (leftNode.canMerge(rightNode)) {<a name="line.519"></a>
+<span class="sourceLineNo">520</span>          // merge left and right node<a name="line.520"></a>
+<span class="sourceLineNo">521</span>          return mergeNodes(leftNode, rightNode);<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        }<a name="line.522"></a>
+<span class="sourceLineNo">523</span><a name="line.523"></a>
+<span class="sourceLineNo">524</span>        if (leftCanGrow &amp;&amp; rightCanGrow) {<a name="line.524"></a>
+<span class="sourceLineNo">525</span>          if ((procId - leftNode.getEnd()) &lt;= (rightNode.getStart() - procId)) {<a name="line.525"></a>
+<span class="sourceLineNo">526</span>            // grow the left node<a name="line.526"></a>
+<span class="sourceLineNo">527</span>            return growNode(leftNode, procId);<a name="line.527"></a>
+<span class="sourceLineNo">528</span>          }<a name="line.528"></a>
+<span class="sourceLineNo">529</span>          // grow the right node<a name="line.529"></a>
+<span class="sourceLineNo">530</span>          return growNode(rightNode, procId);<a name="line.530"></a>
+<span class="sourceLineNo">531</span>        }<a name="line.531"></a>
+<span class="sourceLineNo">532</span>      }<a name="line.532"></a>
+<span class="sourceLineNo">533</span>    }<a name="line.533"></a>
+<span class="sourceLineNo">534</span><a name="line.534"></a>
+<span class="sourceLineNo">535</span>    // grow the left node<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    if (leftCanGrow) {<a name="line.536"></a>
+<span class="sourceLineNo">537</span>      return growNode(leftNode, procId);<a name="line.537"></a>
+<span class="sourceLineNo">538</span>    }<a name="line.538"></a>
+<span class="sourceLineNo">539</span><a name="line.539"></a>
+<span class="sourceLineNo">540</span>    // grow the right node<a name="line.540"></a>
+<span class="sourceLineNo">541</span>    if (rightCanGrow) {<a name="line.541"></a>
+<span class="sourceLineNo">542</span>      return growNode(rightNode, procId);<a name="line.542"></a>
+<span class="sourceLineNo">543</span>    }<a name="line.543"></a>
+<span class="sourceLineNo">544</span><a name="line.544"></a>
+<span class="sourceLineNo">545</span>    // add new node<a name="line.545"></a>
+<span class="sourceLineNo">546</span>    BitSetNode node = new BitSetNode(procId, partial);<a name="line.546"></a>
+<span class="sourceLineNo">547</span>    map.put(node.getStart(), node);<a name="line.547"></a>
+<span class="sourceLineNo">548</span>    return node;<a name="line.548"></a>
+<span class="sourceLineNo">549</span>  }<a name="line.549"></a>
+<span class="sourceLineNo">550</span><a name="line.550"></a>
+<span class="sourceLineNo">551</span>  private BitSetNode growNode(BitSetNode node, long procId) {<a name="line.551"></a>
+<span class="sourceLineNo">552</span>    map.remove(node.getStart());<a name="line.552"></a>
+<span class="sourceLineNo">553</span>    node.grow(procId);<a name="line.553"></a>
+<span class="sourceLineNo">554</span>    map.put(node.getStart(), node);<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    return node;<a name="line.555"></a>
+<span class="sourceLineNo">556</span>  }<a name="line.556"></a>
+<span class="sourceLineNo">557</span><a name="line.557"></a>
+<span class="sourceLineNo">558</span>  private BitSetNode mergeNodes(BitSetNode leftNode, BitSetNode rightNode) {<a name="line.558"></a>
+<span class="sourceLineNo">559</span>    assert leftNode.getStart() &lt; rightNode.getStart();<a name="line.559"></a>
+<span class="sourceLineNo">560</span>    leftNode.merge(rightNode);<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    map.remove(rightNode.getStart());<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    return leftNode;<a name="line.562"></a>
+<span class="sourceLineNo">563</span>  }<a name="line.563"></a>
+<span class="sourceLineNo">564</span><a name="line.564"></a>
+<span class="sourceLineNo">565</span>  public void dump() {<a name="line.565"></a>
+<span class="sourceLineNo">566</span>    System.out.println("map " + map.size());<a name="line.566"></a>
+<span class="sourceLineNo">567</span>    System.out.println("isUpdated " + isUpdated());<a name="line.567"></a>
+<span class="sourceLineNo">568</span>    System.out.println("isEmpty " + isEmpty());<a name="line.568"></a>
+<span class="sourceLineNo">569</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.569"></a>
+<span class="sourceLineNo">570</span>      entry.getValue().dump();<a name="line.570"></a>
+<span class="sourceLineNo">571</span>    }<a name="line.571"></a>
+<span class="sourceLineNo">572</span>  }<a name="line.572"></a>
+<span class="sourceLineNo">573</span><a name="line.573"></a>
+<span class="sourceLineNo">574</span>  public void writeTo(final OutputStream stream) throws IOException {<a name="line.574"></a>
+<span class="sourceLineNo">575</span>    ProcedureProtos.ProcedureStoreTracker.Builder builder =<a name="line.575"></a>
+<span class="sourceLineNo">576</span>        ProcedureProtos.ProcedureStoreTracker.newBuilder();<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.577"></a>
+<span class="sourceLineNo">578</span>      builder.addNode(entry.getValue().convert());<a name="line.578"></a>
+<span class="sourceLineNo">579</span>    }<a name="line.579"></a>
+<span class="sourceLineNo">580</span>    builder.build().writeDelimitedTo(stream);<a name="line.580"></a>
+<span class="sourceLineNo">581</span>  }<a name="line.581"></a>
+<span class="sourceLineNo">582</span><a name="line.582"></a>
+<span class="sourceLineNo">583</span>  public void readFrom(final InputStream stream) throws IOException {<a name="line.583"></a>
+<span class="sourceLineNo">584</span>    reset();<a name="line.584"></a>
+<span class="sourceLineNo">585</span>    final ProcedureProtos.ProcedureStoreTracker data =<a name="line.585"></a>
+<span class="sourceLineNo">586</span>        ProcedureProtos.ProcedureStoreTracker.parseDelimitedFrom(stream);<a name="line.586"></a>
+<span class="sourceLineNo">587</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: data.getNodeList()) {<a name="line.587"></a>
+<span class="sourceLineNo">588</span>      final BitSetNode node = BitSetNode.convert(protoNode);<a name="line.588"></a>
+<span class="sourceLineNo">589</span>      map.put(node.getStart(), node);<a name="line.589"></a>
+<span class="sourceLineNo">590</span>    }<a name="line.590"></a>
+<span class="sourceLineNo">591</span>  }<a name="line.591"></a>
+<span class="sourceLineNo">592</span>}<a name="line.592"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f8d6f420/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
index f6c7b80..1c21359 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
@@ -422,180 +422,182 @@
 <span class="sourceLineNo">414</span>    node.updateState(procId, isDeleted);<a name="line.414"></a>
 <span class="sourceLineNo">415</span>  }<a name="line.415"></a>
 <span class="sourceLineNo">416</span><a name="line.416"></a>
-<span class="sourceLineNo">417</span>  public void clear() {<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    this.map.clear();<a name="line.418"></a>
-<span class="sourceLineNo">419</span>    resetUpdates();<a name="line.419"></a>
-<span class="sourceLineNo">420</span>  }<a name="line.420"></a>
-<span class="sourceLineNo">421</span><a name="line.421"></a>
-<span class="sourceLineNo">422</span>  public DeleteState isDeleted(long procId) {<a name="line.422"></a>
-<span class="sourceLineNo">423</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.floorEntry(procId);<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    if (entry != null &amp;&amp; entry.getValue().contains(procId)) {<a name="line.424"></a>
-<span class="sourceLineNo">425</span>      BitSetNode node = entry.getValue();<a name="line.425"></a>
-<span class="sourceLineNo">426</span>      DeleteState state = node.isDeleted(procId);<a name="line.426"></a>
-<span class="sourceLineNo">427</span>      return partial &amp;&amp; !node.isUpdated(procId) ? DeleteState.MAYBE : state;<a name="line.427"></a>
-<span class="sourceLineNo">428</span>    }<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    return partial ? DeleteState.MAYBE : DeleteState.YES;<a name="line.429"></a>
-<span class="sourceLineNo">430</span>  }<a name="line.430"></a>
-<span class="sourceLineNo">431</span><a name="line.431"></a>
-<span class="sourceLineNo">432</span>  public long getMinProcId() {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    // TODO: Cache?<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.firstEntry();<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    return entry == null ? 0 : entry.getValue().getMinProcId();<a name="line.435"></a>
-<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
-<span class="sourceLineNo">437</span><a name="line.437"></a>
-<span class="sourceLineNo">438</span>  public void setKeepDeletes(boolean keepDeletes) {<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    this.keepDeletes = keepDeletes;<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    if (!keepDeletes) {<a name="line.440"></a>
-<span class="sourceLineNo">441</span>      Iterator&lt;Map.Entry&lt;Long, BitSetNode&gt;&gt; it = map.entrySet().iterator();<a name="line.441"></a>
-<span class="sourceLineNo">442</span>      while (it.hasNext()) {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>        Map.Entry&lt;Long, BitSetNode&gt; entry = it.next();<a name="line.443"></a>
-<span class="sourceLineNo">444</span>        if (entry.getValue().isEmpty()) {<a name="line.444"></a>
-<span class="sourceLineNo">445</span>          it.remove();<a name="line.445"></a>
-<span class="sourceLineNo">446</span>        }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>      }<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    }<a name="line.448"></a>
-<span class="sourceLineNo">449</span>  }<a name="line.449"></a>
-<span class="sourceLineNo">450</span><a name="line.450"></a>
-<span class="sourceLineNo">451</span>  public void setPartialFlag(boolean isPartial) {<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    if (this.partial &amp;&amp; !isPartial) {<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.453"></a>
-<span class="sourceLineNo">454</span>        entry.getValue().unsetPartialFlag();<a name="line.454"></a>
-<span class="sourceLineNo">455</span>      }<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    }<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    this.partial = isPartial;<a name="line.457"></a>
-<span class="sourceLineNo">458</span>  }<a name="line.458"></a>
-<span class="sourceLineNo">459</span><a name="line.459"></a>
-<span class="sourceLineNo">460</span>  public boolean isEmpty() {<a name="line.460"></a>
-<span class="sourceLineNo">461</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>      if (entry.getValue().isEmpty() == false) {<a name="line.462"></a>
-<span class="sourceLineNo">463</span>        return false;<a name="line.463"></a>
-<span class="sourceLineNo">464</span>      }<a name="line.464"></a>
-<span class="sourceLineNo">465</span>    }<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    return true;<a name="line.466"></a>
-<span class="sourceLineNo">467</span>  }<a name="line.467"></a>
-<span class="sourceLineNo">468</span><a name="line.468"></a>
-<span class="sourceLineNo">469</span>  public boolean isUpdated() {<a name="line.469"></a>
-<span class="sourceLineNo">470</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.470"></a>
-<span class="sourceLineNo">471</span>      if (entry.getValue().isUpdated() == false) {<a name="line.471"></a>
-<span class="sourceLineNo">472</span>        return false;<a name="line.472"></a>
-<span class="sourceLineNo">473</span>      }<a name="line.473"></a>
-<span class="sourceLineNo">474</span>    }<a name="line.474"></a>
-<span class="sourceLineNo">475</span>    return true;<a name="line.475"></a>
-<span class="sourceLineNo">476</span>  }<a name="line.476"></a>
-<span class="sourceLineNo">477</span><a name="line.477"></a>
-<span class="sourceLineNo">478</span>  public boolean isTracking(long minId, long maxId) {<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    // TODO: we can make it more precise, instead of looking just at the block<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    return map.floorEntry(minId) != null || map.floorEntry(maxId) != null;<a name="line.480"></a>
-<span class="sourceLineNo">481</span>  }<a name="line.481"></a>
-<span class="sourceLineNo">482</span><a name="line.482"></a>
-<span class="sourceLineNo">483</span>  public void resetUpdates() {<a name="line.483"></a>
-<span class="sourceLineNo">484</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.484"></a>
-<span class="sourceLineNo">485</span>      entry.getValue().resetUpdates();<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    }<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    minUpdatedProcId = Long.MAX_VALUE;<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    maxUpdatedProcId = Long.MIN_VALUE;<a name="line.488"></a>
-<span class="sourceLineNo">489</span>  }<a name="line.489"></a>
-<span class="sourceLineNo">490</span><a name="line.490"></a>
-<span class="sourceLineNo">491</span>  public void undeleteAll() {<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.492"></a>
-<span class="sourceLineNo">493</span>      entry.getValue().undeleteAll();<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    }<a name="line.494"></a>
-<span class="sourceLineNo">495</span>  }<a name="line.495"></a>
-<span class="sourceLineNo">496</span><a name="line.496"></a>
-<span class="sourceLineNo">497</span>  private BitSetNode getOrCreateNode(final long procId) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>    // can procId fit in the left node?<a name="line.498"></a>
-<span class="sourceLineNo">499</span>    BitSetNode leftNode = null;<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    boolean leftCanGrow = false;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>    Map.Entry&lt;Long, BitSetNode&gt; leftEntry = map.floorEntry(procId);<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    if (leftEntry != null) {<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      leftNode = leftEntry.getValue();<a name="line.503"></a>
-<span class="sourceLineNo">504</span>      if (leftNode.contains(procId)) {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        return leftNode;<a name="line.505"></a>
-<span class="sourceLineNo">506</span>      }<a name="line.506"></a>
-<span class="sourceLineNo">507</span>      leftCanGrow = leftNode.canGrow(procId);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>    }<a name="line.508"></a>
-<span class="sourceLineNo">509</span><a name="line.509"></a>
-<span class="sourceLineNo">510</span>    BitSetNode rightNode = null;<a name="line.510"></a>
-<span class="sourceLineNo">511</span>    boolean rightCanGrow = false;<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    Map.Entry&lt;Long, BitSetNode&gt; rightEntry = map.ceilingEntry(procId);<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    if (rightEntry != null) {<a name="line.513"></a>
-<span class="sourceLineNo">514</span>      rightNode = rightEntry.getValue();<a name="line.514"></a>
-<span class="sourceLineNo">515</span>      rightCanGrow = rightNode.canGrow(procId);<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      if (leftNode != null) {<a name="line.516"></a>
-<span class="sourceLineNo">517</span>        if (leftNode.canMerge(rightNode)) {<a name="line.517"></a>
-<span class="sourceLineNo">518</span>          // merge left and right node<a name="line.518"></a>
-<span class="sourceLineNo">519</span>          return mergeNodes(leftNode, rightNode);<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        }<a name="line.520"></a>
-<span class="sourceLineNo">521</span><a name="line.521"></a>
-<span class="sourceLineNo">522</span>        if (leftCanGrow &amp;&amp; rightCanGrow) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          if ((procId - leftNode.getEnd()) &lt;= (rightNode.getStart() - procId)) {<a name="line.523"></a>
-<span class="sourceLineNo">524</span>            // grow the left node<a name="line.524"></a>
-<span class="sourceLineNo">525</span>            return growNode(leftNode, procId);<a name="line.525"></a>
-<span class="sourceLineNo">526</span>          }<a name="line.526"></a>
-<span class="sourceLineNo">527</span>          // grow the right node<a name="line.527"></a>
-<span class="sourceLineNo">528</span>          return growNode(rightNode, procId);<a name="line.528"></a>
-<span class="sourceLineNo">529</span>        }<a name="line.529"></a>
-<span class="sourceLineNo">530</span>      }<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>    // grow the left node<a name="line.533"></a>
-<span class="sourceLineNo">534</span>    if (leftCanGrow) {<a name="line.534"></a>
-<span class="sourceLineNo">535</span>      return growNode(leftNode, procId);<a name="line.535"></a>
-<span class="sourceLineNo">536</span>    }<a name="line.536"></a>
-<span class="sourceLineNo">537</span><a name="line.537"></a>
-<span class="sourceLineNo">538</span>    // grow the right node<a name="line.538"></a>
-<span class="sourceLineNo">539</span>    if (rightCanGrow) {<a name="line.539"></a>
-<span class="sourceLineNo">540</span>      return growNode(rightNode, procId);<a name="line.540"></a>
-<span class="sourceLineNo">541</span>    }<a name="line.541"></a>
-<span class="sourceLineNo">542</span><a name="line.542"></a>
-<span class="sourceLineNo">543</span>    // add new node<a name="line.543"></a>
-<span class="sourceLineNo">544</span>    BitSetNode node = new BitSetNode(procId, partial);<a name="line.544"></a>
-<span class="sourceLineNo">545</span>    map.put(node.getStart(), node);<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    return node;<a name="line.546"></a>
-<span class="sourceLineNo">547</span>  }<a name="line.547"></a>
-<span class="sourceLineNo">548</span><a name="line.548"></a>
-<span class="sourceLineNo">549</span>  private BitSetNode growNode(BitSetNode node, long procId) {<a name="line.549"></a>
-<span class="sourceLineNo">550</span>    map.remove(node.getStart());<a name="line.550"></a>
-<span class="sourceLineNo">551</span>    node.grow(procId);<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    map.put(node.getStart(), node);<a name="line.552"></a>
-<span class="sourceLineNo">553</span>    return node;<a name="line.553"></a>
-<span class="sourceLineNo">554</span>  }<a name="line.554"></a>
-<span class="sourceLineNo">555</span><a name="line.555"></a>
-<span class="sourceLineNo">556</span>  private BitSetNode mergeNodes(BitSetNode leftNode, BitSetNode rightNode) {<a name="line.556"></a>
-<span class="sourceLineNo">557</span>    assert leftNode.getStart() &lt; rightNode.getStart();<a name="line.557"></a>
-<span class="sourceLineNo">558</span>    leftNode.merge(rightNode);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    map.remove(rightNode.getStart());<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    return leftNode;<a name="line.560"></a>
-<span class="sourceLineNo">561</span>  }<a name="line.561"></a>
-<span class="sourceLineNo">562</span><a name="line.562"></a>
-<span class="sourceLineNo">563</span>  public void dump() {<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    System.out.println("map " + map.size());<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    System.out.println("isUpdated " + isUpdated());<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    System.out.println("isEmpty " + isEmpty());<a name="line.566"></a>
-<span class="sourceLineNo">567</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>      entry.getValue().dump();<a name="line.568"></a>
-<span class="sourceLineNo">569</span>    }<a name="line.569"></a>
-<span class="sourceLineNo">570</span>  }<a name="line.570"></a>
-<span class="sourceLineNo">571</span><a name="line.571"></a>
-<span class="sourceLineNo">572</span>  public void writeTo(final OutputStream stream) throws IOException {<a name="line.572"></a>
-<span class="sourceLineNo">573</span>    ProcedureProtos.ProcedureStoreTracker.Builder builder =<a name="line.573"></a>
-<span class="sourceLineNo">574</span>        ProcedureProtos.ProcedureStoreTracker.newBuilder();<a name="line.574"></a>
-<span class="sourceLineNo">575</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.575"></a>
-<span class="sourceLineNo">576</span>      builder.addNode(entry.getValue().convert());<a name="line.576"></a>
-<span class="sourceLineNo">577</span>    }<a name="line.577"></a>
-<span class="sourceLineNo">578</span>    builder.build().writeDelimitedTo(stream);<a name="line.578"></a>
-<span class="sourceLineNo">579</span>  }<a name="line.579"></a>
-<span class="sourceLineNo">580</span><a name="line.580"></a>
-<span class="sourceLineNo">581</span>  public void readFrom(final InputStream stream) throws IOException {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>    ProcedureProtos.ProcedureStoreTracker data =<a name="line.582"></a>
-<span class="sourceLineNo">583</span>        ProcedureProtos.ProcedureStoreTracker.parseDelimitedFrom(stream);<a name="line.583"></a>
-<span class="sourceLineNo">584</span>    map.clear();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: data.getNodeList()) {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>      BitSetNode node = BitSetNode.convert(protoNode);<a name="line.586"></a>
-<span class="sourceLineNo">587</span>      map.put(node.getStart(), node);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>    }<a name="line.588"></a>
-<span class="sourceLineNo">589</span>  }<a name="line.589"></a>
-<span class="sourceLineNo">590</span>}<a name="line.590"></a>
+<span class="sourceLineNo">417</span>  public void reset() {<a name="line.417"></a>
+<span class="sourceLineNo">418</span>    this.keepDeletes = false;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>    this.partial = false;<a name="line.419"></a>
+<span class="sourceLineNo">420</span>    this.map.clear();<a name="line.420"></a>
+<span class="sourceLineNo">421</span>    resetUpdates();<a name="line.421"></a>
+<span class="sourceLineNo">422</span>  }<a name="line.422"></a>
+<span class="sourceLineNo">423</span><a name="line.423"></a>
+<span class="sourceLineNo">424</span>  public DeleteState isDeleted(long procId) {<a name="line.424"></a>
+<span class="sourceLineNo">425</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.floorEntry(procId);<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    if (entry != null &amp;&amp; entry.getValue().contains(procId)) {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      BitSetNode node = entry.getValue();<a name="line.427"></a>
+<span class="sourceLineNo">428</span>      DeleteState state = node.isDeleted(procId);<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      return partial &amp;&amp; !node.isUpdated(procId) ? DeleteState.MAYBE : state;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>    }<a name="line.430"></a>
+<span class="sourceLineNo">431</span>    return partial ? DeleteState.MAYBE : DeleteState.YES;<a name="line.431"></a>
+<span class="sourceLineNo">432</span>  }<a name="line.432"></a>
+<span class="sourceLineNo">433</span><a name="line.433"></a>
+<span class="sourceLineNo">434</span>  public long getMinProcId() {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    // TODO: Cache?<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    Map.Entry&lt;Long, BitSetNode&gt; entry = map.firstEntry();<a name="line.436"></a>
+<span class="sourceLineNo">437</span>    return entry == null ? 0 : entry.getValue().getMinProcId();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>  }<a name="line.438"></a>
+<span class="sourceLineNo">439</span><a name="line.439"></a>
+<span class="sourceLineNo">440</span>  public void setKeepDeletes(boolean keepDeletes) {<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    this.keepDeletes = keepDeletes;<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    if (!keepDeletes) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      Iterator&lt;Map.Entry&lt;Long, BitSetNode&gt;&gt; it = map.entrySet().iterator();<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      while (it.hasNext()) {<a name="line.444"></a>
+<span class="sourceLineNo">445</span>        Map.Entry&lt;Long, BitSetNode&gt; entry = it.next();<a name="line.445"></a>
+<span class="sourceLineNo">446</span>        if (entry.getValue().isEmpty()) {<a name="line.446"></a>
+<span class="sourceLineNo">447</span>          it.remove();<a name="line.447"></a>
+<span class="sourceLineNo">448</span>        }<a name="line.448"></a>
+<span class="sourceLineNo">449</span>      }<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    }<a name="line.450"></a>
+<span class="sourceLineNo">451</span>  }<a name="line.451"></a>
+<span class="sourceLineNo">452</span><a name="line.452"></a>
+<span class="sourceLineNo">453</span>  public void setPartialFlag(boolean isPartial) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>    if (this.partial &amp;&amp; !isPartial) {<a name="line.454"></a>
+<span class="sourceLineNo">455</span>      for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.455"></a>
+<span class="sourceLineNo">456</span>        entry.getValue().unsetPartialFlag();<a name="line.456"></a>
+<span class="sourceLineNo">457</span>      }<a name="line.457"></a>
+<span class="sourceLineNo">458</span>    }<a name="line.458"></a>
+<span class="sourceLineNo">459</span>    this.partial = isPartial;<a name="line.459"></a>
+<span class="sourceLineNo">460</span>  }<a name="line.460"></a>
+<span class="sourceLineNo">461</span><a name="line.461"></a>
+<span class="sourceLineNo">462</span>  public boolean isEmpty() {<a name="line.462"></a>
+<span class="sourceLineNo">463</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.463"></a>
+<span class="sourceLineNo">464</span>      if (entry.getValue().isEmpty() == false) {<a name="line.464"></a>
+<span class="sourceLineNo">465</span>        return false;<a name="line.465"></a>
+<span class="sourceLineNo">466</span>      }<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    }<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    return true;<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  public boolean isUpdated() {<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.472"></a>
+<span class="sourceLineNo">473</span>      if (entry.getValue().isUpdated() == false) {<a name="line.473"></a>
+<span class="sourceLineNo">474</span>        return false;<a name="line.474"></a>
+<span class="sourceLineNo">475</span>      }<a name="line.475"></a>
+<span class="sourceLineNo">476</span>    }<a name="line.476"></a>
+<span class="sourceLineNo">477</span>    return true;<a name="line.477"></a>
+<span class="sourceLineNo">478</span>  }<a name="line.478"></a>
+<span class="sourceLineNo">479</span><a name="line.479"></a>
+<span class="sourceLineNo">480</span>  public boolean isTracking(long minId, long maxId) {<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    // TODO: we can make it more precise, instead of looking just at the block<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    return map.floorEntry(minId) != null || map.floorEntry(maxId) != null;<a name="line.482"></a>
+<span class="sourceLineNo">483</span>  }<a name="line.483"></a>
+<span class="sourceLineNo">484</span><a name="line.484"></a>
+<span class="sourceLineNo">485</span>  public void resetUpdates() {<a name="line.485"></a>
+<span class="sourceLineNo">486</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.486"></a>
+<span class="sourceLineNo">487</span>      entry.getValue().resetUpdates();<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    }<a name="line.488"></a>
+<span class="sourceLineNo">489</span>    minUpdatedProcId = Long.MAX_VALUE;<a name="line.489"></a>
+<span class="sourceLineNo">490</span>    maxUpdatedProcId = Long.MIN_VALUE;<a name="line.490"></a>
+<span class="sourceLineNo">491</span>  }<a name="line.491"></a>
+<span class="sourceLineNo">492</span><a name="line.492"></a>
+<span class="sourceLineNo">493</span>  public void undeleteAll() {<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.494"></a>
+<span class="sourceLineNo">495</span>      entry.getValue().undeleteAll();<a name="line.495"></a>
+<span class="sourceLineNo">496</span>    }<a name="line.496"></a>
+<span class="sourceLineNo">497</span>  }<a name="line.497"></a>
+<span class="sourceLineNo">498</span><a name="line.498"></a>
+<span class="sourceLineNo">499</span>  private BitSetNode getOrCreateNode(final long procId) {<a name="line.499"></a>
+<span class="sourceLineNo">500</span>    // can procId fit in the left node?<a name="line.500"></a>
+<span class="sourceLineNo">501</span>    BitSetNode leftNode = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>    boolean leftCanGrow = false;<a name="line.502"></a>
+<span class="sourceLineNo">503</span>    Map.Entry&lt;Long, BitSetNode&gt; leftEntry = map.floorEntry(procId);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>    if (leftEntry != null) {<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      leftNode = leftEntry.getValue();<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      if (leftNode.contains(procId)) {<a name="line.506"></a>
+<span class="sourceLineNo">507</span>        return leftNode;<a name="line.507"></a>
+<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      leftCanGrow = leftNode.canGrow(procId);<a name="line.509"></a>
+<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
+<span class="sourceLineNo">511</span><a name="line.511"></a>
+<span class="sourceLineNo">512</span>    BitSetNode rightNode = null;<a name="line.512"></a>
+<span class="sourceLineNo">513</span>    boolean rightCanGrow = false;<a name="line.513"></a>
+<span class="sourceLineNo">514</span>    Map.Entry&lt;Long, BitSetNode&gt; rightEntry = map.ceilingEntry(procId);<a name="line.514"></a>
+<span class="sourceLineNo">515</span>    if (rightEntry != null) {<a name="line.515"></a>
+<span class="sourceLineNo">516</span>      rightNode = rightEntry.getValue();<a name="line.516"></a>
+<span class="sourceLineNo">517</span>      rightCanGrow = rightNode.canGrow(procId);<a name="line.517"></a>
+<span class="sourceLineNo">518</span>      if (leftNode != null) {<a name="line.518"></a>
+<span class="sourceLineNo">519</span>        if (leftNode.canMerge(rightNode)) {<a name="line.519"></a>
+<span class="sourceLineNo">520</span>          // merge left and right node<a name="line.520"></a>
+<span class="sourceLineNo">521</span>          return mergeNodes(leftNode, rightNode);<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        }<a name="line.522"></a>
+<span class="sourceLineNo">523</span><a name="line.523"></a>
+<span class="sourceLineNo">524</span>        if (leftCanGrow &amp;&amp; rightCanGrow) {<a name="line.524"></a>
+<span class="sourceLineNo">525</span>          if ((procId - leftNode.getEnd()) &lt;= (rightNode.getStart() - procId)) {<a name="line.525"></a>
+<span class="sourceLineNo">526</span>            // grow the left node<a name="line.526"></a>
+<span class="sourceLineNo">527</span>            return growNode(leftNode, procId);<a name="line.527"></a>
+<span class="sourceLineNo">528</span>          }<a name="line.528"></a>
+<span class="sourceLineNo">529</span>          // grow the right node<a name="line.529"></a>
+<span class="sourceLineNo">530</span>          return growNode(rightNode, procId);<a name="line.530"></a>
+<span class="sourceLineNo">531</span>        }<a name="line.531"></a>
+<span class="sourceLineNo">532</span>      }<a name="line.532"></a>
+<span class="sourceLineNo">533</span>    }<a name="line.533"></a>
+<span class="sourceLineNo">534</span><a name="line.534"></a>
+<span class="sourceLineNo">535</span>    // grow the left node<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    if (leftCanGrow) {<a name="line.536"></a>
+<span class="sourceLineNo">537</span>      return growNode(leftNode, procId);<a name="line.537"></a>
+<span class="sourceLineNo">538</span>    }<a name="line.538"></a>
+<span class="sourceLineNo">539</span><a name="line.539"></a>
+<span class="sourceLineNo">540</span>    // grow the right node<a name="line.540"></a>
+<span class="sourceLineNo">541</span>    if (rightCanGrow) {<a name="line.541"></a>
+<span class="sourceLineNo">542</span>      return growNode(rightNode, procId);<a name="line.542"></a>
+<span class="sourceLineNo">543</span>    }<a name="line.543"></a>
+<span class="sourceLineNo">544</span><a name="line.544"></a>
+<span class="sourceLineNo">545</span>    // add new node<a name="line.545"></a>
+<span class="sourceLineNo">546</span>    BitSetNode node = new BitSetNode(procId, partial);<a name="line.546"></a>
+<span class="sourceLineNo">547</span>    map.put(node.getStart(), node);<a name="line.547"></a>
+<span class="sourceLineNo">548</span>    return node;<a name="line.548"></a>
+<span class="sourceLineNo">549</span>  }<a name="line.549"></a>
+<span class="sourceLineNo">550</span><a name="line.550"></a>
+<span class="sourceLineNo">551</span>  private BitSetNode growNode(BitSetNode node, long procId) {<a name="line.551"></a>
+<span class="sourceLineNo">552</span>    map.remove(node.getStart());<a name="line.552"></a>
+<span class="sourceLineNo">553</span>    node.grow(procId);<a name="line.553"></a>
+<span class="sourceLineNo">554</span>    map.put(node.getStart(), node);<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    return node;<a name="line.555"></a>
+<span class="sourceLineNo">556</span>  }<a name="line.556"></a>
+<span class="sourceLineNo">557</span><a name="line.557"></a>
+<span class="sourceLineNo">558</span>  private BitSetNode mergeNodes(BitSetNode leftNode, BitSetNode rightNode) {<a name="line.558"></a>
+<span class="sourceLineNo">559</span>    assert leftNode.getStart() &lt; rightNode.getStart();<a name="line.559"></a>
+<span class="sourceLineNo">560</span>    leftNode.merge(rightNode);<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    map.remove(rightNode.getStart());<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    return leftNode;<a name="line.562"></a>
+<span class="sourceLineNo">563</span>  }<a name="line.563"></a>
+<span class="sourceLineNo">564</span><a name="line.564"></a>
+<span class="sourceLineNo">565</span>  public void dump() {<a name="line.565"></a>
+<span class="sourceLineNo">566</span>    System.out.println("map " + map.size());<a name="line.566"></a>
+<span class="sourceLineNo">567</span>    System.out.println("isUpdated " + isUpdated());<a name="line.567"></a>
+<span class="sourceLineNo">568</span>    System.out.println("isEmpty " + isEmpty());<a name="line.568"></a>
+<span class="sourceLineNo">569</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.569"></a>
+<span class="sourceLineNo">570</span>      entry.getValue().dump();<a name="line.570"></a>
+<span class="sourceLineNo">571</span>    }<a name="line.571"></a>
+<span class="sourceLineNo">572</span>  }<a name="line.572"></a>
+<span class="sourceLineNo">573</span><a name="line.573"></a>
+<span class="sourceLineNo">574</span>  public void writeTo(final OutputStream stream) throws IOException {<a name="line.574"></a>
+<span class="sourceLineNo">575</span>    ProcedureProtos.ProcedureStoreTracker.Builder builder =<a name="line.575"></a>
+<span class="sourceLineNo">576</span>        ProcedureProtos.ProcedureStoreTracker.newBuilder();<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : map.entrySet()) {<a name="line.577"></a>
+<span class="sourceLineNo">578</span>      builder.addNode(entry.getValue().convert());<a name="line.578"></a>
+<span class="sourceLineNo">579</span>    }<a name="line.579"></a>
+<span class="sourceLineNo">580</span>    builder.build().writeDelimitedTo(stream);<a name="line.580"></a>
+<span class="sourceLineNo">581</span>  }<a name="line.581"></a>
+<span class="sourceLineNo">582</span><a name="line.582"></a>
+<span class="sourceLineNo">583</span>  public void readFrom(final InputStream stream) throws IOException {<a name="line.583"></a>
+<span class="sourceLineNo">584</span>    reset();<a name="line.584"></a>
+<span class="sourceLineNo">585</span>    final ProcedureProtos.ProcedureStoreTracker data =<a name="line.585"></a>
+<span class="sourceLineNo">586</span>        ProcedureProtos.ProcedureStoreTracker.parseDelimitedFrom(stream);<a name="line.586"></a>
+<span class="sourceLineNo">587</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: data.getNodeList()) {<a name="line.587"></a>
+<span class="sourceLineNo">588</span>      final BitSetNode node = BitSetNode.convert(protoNode);<a name="line.588"></a>
+<span class="sourceLineNo">589</span>      map.put(node.getStart(), node);<a name="line.589"></a>
+<span class="sourceLineNo">590</span>    }<a name="line.590"></a>
+<span class="sourceLineNo">591</span>  }<a name="line.591"></a>
+<span class="sourceLineNo">592</span>}<a name="line.592"></a>
 
 
 


Mime
View raw message