Skip to content

Commit

Permalink
remove boolean param to setCommit, rename to setTXCommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Osheroff committed Aug 26, 2015
1 parent cae30f3 commit f64d60c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/main/java/com/zendesk/maxwell/MaxwellAbstractRowsEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class MaxwellAbstractRowsEvent extends AbstractRowEvent {
private final AbstractRowEvent event;

private Long xid;
private boolean commit; // whether this row ends the transaction
private boolean txCommit; // whether this row ends the transaction

protected final Table table;
protected final Database database;
Expand All @@ -41,7 +41,7 @@ public MaxwellAbstractRowsEvent(AbstractRowEvent e, Table table, MaxwellFilter f
this.header = e.getHeader();
this.table = table;
this.database = table.getDatabase();
this.commit = false;
this.txCommit = false;
this.xid = null;
this.filter = f;
}
Expand Down Expand Up @@ -98,12 +98,8 @@ public void setXid(Long xid) {
this.xid = xid;
}

public boolean isCommit() {
return commit;
}

public void setCommit(boolean commit) {
this.commit = commit;
public void setTXCommit() {
this.txCommit = true;
}


Expand Down Expand Up @@ -224,9 +220,8 @@ public void setXid(Long xid) {
this.put("xid", xid);
}

public void setCommit(boolean commit) {
if ( commit )
this.put("commit", commit);
public void setTXCommit() {
this.put("commit", true);
}

public Object getData(String string) {
Expand All @@ -246,7 +241,10 @@ public List<RowMap> jsonMaps() {
rowMap.setDatabase(getDatabase().getName());
rowMap.setTimestamp(getHeader().getTimestamp() / 1000);
rowMap.setXid(getXid());
rowMap.setCommit(isCommit() && !ri.hasNext());

// only set commit: true on the last row of the last event of the transaction
if ( this.txCommit && !ri.hasNext() )
rowMap.setTXCommit();

Iterator<Column> colIter = r.getColumns().iterator();
Iterator<ColumnDef> defIter = table.getColumnList().iterator();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/zendesk/maxwell/MaxwellParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private LinkedList<MaxwellAbstractRowsEvent> getTransactionEvents() throws Excep
e.setXid(xe.getXid());

if ( !list.isEmpty() )
list.getLast().setCommit(true);
list.getLast().setTXCommit();

return list;
}
Expand Down

0 comments on commit f64d60c

Please sign in to comment.