diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-02-10 18:38:35 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-02-10 18:38:35 +0100 |
commit | f7f050f4dbb5754243fbcc884eb1a5c1c0a04c10 (patch) | |
tree | 728814d4dc246e21e030e93099d1337e002ad6be | |
parent | 627a14b11aed4a2df73342d10ed8938adc58f167 (diff) | |
download | sonarqube-f7f050f4dbb5754243fbcc884eb1a5c1c0a04c10.tar.gz sonarqube-f7f050f4dbb5754243fbcc884eb1a5c1c0a04c10.zip |
Use packed repeated fields in protobuf messages
4 files changed, 99 insertions, 79 deletions
diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java index 23c3a57d828..8026f5b5f82 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java @@ -714,15 +714,15 @@ public final class BatchReport { getLanguageBytes(); /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ java.util.List<java.lang.Integer> getChildRefsList(); /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ int getChildRefsCount(); /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ int getChildRefs(int index); @@ -1097,24 +1097,25 @@ public final class BatchReport { public static final int CHILD_REFS_FIELD_NUMBER = 7; private java.util.List<java.lang.Integer> childRefs_; /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public java.util.List<java.lang.Integer> getChildRefsList() { return childRefs_; } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public int getChildRefsCount() { return childRefs_.size(); } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public int getChildRefs(int index) { return childRefs_.get(index); } + private int childRefsMemoizedSerializedSize = -1; public static final int SNAPSHOT_ID_FIELD_NUMBER = 8; private int snapshotId_; @@ -1223,8 +1224,12 @@ public final class BatchReport { if (((bitField0_ & 0x00000020) == 0x00000020)) { output.writeBytes(6, getLanguageBytes()); } + if (getChildRefsList().size() > 0) { + output.writeRawVarint32(58); + output.writeRawVarint32(childRefsMemoizedSerializedSize); + } for (int i = 0; i < childRefs_.size(); i++) { - output.writeInt32(7, childRefs_.get(i)); + output.writeInt32NoTag(childRefs_.get(i)); } if (((bitField0_ & 0x00000040) == 0x00000040)) { output.writeInt32(8, snapshotId_); @@ -1272,7 +1277,12 @@ public final class BatchReport { .computeInt32SizeNoTag(childRefs_.get(i)); } size += dataSize; - size += 1 * getChildRefsList().size(); + if (!getChildRefsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + childRefsMemoizedSerializedSize = dataSize; } if (((bitField0_ & 0x00000040) == 0x00000040)) { size += com.google.protobuf.CodedOutputStream @@ -1902,26 +1912,26 @@ public final class BatchReport { } } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public java.util.List<java.lang.Integer> getChildRefsList() { return java.util.Collections.unmodifiableList(childRefs_); } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public int getChildRefsCount() { return childRefs_.size(); } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public int getChildRefs(int index) { return childRefs_.get(index); } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public Builder setChildRefs( int index, int value) { @@ -1931,7 +1941,7 @@ public final class BatchReport { return this; } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public Builder addChildRefs(int value) { ensureChildRefsIsMutable(); @@ -1940,7 +1950,7 @@ public final class BatchReport { return this; } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public Builder addAllChildRefs( java.lang.Iterable<? extends java.lang.Integer> values) { @@ -1951,7 +1961,7 @@ public final class BatchReport { return this; } /** - * <code>repeated int32 child_refs = 7;</code> + * <code>repeated int32 child_refs = 7 [packed = true];</code> */ public Builder clearChildRefs() { childRefs_ = java.util.Collections.emptyList(); @@ -6404,27 +6414,27 @@ public final class BatchReport { "\n\022batch_report.proto\032\017constants.proto\"R\n" + "\010Metadata\022\025\n\ranalysis_date\030\001 \001(\003\022\023\n\013proj" + "ect_key\030\002 \001(\t\022\032\n\022root_component_ref\030\003 \001(" + - "\005\"\254\001\n\tComponent\022\013\n\003ref\030\001 \001(\005\022\014\n\004path\030\002 \001" + + "\005\"\260\001\n\tComponent\022\013\n\003ref\030\001 \001(\005\022\014\n\004path\030\002 \001" + "(\t\022\014\n\004name\030\003 \001(\t\022\034\n\004type\030\004 \001(\0162\016.Compone" + "ntType\022\017\n\007is_test\030\005 \001(\010\022\020\n\010language\030\006 \001(" + - "\t\022\022\n\nchild_refs\030\007 \003(\005\022\023\n\013snapshot_id\030\010 \001" + - "(\005\022\014\n\004uuid\030\t \001(\t\"\232\004\n\005Issue\022\027\n\017rule_repos" + - "itory\030\001 \001(\t\022\020\n\010rule_key\030\002 \001(\t\022\014\n\004line\030\003 " + - "\001(\005\022\013\n\003msg\030\004 \001(\t\022\033\n\010severity\030\005 \001(\0162\t.Sev", - "erity\022\014\n\004tags\030\006 \003(\t\022\025\n\reffort_to_fix\030\007 \001" + - "(\001\022\016\n\006is_new\030\010 \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017debt" + - "_in_minutes\030\n \001(\003\022\022\n\nresolution\030\013 \001(\t\022\016\n" + - "\006status\030\014 \001(\t\022\020\n\010checksum\030\r \001(\t\022\027\n\017manua" + - "l_severity\030\016 \001(\010\022\020\n\010reporter\030\017 \001(\t\022\020\n\010as" + - "signee\030\020 \001(\t\022\027\n\017action_plan_key\030\021 \001(\t\022\022\n" + - "\nattributes\030\022 \001(\t\022\024\n\014author_login\030\023 \001(\t\022" + - "\025\n\rcreation_date\030\024 \001(\003\022\022\n\nclose_date\030\025 \001" + - "(\003\022\023\n\013update_date\030\026 \001(\003\022\023\n\013selected_at\030\027" + - " \001(\003\022\023\n\013diff_fields\030\030 \001(\t\022\022\n\nis_changed\030", - "\031 \001(\010\022\036\n\026must_send_notification\030\032 \001(\010\"5\n" + - "\006Issues\022\025\n\rcomponent_ref\030\001 \001(\005\022\024\n\004list\030\002" + - " \003(\0132\006.IssueB#\n\037org.sonar.batch.protocol" + - ".outputH\001" + "\t\022\026\n\nchild_refs\030\007 \003(\005B\002\020\001\022\023\n\013snapshot_id" + + "\030\010 \001(\005\022\014\n\004uuid\030\t \001(\t\"\232\004\n\005Issue\022\027\n\017rule_r" + + "epository\030\001 \001(\t\022\020\n\010rule_key\030\002 \001(\t\022\014\n\004lin" + + "e\030\003 \001(\005\022\013\n\003msg\030\004 \001(\t\022\033\n\010severity\030\005 \001(\0162\t", + ".Severity\022\014\n\004tags\030\006 \003(\t\022\025\n\reffort_to_fix" + + "\030\007 \001(\001\022\016\n\006is_new\030\010 \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017" + + "debt_in_minutes\030\n \001(\003\022\022\n\nresolution\030\013 \001(" + + "\t\022\016\n\006status\030\014 \001(\t\022\020\n\010checksum\030\r \001(\t\022\027\n\017m" + + "anual_severity\030\016 \001(\010\022\020\n\010reporter\030\017 \001(\t\022\020" + + "\n\010assignee\030\020 \001(\t\022\027\n\017action_plan_key\030\021 \001(" + + "\t\022\022\n\nattributes\030\022 \001(\t\022\024\n\014author_login\030\023 " + + "\001(\t\022\025\n\rcreation_date\030\024 \001(\003\022\022\n\nclose_date" + + "\030\025 \001(\003\022\023\n\013update_date\030\026 \001(\003\022\023\n\013selected_" + + "at\030\027 \001(\003\022\023\n\013diff_fields\030\030 \001(\t\022\022\n\nis_chan", + "ged\030\031 \001(\010\022\036\n\026must_send_notification\030\032 \001(" + + "\010\"5\n\006Issues\022\025\n\rcomponent_ref\030\001 \001(\005\022\024\n\004li" + + "st\030\002 \003(\0132\006.IssueB#\n\037org.sonar.batch.prot" + + "ocol.outputH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java index f3f9db893b2..a1b40ec8fbf 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java @@ -88,7 +88,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ boolean hasUtLineHits(); @@ -96,7 +96,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ int getUtLineHits(); @@ -123,7 +123,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ boolean hasItLineHits(); @@ -131,7 +131,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ int getItLineHits(); @@ -158,7 +158,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ boolean hasOverallLineHits(); @@ -166,7 +166,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ int getOverallLineHits(); @@ -218,15 +218,15 @@ public final class FileSourceDb { getSymbolsBytes(); /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ java.util.List<java.lang.Integer> getDuplicationsList(); /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ int getDuplicationsCount(); /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ int getDuplications(int index); } @@ -605,7 +605,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public boolean hasUtLineHits() { @@ -615,7 +615,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public int getUtLineHits() { @@ -658,7 +658,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public boolean hasItLineHits() { @@ -668,7 +668,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public int getItLineHits() { @@ -711,7 +711,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public boolean hasOverallLineHits() { @@ -721,7 +721,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public int getOverallLineHits() { @@ -845,24 +845,25 @@ public final class FileSourceDb { public static final int DUPLICATIONS_FIELD_NUMBER = 17; private java.util.List<java.lang.Integer> duplications_; /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public java.util.List<java.lang.Integer> getDuplicationsList() { return duplications_; } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public int getDuplicationsCount() { return duplications_.size(); } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public int getDuplications(int index) { return duplications_.get(index); } + private int duplicationsMemoizedSerializedSize = -1; private void initFields() { line_ = 0; @@ -944,8 +945,12 @@ public final class FileSourceDb { if (((bitField0_ & 0x00008000) == 0x00008000)) { output.writeBytes(16, getSymbolsBytes()); } + if (getDuplicationsList().size() > 0) { + output.writeRawVarint32(138); + output.writeRawVarint32(duplicationsMemoizedSerializedSize); + } for (int i = 0; i < duplications_.size(); i++) { - output.writeInt32(17, duplications_.get(i)); + output.writeInt32NoTag(duplications_.get(i)); } getUnknownFields().writeTo(output); } @@ -1027,7 +1032,12 @@ public final class FileSourceDb { .computeInt32SizeNoTag(duplications_.get(i)); } size += dataSize; - size += 2 * getDuplicationsList().size(); + if (!getDuplicationsList().isEmpty()) { + size += 2; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + duplicationsMemoizedSerializedSize = dataSize; } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -1709,7 +1719,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public boolean hasUtLineHits() { @@ -1719,7 +1729,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public int getUtLineHits() { @@ -1729,7 +1739,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public Builder setUtLineHits(int value) { @@ -1742,7 +1752,7 @@ public final class FileSourceDb { * <code>optional int32 ut_line_hits = 6;</code> * * <pre> - * unit testing + * unit tests * </pre> */ public Builder clearUtLineHits() { @@ -1821,7 +1831,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public boolean hasItLineHits() { @@ -1831,7 +1841,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public int getItLineHits() { @@ -1841,7 +1851,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public Builder setItLineHits(int value) { @@ -1854,7 +1864,7 @@ public final class FileSourceDb { * <code>optional int32 it_line_hits = 9;</code> * * <pre> - * integration testing + * integration tests * </pre> */ public Builder clearItLineHits() { @@ -1933,7 +1943,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public boolean hasOverallLineHits() { @@ -1943,7 +1953,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public int getOverallLineHits() { @@ -1953,7 +1963,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public Builder setOverallLineHits(int value) { @@ -1966,7 +1976,7 @@ public final class FileSourceDb { * <code>optional int32 overall_line_hits = 12;</code> * * <pre> - * overall testing + * overall tests * </pre> */ public Builder clearOverallLineHits() { @@ -2200,26 +2210,26 @@ public final class FileSourceDb { } } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public java.util.List<java.lang.Integer> getDuplicationsList() { return java.util.Collections.unmodifiableList(duplications_); } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public int getDuplicationsCount() { return duplications_.size(); } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public int getDuplications(int index) { return duplications_.get(index); } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public Builder setDuplications( int index, int value) { @@ -2229,7 +2239,7 @@ public final class FileSourceDb { return this; } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public Builder addDuplications(int value) { ensureDuplicationsIsMutable(); @@ -2238,7 +2248,7 @@ public final class FileSourceDb { return this; } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public Builder addAllDuplications( java.lang.Iterable<? extends java.lang.Integer> values) { @@ -2249,7 +2259,7 @@ public final class FileSourceDb { return this; } /** - * <code>repeated int32 duplications = 17;</code> + * <code>repeated int32 duplications = 17 [packed = true];</code> */ public Builder clearDuplications() { duplications_ = java.util.Collections.emptyList(); @@ -2965,7 +2975,7 @@ public final class FileSourceDb { static { java.lang.String[] descriptorData = { "\n\024file_source_db.proto\022\032org.sonar.server" + - ".source.db\"\220\003\n\004Line\022\014\n\004line\030\001 \001(\005\022\016\n\006sou" + + ".source.db\"\224\003\n\004Line\022\014\n\004line\030\001 \001(\005\022\016\n\006sou" + "rce\030\002 \001(\t\022\024\n\014scm_revision\030\003 \001(\t\022\022\n\nscm_a" + "uthor\030\004 \001(\t\022\020\n\010scm_date\030\005 \001(\003\022\024\n\014ut_line" + "_hits\030\006 \001(\005\022\025\n\rut_conditions\030\007 \001(\005\022\035\n\025ut" + @@ -2974,9 +2984,9 @@ public final class FileSourceDb { "ered_conditions\030\013 \001(\005\022\031\n\021overall_line_hi" + "ts\030\014 \001(\005\022\032\n\022overall_conditions\030\r \001(\005\022\"\n\032" + "overall_covered_conditions\030\016 \001(\005\022\024\n\014high", - "lighting\030\017 \001(\t\022\017\n\007symbols\030\020 \001(\t\022\024\n\014dupli" + - "cations\030\021 \003(\005\"7\n\004Data\022/\n\005lines\030\001 \003(\0132 .o" + - "rg.sonar.server.source.db.LineB\002H\001" + "lighting\030\017 \001(\t\022\017\n\007symbols\030\020 \001(\t\022\030\n\014dupli" + + "cations\030\021 \003(\005B\002\020\001\"7\n\004Data\022/\n\005lines\030\001 \003(\013" + + "2 .org.sonar.server.source.db.LineB\002H\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto index 0499fc2b3ca..d1acbfe00a3 100644 --- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto +++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto @@ -51,7 +51,7 @@ message Component { optional ComponentType type = 4; optional bool is_test = 5; optional string language = 6; - repeated int32 child_refs = 7; + repeated int32 child_refs = 7 [packed=true]; // temporary fields during development of computation stack optional int32 snapshot_id = 8; diff --git a/sonar-batch-protocol/src/main/protobuf/file_source_db.proto b/sonar-batch-protocol/src/main/protobuf/file_source_db.proto index bdb0b877949..cc29e17ccdc 100644 --- a/sonar-batch-protocol/src/main/protobuf/file_source_db.proto +++ b/sonar-batch-protocol/src/main/protobuf/file_source_db.proto @@ -64,7 +64,7 @@ message Line { optional string highlighting = 15; optional string symbols = 16; - repeated int32 duplications = 17; + repeated int32 duplications = 17 [packed=true]; } message Data { |