mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
整理代码
This commit is contained in:
@@ -48,5 +48,5 @@ canal.mq.topic=example
|
|||||||
canal.mq.partition=0
|
canal.mq.partition=0
|
||||||
# hash partition config
|
# hash partition config
|
||||||
#canal.mq.partitionsNum=3
|
#canal.mq.partitionsNum=3
|
||||||
#canal.mq.partitionHash=mytest.person:id,mytest.role:id
|
#canal.mq.partitionHash=.*\\..*.$pk$
|
||||||
#################################################
|
#################################################
|
||||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||||
|
|
||||||
@@ -108,7 +109,25 @@ public class Message implements Serializable {
|
|||||||
for (int i = 0; i < partitionsNum; i++) {
|
for (int i = 0; i < partitionsNum; i++) {
|
||||||
partitionEntries[i] = new ArrayList<>();
|
partitionEntries[i] = new ArrayList<>();
|
||||||
}
|
}
|
||||||
for (Entry entry : this.getEntries()) {
|
|
||||||
|
List<CanalEntry.Entry> entries;
|
||||||
|
if (this.isRaw()) {
|
||||||
|
List<ByteString> rawEntries = this.getRawEntries();
|
||||||
|
entries = new ArrayList<>(rawEntries.size());
|
||||||
|
for (ByteString byteString : rawEntries) {
|
||||||
|
Entry entry;
|
||||||
|
try {
|
||||||
|
entry = Entry.parseFrom(byteString);
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
entries.add(entry);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entries = this.getEntries();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entry entry : entries) {
|
||||||
CanalEntry.RowChange rowChange;
|
CanalEntry.RowChange rowChange;
|
||||||
try {
|
try {
|
||||||
rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
|
rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
|
||||||
@@ -194,9 +213,9 @@ public class Message implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < partitionsNum; i++) {
|
for (int i = 0; i < partitionsNum; i++) {
|
||||||
List<Entry> entries = partitionEntries[i];
|
List<Entry> entriesTmp = partitionEntries[i];
|
||||||
if (!entries.isEmpty()) {
|
if (!entriesTmp.isEmpty()) {
|
||||||
partitionMessages[i] = new Message(this.id, entries);
|
partitionMessages[i] = new Message(this.id, entriesTmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user