From 616defde1897bb33b2e6b706f3ffb52ec03a8ad3 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Thu, 15 Dec 2022 03:39:51 -0800 Subject: [PATCH 1/3] allow string dimension indexer to handle byte[] as base64 strings, protobuf byte tests --- examples/bin/generate-example-metrics | 2 +- .../input/protobuf/ProtoTestEventWrapper.java | 1155 +++++++++-------- .../protobuf/ProtobufInputFormatTest.java | 16 +- .../protobuf/ProtobufInputRowParserTest.java | 23 +- .../input/protobuf/ProtobufReaderTest.java | 6 +- .../src/test/resources/ProtoTest.proto | 7 +- .../src/test/resources/prototest.desc | Bin 998 -> 1040 bytes .../druid/segment/StringDimensionIndexer.java | 4 + .../segment/StringDimensionIndexerTest.java | 18 + 9 files changed, 653 insertions(+), 578 deletions(-) diff --git a/examples/bin/generate-example-metrics b/examples/bin/generate-example-metrics index 3bec6afeb615..dd9f61befd7f 100755 --- a/examples/bin/generate-example-metrics +++ b/examples/bin/generate-example-metrics @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java index 80c69877d711..0b88be107d4d 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java @@ -18,11 +18,10 @@ */ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Prototest.proto +// source: ProtoTest.proto package org.apache.druid.data.input.protobuf; -@SuppressWarnings("ALL") public final class ProtoTestEventWrapper { private ProtoTestEventWrapper() {} public static void registerAllExtensions( @@ -150,56 +149,67 @@ public interface ProtoTestEventOrBuilder extends long getSomeLongColumn(); /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * required bytes someBytesColumn = 10; + * @return Whether the someBytesColumn field is set. + */ + boolean hasSomeBytesColumn(); + /** + * required bytes someBytesColumn = 10; + * @return The someBytesColumn. + */ + com.google.protobuf.ByteString getSomeBytesColumn(); + + /** + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return Whether the foo field is set. */ boolean hasFoo(); /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return The foo. */ org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getFoo(); /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getFooOrBuilder(); /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ java.util.List getBarList(); /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getBar(int index); /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ int getBarCount(); /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ java.util.List getBarOrBuilderList(); /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getBarOrBuilder( int index); /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return Whether the otherTimestamp field is set. */ boolean hasOtherTimestamp(); /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return The otherTimestamp. */ com.google.protobuf.Timestamp getOtherTimestamp(); /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ com.google.protobuf.TimestampOrBuilder getOtherTimestampOrBuilder(); } @@ -219,6 +229,7 @@ private ProtoTestEvent() { eventType_ = 0; timestamp_ = ""; description_ = ""; + someBytesColumn_ = com.google.protobuf.ByteString.EMPTY; bar_ = java.util.Collections.emptyList(); } @@ -234,136 +245,6 @@ protected java.lang.Object newInstance( getUnknownFields() { return this.unknownFields; } - private ProtoTestEvent( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: { - int rawValue = input.readEnum(); - @SuppressWarnings("deprecation") - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory value = org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(1, rawValue); - } else { - bitField0_ |= 0x00000001; - eventType_ = rawValue; - } - break; - } - case 16: { - bitField0_ |= 0x00000002; - id_ = input.readUInt64(); - break; - } - case 26: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000004; - timestamp_ = bs; - break; - } - case 32: { - bitField0_ |= 0x00000008; - someOtherId_ = input.readUInt32(); - break; - } - case 40: { - bitField0_ |= 0x00000010; - isValid_ = input.readBool(); - break; - } - case 50: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000020; - description_ = bs; - break; - } - case 61: { - bitField0_ |= 0x00000040; - someFloatColumn_ = input.readFloat(); - break; - } - case 64: { - bitField0_ |= 0x00000080; - someIntColumn_ = input.readUInt32(); - break; - } - case 72: { - bitField0_ |= 0x00000100; - someLongColumn_ = input.readUInt64(); - break; - } - case 82: { - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder subBuilder = null; - if (((bitField0_ & 0x00000200) != 0)) { - subBuilder = foo_.toBuilder(); - } - foo_ = input.readMessage(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(foo_); - foo_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000200; - break; - } - case 90: { - if (!((mutable_bitField0_ & 0x00000400) != 0)) { - bar_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000400; - } - bar_.add( - input.readMessage(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.PARSER, extensionRegistry)); - break; - } - case 98: { - com.google.protobuf.Timestamp.Builder subBuilder = null; - if (((bitField0_ & 0x00000400) != 0)) { - subBuilder = otherTimestamp_.toBuilder(); - } - otherTimestamp_ = input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(otherTimestamp_); - otherTimestamp_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000400; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000400) != 0)) { - bar_ = java.util.Collections.unmodifiableList(bar_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_descriptor; @@ -410,7 +291,6 @@ public enum EventCategory public static final int CATEGORY_TWO_VALUE = 2; - @Override public final int getNumber() { return value; } @@ -445,18 +325,15 @@ public static EventCategory forNumber(int value) { private static final com.google.protobuf.Internal.EnumLiteMap< EventCategory> internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - @Override public EventCategory findValueByNumber(int number) { return EventCategory.forNumber(number); } }; - @Override public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { return getDescriptor().getValues().get(ordinal()); } - @Override public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { return getDescriptor(); @@ -479,7 +356,7 @@ public static EventCategory valueOf( private final int value; - EventCategory(int value) { + private EventCategory(int value) { this.value = value; } @@ -523,62 +400,18 @@ private Foo() { bar_ = ""; } - @Override + @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { return new Foo(); } - @Override + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } - private Foo( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000001; - bar_ = bs; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_Foo_descriptor; @@ -594,12 +427,13 @@ private Foo( private int bitField0_; public static final int BAR_FIELD_NUMBER = 1; - private volatile java.lang.Object bar_; + @SuppressWarnings("serial") + private volatile java.lang.Object bar_ = ""; /** * required string bar = 1; * @return Whether the bar field is set. */ - @Override + @java.lang.Override public boolean hasBar() { return ((bitField0_ & 0x00000001) != 0); } @@ -607,7 +441,7 @@ public boolean hasBar() { * required string bar = 1; * @return The bar. */ - @Override + @java.lang.Override public java.lang.String getBar() { java.lang.Object ref = bar_; if (ref instanceof java.lang.String) { @@ -626,7 +460,7 @@ public java.lang.String getBar() { * required string bar = 1; * @return The bytes for bar. */ - @Override + @java.lang.Override public com.google.protobuf.ByteString getBarBytes() { java.lang.Object ref = bar_; @@ -656,16 +490,16 @@ public final boolean isInitialized() { return true; } - @Override + @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) != 0)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, bar_); } - unknownFields.writeTo(output); + getUnknownFields().writeTo(output); } - @Override + @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; @@ -674,12 +508,12 @@ public int getSerializedSize() { if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, bar_); } - size += unknownFields.getSerializedSize(); + size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; } - @Override + @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; @@ -694,11 +528,11 @@ public boolean equals(final java.lang.Object obj) { if (!getBar() .equals(other.getBar())) return false; } - if (!unknownFields.equals(other.unknownFields)) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } - @Override + @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; @@ -709,7 +543,7 @@ public int hashCode() { hash = (37 * hash) + BAR_FIELD_NUMBER; hash = (53 * hash) + getBar().hashCode(); } - hash = (29 * hash) + unknownFields.hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; } @@ -826,39 +660,34 @@ public static final class Builder extends // Construct using org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.newBuilder() private Builder() { - maybeForceBuilderInitialization(); + } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } + } - @Override + @java.lang.Override public Builder clear() { super.clear(); + bitField0_ = 0; bar_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); return this; } - @Override + @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_Foo_descriptor; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getDefaultInstanceForType() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance(); } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo build() { org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo result = buildPartial(); if (!result.isInitialized()) { @@ -867,53 +696,57 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent return result; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo buildPartial() { org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo result = new org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo result) { int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) != 0)) { + result.bar_ = bar_; to_bitField0_ |= 0x00000001; } - result.bar_ = bar_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; + result.bitField0_ |= to_bitField0_; } - @Override + @java.lang.Override public Builder clone() { return super.clone(); } - @Override + @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); } - @Override + @java.lang.Override public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } - @Override + @java.lang.Override public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } - @Override + @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } - @Override + @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); } - @Override + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo) { return mergeFrom((org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo)other); @@ -926,16 +759,16 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo other) { if (other == org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance()) return this; if (other.hasBar()) { - bitField0_ |= 0x00000001; bar_ = other.bar_; + bitField0_ |= 0x00000001; onChanged(); } - this.mergeUnknownFields(other.unknownFields); + this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; } - @Override + @java.lang.Override public final boolean isInitialized() { if (!hasBar()) { return false; @@ -943,22 +776,40 @@ public final boolean isInitialized() { return true; } - @Override + @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo parsedMessage = null; + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + bar_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } + onChanged(); + } // finally return this; } private int bitField0_; @@ -968,7 +819,6 @@ public Builder mergeFrom( * required string bar = 1; * @return Whether the bar field is set. */ - @Override public boolean hasBar() { return ((bitField0_ & 0x00000001) != 0); } @@ -976,7 +826,6 @@ public boolean hasBar() { * required string bar = 1; * @return The bar. */ - @Override public java.lang.String getBar() { java.lang.Object ref = bar_; if (!(ref instanceof java.lang.String)) { @@ -995,7 +844,6 @@ public java.lang.String getBar() { * required string bar = 1; * @return The bytes for bar. */ - @Override public com.google.protobuf.ByteString getBarBytes() { java.lang.Object ref = bar_; @@ -1016,11 +864,9 @@ public java.lang.String getBar() { */ public Builder setBar( java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; + if (value == null) { throw new NullPointerException(); } bar_ = value; + bitField0_ |= 0x00000001; onChanged(); return this; } @@ -1029,8 +875,8 @@ public Builder setBar( * @return This builder for chaining. */ public Builder clearBar() { - bitField0_ = (bitField0_ & ~0x00000001); bar_ = getDefaultInstance().getBar(); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -1041,21 +887,19 @@ public Builder clearBar() { */ public Builder setBarBytes( com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; + if (value == null) { throw new NullPointerException(); } bar_ = value; + bitField0_ |= 0x00000001; onChanged(); return this; } - @Override + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } - @Override + @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); @@ -1077,12 +921,23 @@ public static org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTe @java.lang.Deprecated public static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - @Override + @java.lang.Override public Foo parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new Foo(input, extensionRegistry); + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); } }; @@ -1090,12 +945,12 @@ public static com.google.protobuf.Parser parser() { return PARSER; } - @Override + @java.lang.Override public com.google.protobuf.Parser getParserForType() { return PARSER; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getDefaultInstanceForType() { return DEFAULT_INSTANCE; } @@ -1104,31 +959,30 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent private int bitField0_; public static final int EVENTTYPE_FIELD_NUMBER = 1; - private int eventType_; + private int eventType_ = 0; /** * required .prototest.ProtoTestEvent.EventCategory eventType = 1; * @return Whether the eventType field is set. */ - @Override public boolean hasEventType() { + @java.lang.Override public boolean hasEventType() { return ((bitField0_ & 0x00000001) != 0); } /** * required .prototest.ProtoTestEvent.EventCategory eventType = 1; * @return The eventType. */ - @Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory getEventType() { - @SuppressWarnings("deprecation") - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory result = org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.valueOf(eventType_); + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory getEventType() { + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory result = org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.forNumber(eventType_); return result == null ? org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.CATEGORY_ZERO : result; } public static final int ID_FIELD_NUMBER = 2; - private long id_; + private long id_ = 0L; /** * required uint64 id = 2; * @return Whether the id field is set. */ - @Override + @java.lang.Override public boolean hasId() { return ((bitField0_ & 0x00000002) != 0); } @@ -1136,18 +990,19 @@ public boolean hasId() { * required uint64 id = 2; * @return The id. */ - @Override + @java.lang.Override public long getId() { return id_; } public static final int TIMESTAMP_FIELD_NUMBER = 3; - private volatile java.lang.Object timestamp_; + @SuppressWarnings("serial") + private volatile java.lang.Object timestamp_ = ""; /** * required string timestamp = 3; * @return Whether the timestamp field is set. */ - @Override + @java.lang.Override public boolean hasTimestamp() { return ((bitField0_ & 0x00000004) != 0); } @@ -1155,7 +1010,7 @@ public boolean hasTimestamp() { * required string timestamp = 3; * @return The timestamp. */ - @Override + @java.lang.Override public java.lang.String getTimestamp() { java.lang.Object ref = timestamp_; if (ref instanceof java.lang.String) { @@ -1174,7 +1029,7 @@ public java.lang.String getTimestamp() { * required string timestamp = 3; * @return The bytes for timestamp. */ - @Override + @java.lang.Override public com.google.protobuf.ByteString getTimestampBytes() { java.lang.Object ref = timestamp_; @@ -1190,12 +1045,12 @@ public java.lang.String getTimestamp() { } public static final int SOMEOTHERID_FIELD_NUMBER = 4; - private int someOtherId_; + private int someOtherId_ = 0; /** * optional uint32 someOtherId = 4; * @return Whether the someOtherId field is set. */ - @Override + @java.lang.Override public boolean hasSomeOtherId() { return ((bitField0_ & 0x00000008) != 0); } @@ -1203,18 +1058,18 @@ public boolean hasSomeOtherId() { * optional uint32 someOtherId = 4; * @return The someOtherId. */ - @Override + @java.lang.Override public int getSomeOtherId() { return someOtherId_; } public static final int ISVALID_FIELD_NUMBER = 5; - private boolean isValid_; + private boolean isValid_ = false; /** * optional bool isValid = 5; * @return Whether the isValid field is set. */ - @Override + @java.lang.Override public boolean hasIsValid() { return ((bitField0_ & 0x00000010) != 0); } @@ -1222,18 +1077,19 @@ public boolean hasIsValid() { * optional bool isValid = 5; * @return The isValid. */ - @Override + @java.lang.Override public boolean getIsValid() { return isValid_; } public static final int DESCRIPTION_FIELD_NUMBER = 6; - private volatile java.lang.Object description_; + @SuppressWarnings("serial") + private volatile java.lang.Object description_ = ""; /** * optional string description = 6; * @return Whether the description field is set. */ - @Override + @java.lang.Override public boolean hasDescription() { return ((bitField0_ & 0x00000020) != 0); } @@ -1241,7 +1097,7 @@ public boolean hasDescription() { * optional string description = 6; * @return The description. */ - @Override + @java.lang.Override public java.lang.String getDescription() { java.lang.Object ref = description_; if (ref instanceof java.lang.String) { @@ -1260,7 +1116,7 @@ public java.lang.String getDescription() { * optional string description = 6; * @return The bytes for description. */ - @Override + @java.lang.Override public com.google.protobuf.ByteString getDescriptionBytes() { java.lang.Object ref = description_; @@ -1276,12 +1132,12 @@ public java.lang.String getDescription() { } public static final int SOMEFLOATCOLUMN_FIELD_NUMBER = 7; - private float someFloatColumn_; + private float someFloatColumn_ = 0F; /** * optional float someFloatColumn = 7; * @return Whether the someFloatColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeFloatColumn() { return ((bitField0_ & 0x00000040) != 0); } @@ -1289,18 +1145,18 @@ public boolean hasSomeFloatColumn() { * optional float someFloatColumn = 7; * @return The someFloatColumn. */ - @Override + @java.lang.Override public float getSomeFloatColumn() { return someFloatColumn_; } public static final int SOMEINTCOLUMN_FIELD_NUMBER = 8; - private int someIntColumn_; + private int someIntColumn_ = 0; /** * optional uint32 someIntColumn = 8; * @return Whether the someIntColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeIntColumn() { return ((bitField0_ & 0x00000080) != 0); } @@ -1308,18 +1164,18 @@ public boolean hasSomeIntColumn() { * optional uint32 someIntColumn = 8; * @return The someIntColumn. */ - @Override + @java.lang.Override public int getSomeIntColumn() { return someIntColumn_; } public static final int SOMELONGCOLUMN_FIELD_NUMBER = 9; - private long someLongColumn_; + private long someLongColumn_ = 0L; /** * optional uint64 someLongColumn = 9; * @return Whether the someLongColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeLongColumn() { return ((bitField0_ & 0x00000100) != 0); } @@ -1327,105 +1183,125 @@ public boolean hasSomeLongColumn() { * optional uint64 someLongColumn = 9; * @return The someLongColumn. */ - @Override + @java.lang.Override public long getSomeLongColumn() { return someLongColumn_; } - public static final int FOO_FIELD_NUMBER = 10; + public static final int SOMEBYTESCOLUMN_FIELD_NUMBER = 10; + private com.google.protobuf.ByteString someBytesColumn_ = com.google.protobuf.ByteString.EMPTY; + /** + * required bytes someBytesColumn = 10; + * @return Whether the someBytesColumn field is set. + */ + @java.lang.Override + public boolean hasSomeBytesColumn() { + return ((bitField0_ & 0x00000200) != 0); + } + /** + * required bytes someBytesColumn = 10; + * @return The someBytesColumn. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSomeBytesColumn() { + return someBytesColumn_; + } + + public static final int FOO_FIELD_NUMBER = 11; private org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo foo_; /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return Whether the foo field is set. */ - @Override + @java.lang.Override public boolean hasFoo() { - return ((bitField0_ & 0x00000200) != 0); + return ((bitField0_ & 0x00000400) != 0); } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return The foo. */ - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getFoo() { return foo_ == null ? org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance() : foo_; } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getFooOrBuilder() { return foo_ == null ? org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance() : foo_; } - public static final int BAR_FIELD_NUMBER = 11; + public static final int BAR_FIELD_NUMBER = 12; + @SuppressWarnings("serial") private java.util.List bar_; /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override + @java.lang.Override public java.util.List getBarList() { return bar_; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override + @java.lang.Override public java.util.List getBarOrBuilderList() { return bar_; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override + @java.lang.Override public int getBarCount() { return bar_.size(); } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getBar(int index) { return bar_.get(index); } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getBarOrBuilder( int index) { return bar_.get(index); } - public static final int OTHERTIMESTAMP_FIELD_NUMBER = 12; + public static final int OTHERTIMESTAMP_FIELD_NUMBER = 13; private com.google.protobuf.Timestamp otherTimestamp_; /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return Whether the otherTimestamp field is set. */ - @Override + @java.lang.Override public boolean hasOtherTimestamp() { - return ((bitField0_ & 0x00000400) != 0); + return ((bitField0_ & 0x00000800) != 0); } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return The otherTimestamp. */ - @Override + @java.lang.Override public com.google.protobuf.Timestamp getOtherTimestamp() { return otherTimestamp_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : otherTimestamp_; } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ - @Override + @java.lang.Override public com.google.protobuf.TimestampOrBuilder getOtherTimestampOrBuilder() { return otherTimestamp_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : otherTimestamp_; } private byte memoizedIsInitialized = -1; - @Override + @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; @@ -1443,6 +1319,10 @@ public final boolean isInitialized() { memoizedIsInitialized = 0; return false; } + if (!hasSomeBytesColumn()) { + memoizedIsInitialized = 0; + return false; + } if (hasFoo()) { if (!getFoo().isInitialized()) { memoizedIsInitialized = 0; @@ -1459,7 +1339,7 @@ public final boolean isInitialized() { return true; } - @Override + @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) != 0)) { @@ -1490,18 +1370,21 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) output.writeUInt64(9, someLongColumn_); } if (((bitField0_ & 0x00000200) != 0)) { - output.writeMessage(10, getFoo()); + output.writeBytes(10, someBytesColumn_); + } + if (((bitField0_ & 0x00000400) != 0)) { + output.writeMessage(11, getFoo()); } for (int i = 0; i < bar_.size(); i++) { - output.writeMessage(11, bar_.get(i)); + output.writeMessage(12, bar_.get(i)); } - if (((bitField0_ & 0x00000400) != 0)) { - output.writeMessage(12, getOtherTimestamp()); + if (((bitField0_ & 0x00000800) != 0)) { + output.writeMessage(13, getOtherTimestamp()); } - unknownFields.writeTo(output); + getUnknownFields().writeTo(output); } - @Override + @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; @@ -1543,22 +1426,26 @@ public int getSerializedSize() { } if (((bitField0_ & 0x00000200) != 0)) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(10, getFoo()); + .computeBytesSize(10, someBytesColumn_); + } + if (((bitField0_ & 0x00000400) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, getFoo()); } for (int i = 0; i < bar_.size(); i++) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(11, bar_.get(i)); + .computeMessageSize(12, bar_.get(i)); } - if (((bitField0_ & 0x00000400) != 0)) { + if (((bitField0_ & 0x00000800) != 0)) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(12, getOtherTimestamp()); + .computeMessageSize(13, getOtherTimestamp()); } - size += unknownFields.getSerializedSize(); + size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; } - @Override + @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; @@ -1613,6 +1500,11 @@ public boolean equals(final java.lang.Object obj) { if (getSomeLongColumn() != other.getSomeLongColumn()) return false; } + if (hasSomeBytesColumn() != other.hasSomeBytesColumn()) return false; + if (hasSomeBytesColumn()) { + if (!getSomeBytesColumn() + .equals(other.getSomeBytesColumn())) return false; + } if (hasFoo() != other.hasFoo()) return false; if (hasFoo()) { if (!getFoo() @@ -1625,11 +1517,11 @@ public boolean equals(final java.lang.Object obj) { if (!getOtherTimestamp() .equals(other.getOtherTimestamp())) return false; } - if (!unknownFields.equals(other.unknownFields)) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } - @Override + @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; @@ -1676,6 +1568,10 @@ public int hashCode() { hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getSomeLongColumn()); } + if (hasSomeBytesColumn()) { + hash = (37 * hash) + SOMEBYTESCOLUMN_FIELD_NUMBER; + hash = (53 * hash) + getSomeBytesColumn().hashCode(); + } if (hasFoo()) { hash = (37 * hash) + FOO_FIELD_NUMBER; hash = (53 * hash) + getFoo().hashCode(); @@ -1688,7 +1584,7 @@ public int hashCode() { hash = (37 * hash) + OTHERTIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + getOtherTimestamp().hashCode(); } - hash = (29 * hash) + unknownFields.hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; } @@ -1763,7 +1659,7 @@ public static org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTe .parseWithIOException(PARSER, input, extensionRegistry); } - @Override + @java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); @@ -1771,13 +1667,13 @@ public static Builder newBuilder() { public static Builder newBuilder(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } - @Override + @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } - @Override + @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); @@ -1795,7 +1691,7 @@ public static final class Builder extends return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_descriptor; } - @Override + @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_fieldAccessorTable @@ -1821,60 +1717,52 @@ private void maybeForceBuilderInitialization() { getOtherTimestampFieldBuilder(); } } - @Override + @java.lang.Override public Builder clear() { super.clear(); + bitField0_ = 0; eventType_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); id_ = 0L; - bitField0_ = (bitField0_ & ~0x00000002); timestamp_ = ""; - bitField0_ = (bitField0_ & ~0x00000004); someOtherId_ = 0; - bitField0_ = (bitField0_ & ~0x00000008); isValid_ = false; - bitField0_ = (bitField0_ & ~0x00000010); description_ = ""; - bitField0_ = (bitField0_ & ~0x00000020); someFloatColumn_ = 0F; - bitField0_ = (bitField0_ & ~0x00000040); someIntColumn_ = 0; - bitField0_ = (bitField0_ & ~0x00000080); someLongColumn_ = 0L; - bitField0_ = (bitField0_ & ~0x00000100); - if (fooBuilder_ == null) { - foo_ = null; - } else { - fooBuilder_.clear(); + someBytesColumn_ = com.google.protobuf.ByteString.EMPTY; + foo_ = null; + if (fooBuilder_ != null) { + fooBuilder_.dispose(); + fooBuilder_ = null; } - bitField0_ = (bitField0_ & ~0x00000200); if (barBuilder_ == null) { bar_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); } else { + bar_ = null; barBuilder_.clear(); } - if (otherTimestampBuilder_ == null) { - otherTimestamp_ = null; - } else { - otherTimestampBuilder_.clear(); - } bitField0_ = (bitField0_ & ~0x00000800); + otherTimestamp_ = null; + if (otherTimestampBuilder_ != null) { + otherTimestampBuilder_.dispose(); + otherTimestampBuilder_ = null; + } return this; } - @Override + @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.internal_static_prototest_ProtoTestEvent_descriptor; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent getDefaultInstanceForType() { return org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.getDefaultInstance(); } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent build() { org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent result = buildPartial(); if (!result.isInitialized()) { @@ -1883,23 +1771,42 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent return result; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent buildPartial() { org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent result = new org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent result) { + if (barBuilder_ == null) { + if (((bitField0_ & 0x00000800) != 0)) { + bar_ = java.util.Collections.unmodifiableList(bar_); + bitField0_ = (bitField0_ & ~0x00000800); + } + result.bar_ = bar_; + } else { + result.bar_ = barBuilder_.build(); + } + } + + private void buildPartial0(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent result) { int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) != 0)) { + result.eventType_ = eventType_; to_bitField0_ |= 0x00000001; } - result.eventType_ = eventType_; if (((from_bitField0_ & 0x00000002) != 0)) { result.id_ = id_; to_bitField0_ |= 0x00000002; } if (((from_bitField0_ & 0x00000004) != 0)) { + result.timestamp_ = timestamp_; to_bitField0_ |= 0x00000004; } - result.timestamp_ = timestamp_; if (((from_bitField0_ & 0x00000008) != 0)) { result.someOtherId_ = someOtherId_; to_bitField0_ |= 0x00000008; @@ -1909,9 +1816,9 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent to_bitField0_ |= 0x00000010; } if (((from_bitField0_ & 0x00000020) != 0)) { + result.description_ = description_; to_bitField0_ |= 0x00000020; } - result.description_ = description_; if (((from_bitField0_ & 0x00000040) != 0)) { result.someFloatColumn_ = someFloatColumn_; to_bitField0_ |= 0x00000040; @@ -1925,68 +1832,57 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent to_bitField0_ |= 0x00000100; } if (((from_bitField0_ & 0x00000200) != 0)) { - if (fooBuilder_ == null) { - result.foo_ = foo_; - } else { - result.foo_ = fooBuilder_.build(); - } + result.someBytesColumn_ = someBytesColumn_; to_bitField0_ |= 0x00000200; } - if (barBuilder_ == null) { - if (((bitField0_ & 0x00000400) != 0)) { - bar_ = java.util.Collections.unmodifiableList(bar_); - bitField0_ = (bitField0_ & ~0x00000400); - } - result.bar_ = bar_; - } else { - result.bar_ = barBuilder_.build(); - } - if (((from_bitField0_ & 0x00000800) != 0)) { - if (otherTimestampBuilder_ == null) { - result.otherTimestamp_ = otherTimestamp_; - } else { - result.otherTimestamp_ = otherTimestampBuilder_.build(); - } + if (((from_bitField0_ & 0x00000400) != 0)) { + result.foo_ = fooBuilder_ == null + ? foo_ + : fooBuilder_.build(); to_bitField0_ |= 0x00000400; } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; + if (((from_bitField0_ & 0x00001000) != 0)) { + result.otherTimestamp_ = otherTimestampBuilder_ == null + ? otherTimestamp_ + : otherTimestampBuilder_.build(); + to_bitField0_ |= 0x00000800; + } + result.bitField0_ |= to_bitField0_; } - @Override + @java.lang.Override public Builder clone() { return super.clone(); } - @Override + @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); } - @Override + @java.lang.Override public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } - @Override + @java.lang.Override public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } - @Override + @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } - @Override + @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); } - @Override + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent) { return mergeFrom((org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent)other); @@ -2005,8 +1901,8 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap setId(other.getId()); } if (other.hasTimestamp()) { - bitField0_ |= 0x00000004; timestamp_ = other.timestamp_; + bitField0_ |= 0x00000004; onChanged(); } if (other.hasSomeOtherId()) { @@ -2016,8 +1912,8 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap setIsValid(other.getIsValid()); } if (other.hasDescription()) { - bitField0_ |= 0x00000020; description_ = other.description_; + bitField0_ |= 0x00000020; onChanged(); } if (other.hasSomeFloatColumn()) { @@ -2029,6 +1925,9 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap if (other.hasSomeLongColumn()) { setSomeLongColumn(other.getSomeLongColumn()); } + if (other.hasSomeBytesColumn()) { + setSomeBytesColumn(other.getSomeBytesColumn()); + } if (other.hasFoo()) { mergeFoo(other.getFoo()); } @@ -2036,7 +1935,7 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap if (!other.bar_.isEmpty()) { if (bar_.isEmpty()) { bar_ = other.bar_; - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00000800); } else { ensureBarIsMutable(); bar_.addAll(other.bar_); @@ -2049,7 +1948,7 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap barBuilder_.dispose(); barBuilder_ = null; bar_ = other.bar_; - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00000800); barBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getBarFieldBuilder() : null; @@ -2061,12 +1960,12 @@ public Builder mergeFrom(org.apache.druid.data.input.protobuf.ProtoTestEventWrap if (other.hasOtherTimestamp()) { mergeOtherTimestamp(other.getOtherTimestamp()); } - this.mergeUnknownFields(other.unknownFields); + this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; } - @Override + @java.lang.Override public final boolean isInitialized() { if (!hasEventType()) { return false; @@ -2077,6 +1976,9 @@ public final boolean isInitialized() { if (!hasTimestamp()) { return false; } + if (!hasSomeBytesColumn()) { + return false; + } if (hasFoo()) { if (!getFoo().isInitialized()) { return false; @@ -2090,22 +1992,119 @@ public final boolean isInitialized() { return true; } - @Override + @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent parsedMessage = null; + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int tmpRaw = input.readEnum(); + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory tmpValue = + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.forNumber(tmpRaw); + if (tmpValue == null) { + mergeUnknownVarintField(1, tmpRaw); + } else { + eventType_ = tmpRaw; + bitField0_ |= 0x00000001; + } + break; + } // case 8 + case 16: { + id_ = input.readUInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: { + timestamp_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: { + someOtherId_ = input.readUInt32(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 40: { + isValid_ = input.readBool(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 50: { + description_ = input.readBytes(); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 61: { + someFloatColumn_ = input.readFloat(); + bitField0_ |= 0x00000040; + break; + } // case 61 + case 64: { + someIntColumn_ = input.readUInt32(); + bitField0_ |= 0x00000080; + break; + } // case 64 + case 72: { + someLongColumn_ = input.readUInt64(); + bitField0_ |= 0x00000100; + break; + } // case 72 + case 82: { + someBytesColumn_ = input.readBytes(); + bitField0_ |= 0x00000200; + break; + } // case 82 + case 90: { + input.readMessage( + getFooFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000400; + break; + } // case 90 + case 98: { + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo m = + input.readMessage( + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.PARSER, + extensionRegistry); + if (barBuilder_ == null) { + ensureBarIsMutable(); + bar_.add(m); + } else { + barBuilder_.addMessage(m); + } + break; + } // case 98 + case 106: { + input.readMessage( + getOtherTimestampFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00001000; + break; + } // case 106 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } + onChanged(); + } // finally return this; } private int bitField0_; @@ -2115,17 +2114,16 @@ public Builder mergeFrom( * required .prototest.ProtoTestEvent.EventCategory eventType = 1; * @return Whether the eventType field is set. */ - @Override public boolean hasEventType() { + @java.lang.Override public boolean hasEventType() { return ((bitField0_ & 0x00000001) != 0); } /** * required .prototest.ProtoTestEvent.EventCategory eventType = 1; * @return The eventType. */ - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory getEventType() { - @SuppressWarnings("deprecation") - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory result = org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.valueOf(eventType_); + org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory result = org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.forNumber(eventType_); return result == null ? org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.EventCategory.CATEGORY_ZERO : result; } /** @@ -2158,7 +2156,7 @@ public Builder clearEventType() { * required uint64 id = 2; * @return Whether the id field is set. */ - @Override + @java.lang.Override public boolean hasId() { return ((bitField0_ & 0x00000002) != 0); } @@ -2166,7 +2164,7 @@ public boolean hasId() { * required uint64 id = 2; * @return The id. */ - @Override + @java.lang.Override public long getId() { return id_; } @@ -2176,8 +2174,9 @@ public long getId() { * @return This builder for chaining. */ public Builder setId(long value) { - bitField0_ |= 0x00000002; + id_ = value; + bitField0_ |= 0x00000002; onChanged(); return this; } @@ -2197,7 +2196,6 @@ public Builder clearId() { * required string timestamp = 3; * @return Whether the timestamp field is set. */ - @Override public boolean hasTimestamp() { return ((bitField0_ & 0x00000004) != 0); } @@ -2205,7 +2203,6 @@ public boolean hasTimestamp() { * required string timestamp = 3; * @return The timestamp. */ - @Override public java.lang.String getTimestamp() { java.lang.Object ref = timestamp_; if (!(ref instanceof java.lang.String)) { @@ -2224,7 +2221,6 @@ public java.lang.String getTimestamp() { * required string timestamp = 3; * @return The bytes for timestamp. */ - @Override public com.google.protobuf.ByteString getTimestampBytes() { java.lang.Object ref = timestamp_; @@ -2245,11 +2241,9 @@ public java.lang.String getTimestamp() { */ public Builder setTimestamp( java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; + if (value == null) { throw new NullPointerException(); } timestamp_ = value; + bitField0_ |= 0x00000004; onChanged(); return this; } @@ -2258,8 +2252,8 @@ public Builder setTimestamp( * @return This builder for chaining. */ public Builder clearTimestamp() { - bitField0_ = (bitField0_ & ~0x00000004); timestamp_ = getDefaultInstance().getTimestamp(); + bitField0_ = (bitField0_ & ~0x00000004); onChanged(); return this; } @@ -2270,11 +2264,9 @@ public Builder clearTimestamp() { */ public Builder setTimestampBytes( com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; + if (value == null) { throw new NullPointerException(); } timestamp_ = value; + bitField0_ |= 0x00000004; onChanged(); return this; } @@ -2284,7 +2276,7 @@ public Builder setTimestampBytes( * optional uint32 someOtherId = 4; * @return Whether the someOtherId field is set. */ - @Override + @java.lang.Override public boolean hasSomeOtherId() { return ((bitField0_ & 0x00000008) != 0); } @@ -2292,7 +2284,7 @@ public boolean hasSomeOtherId() { * optional uint32 someOtherId = 4; * @return The someOtherId. */ - @Override + @java.lang.Override public int getSomeOtherId() { return someOtherId_; } @@ -2302,8 +2294,9 @@ public int getSomeOtherId() { * @return This builder for chaining. */ public Builder setSomeOtherId(int value) { - bitField0_ |= 0x00000008; + someOtherId_ = value; + bitField0_ |= 0x00000008; onChanged(); return this; } @@ -2323,7 +2316,7 @@ public Builder clearSomeOtherId() { * optional bool isValid = 5; * @return Whether the isValid field is set. */ - @Override + @java.lang.Override public boolean hasIsValid() { return ((bitField0_ & 0x00000010) != 0); } @@ -2331,7 +2324,7 @@ public boolean hasIsValid() { * optional bool isValid = 5; * @return The isValid. */ - @Override + @java.lang.Override public boolean getIsValid() { return isValid_; } @@ -2341,8 +2334,9 @@ public boolean getIsValid() { * @return This builder for chaining. */ public Builder setIsValid(boolean value) { - bitField0_ |= 0x00000010; + isValid_ = value; + bitField0_ |= 0x00000010; onChanged(); return this; } @@ -2362,7 +2356,6 @@ public Builder clearIsValid() { * optional string description = 6; * @return Whether the description field is set. */ - @Override public boolean hasDescription() { return ((bitField0_ & 0x00000020) != 0); } @@ -2370,7 +2363,6 @@ public boolean hasDescription() { * optional string description = 6; * @return The description. */ - @Override public java.lang.String getDescription() { java.lang.Object ref = description_; if (!(ref instanceof java.lang.String)) { @@ -2389,7 +2381,6 @@ public java.lang.String getDescription() { * optional string description = 6; * @return The bytes for description. */ - @Override public com.google.protobuf.ByteString getDescriptionBytes() { java.lang.Object ref = description_; @@ -2410,11 +2401,9 @@ public java.lang.String getDescription() { */ public Builder setDescription( java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000020; + if (value == null) { throw new NullPointerException(); } description_ = value; + bitField0_ |= 0x00000020; onChanged(); return this; } @@ -2423,8 +2412,8 @@ public Builder setDescription( * @return This builder for chaining. */ public Builder clearDescription() { - bitField0_ = (bitField0_ & ~0x00000020); description_ = getDefaultInstance().getDescription(); + bitField0_ = (bitField0_ & ~0x00000020); onChanged(); return this; } @@ -2435,11 +2424,9 @@ public Builder clearDescription() { */ public Builder setDescriptionBytes( com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000020; + if (value == null) { throw new NullPointerException(); } description_ = value; + bitField0_ |= 0x00000020; onChanged(); return this; } @@ -2449,7 +2436,7 @@ public Builder setDescriptionBytes( * optional float someFloatColumn = 7; * @return Whether the someFloatColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeFloatColumn() { return ((bitField0_ & 0x00000040) != 0); } @@ -2457,7 +2444,7 @@ public boolean hasSomeFloatColumn() { * optional float someFloatColumn = 7; * @return The someFloatColumn. */ - @Override + @java.lang.Override public float getSomeFloatColumn() { return someFloatColumn_; } @@ -2467,8 +2454,9 @@ public float getSomeFloatColumn() { * @return This builder for chaining. */ public Builder setSomeFloatColumn(float value) { - bitField0_ |= 0x00000040; + someFloatColumn_ = value; + bitField0_ |= 0x00000040; onChanged(); return this; } @@ -2488,7 +2476,7 @@ public Builder clearSomeFloatColumn() { * optional uint32 someIntColumn = 8; * @return Whether the someIntColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeIntColumn() { return ((bitField0_ & 0x00000080) != 0); } @@ -2496,7 +2484,7 @@ public boolean hasSomeIntColumn() { * optional uint32 someIntColumn = 8; * @return The someIntColumn. */ - @Override + @java.lang.Override public int getSomeIntColumn() { return someIntColumn_; } @@ -2506,8 +2494,9 @@ public int getSomeIntColumn() { * @return This builder for chaining. */ public Builder setSomeIntColumn(int value) { - bitField0_ |= 0x00000080; + someIntColumn_ = value; + bitField0_ |= 0x00000080; onChanged(); return this; } @@ -2527,7 +2516,7 @@ public Builder clearSomeIntColumn() { * optional uint64 someLongColumn = 9; * @return Whether the someLongColumn field is set. */ - @Override + @java.lang.Override public boolean hasSomeLongColumn() { return ((bitField0_ & 0x00000100) != 0); } @@ -2535,7 +2524,7 @@ public boolean hasSomeLongColumn() { * optional uint64 someLongColumn = 9; * @return The someLongColumn. */ - @Override + @java.lang.Override public long getSomeLongColumn() { return someLongColumn_; } @@ -2545,8 +2534,9 @@ public long getSomeLongColumn() { * @return This builder for chaining. */ public Builder setSomeLongColumn(long value) { - bitField0_ |= 0x00000100; + someLongColumn_ = value; + bitField0_ |= 0x00000100; onChanged(); return this; } @@ -2561,22 +2551,60 @@ public Builder clearSomeLongColumn() { return this; } + private com.google.protobuf.ByteString someBytesColumn_ = com.google.protobuf.ByteString.EMPTY; + /** + * required bytes someBytesColumn = 10; + * @return Whether the someBytesColumn field is set. + */ + @java.lang.Override + public boolean hasSomeBytesColumn() { + return ((bitField0_ & 0x00000200) != 0); + } + /** + * required bytes someBytesColumn = 10; + * @return The someBytesColumn. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSomeBytesColumn() { + return someBytesColumn_; + } + /** + * required bytes someBytesColumn = 10; + * @param value The someBytesColumn to set. + * @return This builder for chaining. + */ + public Builder setSomeBytesColumn(com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + someBytesColumn_ = value; + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + /** + * required bytes someBytesColumn = 10; + * @return This builder for chaining. + */ + public Builder clearSomeBytesColumn() { + bitField0_ = (bitField0_ & ~0x00000200); + someBytesColumn_ = getDefaultInstance().getSomeBytesColumn(); + onChanged(); + return this; + } + private org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo foo_; private com.google.protobuf.SingleFieldBuilderV3< org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder> fooBuilder_; /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return Whether the foo field is set. */ - @Override public boolean hasFoo() { - return ((bitField0_ & 0x00000200) != 0); + return ((bitField0_ & 0x00000400) != 0); } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; * @return The foo. */ - @Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getFoo() { if (fooBuilder_ == null) { return foo_ == null ? org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance() : foo_; @@ -2585,7 +2613,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent } } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ public Builder setFoo(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo value) { if (fooBuilder_ == null) { @@ -2593,72 +2621,70 @@ public Builder setFoo(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper throw new NullPointerException(); } foo_ = value; - onChanged(); } else { fooBuilder_.setMessage(value); } - bitField0_ |= 0x00000200; + bitField0_ |= 0x00000400; + onChanged(); return this; } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ public Builder setFoo( org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder builderForValue) { if (fooBuilder_ == null) { foo_ = builderForValue.build(); - onChanged(); } else { fooBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00000200; + bitField0_ |= 0x00000400; + onChanged(); return this; } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ public Builder mergeFoo(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo value) { if (fooBuilder_ == null) { - if (((bitField0_ & 0x00000200) != 0) && - foo_ != null && - foo_ != org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance()) { - foo_ = - org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.newBuilder(foo_).mergeFrom(value).buildPartial(); + if (((bitField0_ & 0x00000400) != 0) && + foo_ != null && + foo_ != org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance()) { + getFooBuilder().mergeFrom(value); } else { foo_ = value; } - onChanged(); } else { fooBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000200; + bitField0_ |= 0x00000400; + onChanged(); return this; } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ public Builder clearFoo() { - if (fooBuilder_ == null) { - foo_ = null; - onChanged(); - } else { - fooBuilder_.clear(); + bitField0_ = (bitField0_ & ~0x00000400); + foo_ = null; + if (fooBuilder_ != null) { + fooBuilder_.dispose(); + fooBuilder_ = null; } - bitField0_ = (bitField0_ & ~0x00000200); + onChanged(); return this; } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder getFooBuilder() { - bitField0_ |= 0x00000200; + bitField0_ |= 0x00000400; onChanged(); return getFooFieldBuilder().getBuilder(); } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ - @Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getFooOrBuilder() { if (fooBuilder_ != null) { return fooBuilder_.getMessageOrBuilder(); @@ -2668,7 +2694,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent } } /** - * optional .prototest.ProtoTestEvent.Foo foo = 10; + * optional .prototest.ProtoTestEvent.Foo foo = 11; */ private com.google.protobuf.SingleFieldBuilderV3< org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder> @@ -2687,9 +2713,9 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent private java.util.List bar_ = java.util.Collections.emptyList(); private void ensureBarIsMutable() { - if (!((bitField0_ & 0x00000400) != 0)) { + if (!((bitField0_ & 0x00000800) != 0)) { bar_ = new java.util.ArrayList(bar_); - bitField0_ |= 0x00000400; + bitField0_ |= 0x00000800; } } @@ -2697,9 +2723,8 @@ private void ensureBarIsMutable() { org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder> barBuilder_; /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override public java.util.List getBarList() { if (barBuilder_ == null) { return java.util.Collections.unmodifiableList(bar_); @@ -2708,9 +2733,8 @@ public java.util.Listrepeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override public int getBarCount() { if (barBuilder_ == null) { return bar_.size(); @@ -2719,9 +2743,8 @@ public int getBarCount() { } } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo getBar(int index) { if (barBuilder_ == null) { return bar_.get(index); @@ -2730,7 +2753,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent } } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder setBar( int index, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo value) { @@ -2747,7 +2770,7 @@ public Builder setBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder setBar( int index, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder builderForValue) { @@ -2761,7 +2784,7 @@ public Builder setBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder addBar(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo value) { if (barBuilder_ == null) { @@ -2777,7 +2800,7 @@ public Builder addBar(org.apache.druid.data.input.protobuf.ProtoTestEventWrapper return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder addBar( int index, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo value) { @@ -2794,7 +2817,7 @@ public Builder addBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder addBar( org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder builderForValue) { @@ -2808,7 +2831,7 @@ public Builder addBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder addBar( int index, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder builderForValue) { @@ -2822,7 +2845,7 @@ public Builder addBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder addAllBar( java.lang.Iterable values) { @@ -2837,12 +2860,12 @@ public Builder addAllBar( return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder clearBar() { if (barBuilder_ == null) { bar_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00000800); onChanged(); } else { barBuilder_.clear(); @@ -2850,7 +2873,7 @@ public Builder clearBar() { return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public Builder removeBar(int index) { if (barBuilder_ == null) { @@ -2863,16 +2886,15 @@ public Builder removeBar(int index) { return this; } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder getBarBuilder( int index) { return getBarFieldBuilder().getBuilder(index); } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder getBarOrBuilder( int index) { if (barBuilder_ == null) { @@ -2881,10 +2903,9 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent } } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ - @Override - public java.util.List + public java.util.List getBarOrBuilderList() { if (barBuilder_ != null) { return barBuilder_.getMessageOrBuilderList(); @@ -2893,14 +2914,14 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent } } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder addBarBuilder() { return getBarFieldBuilder().addBuilder( org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance()); } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder addBarBuilder( int index) { @@ -2908,7 +2929,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent index, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.getDefaultInstance()); } /** - * repeated .prototest.ProtoTestEvent.Foo bar = 11; + * repeated .prototest.ProtoTestEvent.Foo bar = 12; */ public java.util.List getBarBuilderList() { @@ -2921,7 +2942,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent barBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.Foo.Builder, org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent.FooOrBuilder>( bar_, - ((bitField0_ & 0x00000400) != 0), + ((bitField0_ & 0x00000800) != 0), getParentForChildren(), isClean()); bar_ = null; @@ -2933,18 +2954,16 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> otherTimestampBuilder_; /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return Whether the otherTimestamp field is set. */ - @Override public boolean hasOtherTimestamp() { - return ((bitField0_ & 0x00000800) != 0); + return ((bitField0_ & 0x00001000) != 0); } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; * @return The otherTimestamp. */ - @Override public com.google.protobuf.Timestamp getOtherTimestamp() { if (otherTimestampBuilder_ == null) { return otherTimestamp_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : otherTimestamp_; @@ -2953,7 +2972,7 @@ public com.google.protobuf.Timestamp getOtherTimestamp() { } } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ public Builder setOtherTimestamp(com.google.protobuf.Timestamp value) { if (otherTimestampBuilder_ == null) { @@ -2961,72 +2980,70 @@ public Builder setOtherTimestamp(com.google.protobuf.Timestamp value) { throw new NullPointerException(); } otherTimestamp_ = value; - onChanged(); } else { otherTimestampBuilder_.setMessage(value); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00001000; + onChanged(); return this; } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ public Builder setOtherTimestamp( com.google.protobuf.Timestamp.Builder builderForValue) { if (otherTimestampBuilder_ == null) { otherTimestamp_ = builderForValue.build(); - onChanged(); } else { otherTimestampBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00001000; + onChanged(); return this; } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ public Builder mergeOtherTimestamp(com.google.protobuf.Timestamp value) { if (otherTimestampBuilder_ == null) { - if (((bitField0_ & 0x00000800) != 0) && - otherTimestamp_ != null && - otherTimestamp_ != com.google.protobuf.Timestamp.getDefaultInstance()) { - otherTimestamp_ = - com.google.protobuf.Timestamp.newBuilder(otherTimestamp_).mergeFrom(value).buildPartial(); + if (((bitField0_ & 0x00001000) != 0) && + otherTimestamp_ != null && + otherTimestamp_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getOtherTimestampBuilder().mergeFrom(value); } else { otherTimestamp_ = value; } - onChanged(); } else { otherTimestampBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00001000; + onChanged(); return this; } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ public Builder clearOtherTimestamp() { - if (otherTimestampBuilder_ == null) { - otherTimestamp_ = null; - onChanged(); - } else { - otherTimestampBuilder_.clear(); + bitField0_ = (bitField0_ & ~0x00001000); + otherTimestamp_ = null; + if (otherTimestampBuilder_ != null) { + otherTimestampBuilder_.dispose(); + otherTimestampBuilder_ = null; } - bitField0_ = (bitField0_ & ~0x00000800); + onChanged(); return this; } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ public com.google.protobuf.Timestamp.Builder getOtherTimestampBuilder() { - bitField0_ |= 0x00000800; + bitField0_ |= 0x00001000; onChanged(); return getOtherTimestampFieldBuilder().getBuilder(); } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ - @Override public com.google.protobuf.TimestampOrBuilder getOtherTimestampOrBuilder() { if (otherTimestampBuilder_ != null) { return otherTimestampBuilder_.getMessageOrBuilder(); @@ -3036,7 +3053,7 @@ public com.google.protobuf.TimestampOrBuilder getOtherTimestampOrBuilder() { } } /** - * optional .google.protobuf.Timestamp otherTimestamp = 12; + * optional .google.protobuf.Timestamp otherTimestamp = 13; */ private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> @@ -3051,13 +3068,13 @@ public com.google.protobuf.TimestampOrBuilder getOtherTimestampOrBuilder() { } return otherTimestampBuilder_; } - @Override + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } - @Override + @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); @@ -3079,12 +3096,23 @@ public static org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTe @java.lang.Deprecated public static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - @Override + @java.lang.Override public ProtoTestEvent parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new ProtoTestEvent(input, extensionRegistry); + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); } }; @@ -3092,12 +3120,12 @@ public static com.google.protobuf.Parser parser() { return PARSER; } - @Override + @java.lang.Override public com.google.protobuf.Parser getParserForType() { return PARSER; } - @Override + @java.lang.Override public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent getDefaultInstanceForType() { return DEFAULT_INSTANCE; } @@ -3123,21 +3151,22 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent descriptor; static { java.lang.String[] descriptorData = { - "\n\017Prototest.proto\022\tprototest\032\037google/pro" + - "tobuf/timestamp.proto\"\326\003\n\016ProtoTestEvent" + + "\n\017ProtoTest.proto\022\tprototest\032\037google/pro" + + "tobuf/timestamp.proto\"\357\003\n\016ProtoTestEvent" + "\022:\n\teventType\030\001 \002(\0162\'.prototest.ProtoTes" + "tEvent.EventCategory\022\n\n\002id\030\002 \002(\004\022\021\n\ttime" + "stamp\030\003 \002(\t\022\023\n\013someOtherId\030\004 \001(\r\022\017\n\007isVa" + "lid\030\005 \001(\010\022\023\n\013description\030\006 \001(\t\022\027\n\017someFl" + "oatColumn\030\007 \001(\002\022\025\n\rsomeIntColumn\030\010 \001(\r\022\026" + - "\n\016someLongColumn\030\t \001(\004\022*\n\003foo\030\n \001(\0132\035.pr" + - "ototest.ProtoTestEvent.Foo\022*\n\003bar\030\013 \003(\0132" + - "\035.prototest.ProtoTestEvent.Foo\0222\n\016otherT" + - "imestamp\030\014 \001(\0132\032.google.protobuf.Timesta" + - "mp\032\022\n\003Foo\022\013\n\003bar\030\001 \002(\t\"F\n\rEventCategory\022" + - "\021\n\rCATEGORY_ZERO\020\000\022\020\n\014CATEGORY_ONE\020\001\022\020\n\014" + - "CATEGORY_TWO\020\002B=\n$org.apache.druid.data." + - "input.protobufB\025ProtoTestEventWrapper" + "\n\016someLongColumn\030\t \001(\004\022\027\n\017someBytesColum" + + "n\030\n \002(\014\022*\n\003foo\030\013 \001(\0132\035.prototest.ProtoTe" + + "stEvent.Foo\022*\n\003bar\030\014 \003(\0132\035.prototest.Pro" + + "toTestEvent.Foo\0222\n\016otherTimestamp\030\r \001(\0132" + + "\032.google.protobuf.Timestamp\032\022\n\003Foo\022\013\n\003ba" + + "r\030\001 \002(\t\"F\n\rEventCategory\022\021\n\rCATEGORY_ZER" + + "O\020\000\022\020\n\014CATEGORY_ONE\020\001\022\020\n\014CATEGORY_TWO\020\002B" + + "=\n$org.apache.druid.data.input.protobufB" + + "\025ProtoTestEventWrapper" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -3149,7 +3178,7 @@ public org.apache.druid.data.input.protobuf.ProtoTestEventWrapper.ProtoTestEvent internal_static_prototest_ProtoTestEvent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_prototest_ProtoTestEvent_descriptor, - new java.lang.String[] { "EventType", "Id", "Timestamp", "SomeOtherId", "IsValid", "Description", "SomeFloatColumn", "SomeIntColumn", "SomeLongColumn", "Foo", "Bar", "OtherTimestamp", }); + new java.lang.String[] { "EventType", "Id", "Timestamp", "SomeOtherId", "IsValid", "Description", "SomeFloatColumn", "SomeIntColumn", "SomeLongColumn", "SomeBytesColumn", "Foo", "Bar", "OtherTimestamp", }); internal_static_prototest_ProtoTestEvent_Foo_descriptor = internal_static_prototest_ProtoTestEvent_descriptor.getNestedTypes().get(0); internal_static_prototest_ProtoTestEvent_Foo_fieldAccessorTable = new diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputFormatTest.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputFormatTest.java index 1d0cfe916656..0b5d096449c0 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputFormatTest.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputFormatTest.java @@ -81,7 +81,8 @@ public void setUp() throws Exception new StringDimensionSchema("event"), new StringDimensionSchema("id"), new StringDimensionSchema("someOtherId"), - new StringDimensionSchema("isValid") + new StringDimensionSchema("isValid"), + new StringDimensionSchema("someBytesColumn") )); flattenSpec = new JSONPathSpec( true, @@ -161,6 +162,7 @@ public void testParseFlattenData() throws Exception .add("id") .add("someOtherId") .add("isValid") + .add("someBytesColumn") .build(), row.getDimensions() ); @@ -202,6 +204,7 @@ public void testParseFlattenDataJq() throws Exception .add("id") .add("someOtherId") .add("isValid") + .add("someBytesColumn") .build(), row.getDimensions() ); @@ -239,6 +242,7 @@ public void testParseFlattenDataDiscover() throws Exception .add("someLongColumn") .add("someFloatColumn") .add("id") + .add("someBytesColumn") .add("timestamp") .build(), row.getDimensions() @@ -272,7 +276,8 @@ public void testParseNestedData() throws Exception new StringDimensionSchema("isValid"), new StringDimensionSchema("eventType"), new NestedDataDimensionSchema("foo"), - new NestedDataDimensionSchema("bar") + new NestedDataDimensionSchema("bar"), + new StringDimensionSchema("someBytesColumn") ) ), null @@ -305,6 +310,7 @@ public void testParseNestedData() throws Exception .add("eventType") .add("foo") .add("bar") + .add("someBytesColumn") .build(), row.getDimensions() ); @@ -314,6 +320,10 @@ public void testParseNestedData() throws Exception ImmutableList.of(ImmutableMap.of("bar", "bar0"), ImmutableMap.of("bar", "bar1")), row.getRaw("bar") ); + Assert.assertArrayEquals( + new byte[]{0x01, 0x02, 0x03, 0x04}, + (byte[]) row.getRaw("someBytesColumn") + ); ProtobufInputRowParserTest.verifyNestedData(row, dateTime); } @@ -386,7 +396,7 @@ public void testParseFlatData() throws Exception null ).read().next(); - ProtobufInputRowParserTest.verifyFlatData(row, dateTime); + ProtobufInputRowParserTest.verifyFlatData(row, dateTime, false); } @Test diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputRowParserTest.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputRowParserTest.java index dbcf4d3b31b3..9ac9fec36561 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputRowParserTest.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufInputRowParserTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.protobuf.ByteString; import com.google.protobuf.Timestamp; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.DimensionsSpec; @@ -29,6 +30,7 @@ import org.apache.druid.data.input.impl.ParseSpec; import org.apache.druid.data.input.impl.StringDimensionSchema; import org.apache.druid.data.input.impl.TimestampSpec; +import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.parsers.JSONPathFieldSpec; import org.apache.druid.java.util.common.parsers.JSONPathFieldType; import org.apache.druid.java.util.common.parsers.JSONPathSpec; @@ -136,7 +138,7 @@ public void testParseFlatData() throws Exception ProtoTestEventWrapper.ProtoTestEvent event = buildFlatData(dateTime); InputRow row = parser.parseBatch(toByteBuffer(event)).get(0); - verifyFlatData(row, dateTime); + verifyFlatData(row, dateTime, true); } @Test @@ -150,7 +152,7 @@ public void testParseFlatDataWithComplexTimestamp() throws Exception InputRow row = parser.parseBatch(toByteBuffer(event)).get(0); - verifyFlatDataWithComplexTimestamp(row, dateTime); + verifyFlatDataWithComplexTimestamp(row, dateTime, true); } @Test @@ -212,10 +214,11 @@ static ProtoTestEventWrapper.ProtoTestEvent buildFlatData(DateTime dateTime) .setSomeFloatColumn(47.11F) .setSomeIntColumn(815) .setSomeLongColumn(816L) + .setSomeBytesColumn(ByteString.copyFrom(new byte[]{0x01, 0x02, 0x03, 0x04})) .build(); } - static void verifyFlatData(InputRow row, DateTime dateTime) + static void verifyFlatData(InputRow row, DateTime dateTime, boolean badBytesConversion) { Assert.assertEquals(dateTime.getMillis(), row.getTimestampFromEpoch()); @@ -223,6 +226,13 @@ static void verifyFlatData(InputRow row, DateTime dateTime) assertDimensionEquals(row, "isValid", "true"); assertDimensionEquals(row, "someOtherId", "4712"); assertDimensionEquals(row, "description", "description"); + if (badBytesConversion) { + // legacy flattener used by parser doesn't convert bytes, instead calls tostring + // this can be removed if we update the parser to use the protobuf flattener used by the input format/reader + assertDimensionEquals(row, "someBytesColumn", row.getRaw("someBytesColumn").toString()); + } else { + assertDimensionEquals(row, "someBytesColumn", StringUtils.encodeBase64String(new byte[]{0x01, 0x02, 0x03, 0x04})); + } Assert.assertEquals(47.11F, row.getMetric("someFloatColumn").floatValue(), 0.0); @@ -242,6 +252,7 @@ static ProtoTestEventWrapper.ProtoTestEvent buildNestedData(DateTime dateTime) .setSomeFloatColumn(47.11F) .setSomeIntColumn(815) .setSomeLongColumn(816L) + .setSomeBytesColumn(ByteString.copyFrom(new byte[]{0x01, 0x02, 0x03, 0x04})) .setFoo(ProtoTestEventWrapper.ProtoTestEvent.Foo .newBuilder() .setBar("baz")) @@ -266,6 +277,7 @@ static void verifyNestedData(InputRow row, DateTime dateTime) assertDimensionEquals(row, "eventType", ProtoTestEventWrapper.ProtoTestEvent.EventCategory.CATEGORY_ONE.name()); assertDimensionEquals(row, "foobar", "baz"); assertDimensionEquals(row, "bar0", "bar0"); + assertDimensionEquals(row, "someBytesColumn", StringUtils.encodeBase64String(new byte[]{0x01, 0x02, 0x03, 0x04})); Assert.assertEquals(47.11F, row.getMetric("someFloatColumn").floatValue(), 0.0); @@ -287,12 +299,13 @@ static ProtoTestEventWrapper.ProtoTestEvent buildFlatDataWithComplexTimestamp(Da .setSomeFloatColumn(47.11F) .setSomeIntColumn(815) .setSomeLongColumn(816L) + .setSomeBytesColumn(ByteString.copyFrom(new byte[]{0x01, 0x02, 0x03, 0x04})) .build(); } - static void verifyFlatDataWithComplexTimestamp(InputRow row, DateTime dateTime) + static void verifyFlatDataWithComplexTimestamp(InputRow row, DateTime dateTime, boolean badBytesConversion) { - verifyFlatData(row, dateTime); + verifyFlatData(row, dateTime, badBytesConversion); } static ByteBuffer toByteBuffer(ProtoTestEventWrapper.ProtoTestEvent event) throws IOException diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufReaderTest.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufReaderTest.java index 24807e642481..36654c6cc949 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufReaderTest.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtobufReaderTest.java @@ -101,7 +101,7 @@ public void testParseFlatData() throws Exception InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0); - ProtobufInputRowParserTest.verifyFlatData(row, dateTime); + ProtobufInputRowParserTest.verifyFlatData(row, dateTime, false); } @Test @@ -117,7 +117,7 @@ public void testParseFlatDataWithComplexTimestamp() throws Exception InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0); - ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime); + ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime, false); } @Test @@ -138,6 +138,6 @@ public void testParseFlatDataWithComplexTimestampWithDefaultFlattenSpec() throws InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0); - ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime); + ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime, false); } } diff --git a/extensions-core/protobuf-extensions/src/test/resources/ProtoTest.proto b/extensions-core/protobuf-extensions/src/test/resources/ProtoTest.proto index 96b00d437dd7..19085970f11d 100644 --- a/extensions-core/protobuf-extensions/src/test/resources/ProtoTest.proto +++ b/extensions-core/protobuf-extensions/src/test/resources/ProtoTest.proto @@ -44,7 +44,8 @@ message ProtoTestEvent { optional float someFloatColumn = 7; optional uint32 someIntColumn = 8; optional uint64 someLongColumn = 9; - optional Foo foo = 10; - repeated Foo bar = 11; - optional google.protobuf.Timestamp otherTimestamp = 12; + required bytes someBytesColumn = 10; + optional Foo foo = 11; + repeated Foo bar = 12; + optional google.protobuf.Timestamp otherTimestamp = 13; } diff --git a/extensions-core/protobuf-extensions/src/test/resources/prototest.desc b/extensions-core/protobuf-extensions/src/test/resources/prototest.desc index 7509c6b82a32cdf58f2363382c351bd29179ca71..350cb03ea679774f212993289a01bedd1359a56c 100644 GIT binary patch delta 103 zcmaFHK7nHcGb2|w8y9~-QGQ8&$YfqdGo~Ka&900wj3ydf{KfgXsZNz8sm0FuIi-Q&B!zP7Lzq2?_@FN3jhT!9nSy& delta 68 zcmbQh@r-=~Gb7hSRxbX4qWqHllF7V`W=xM*HoG#$Fmma0F{kC{OK>SLPG)0P<^i&W WfI>-$MH1YTS(vREc_uqBUjP7bd=TmY diff --git a/processing/src/main/java/org/apache/druid/segment/StringDimensionIndexer.java b/processing/src/main/java/org/apache/druid/segment/StringDimensionIndexer.java index 589ad84fee32..62713966b014 100644 --- a/processing/src/main/java/org/apache/druid/segment/StringDimensionIndexer.java +++ b/processing/src/main/java/org/apache/druid/segment/StringDimensionIndexer.java @@ -28,6 +28,7 @@ import org.apache.druid.common.config.NullHandling; import org.apache.druid.data.input.impl.DimensionSchema.MultiValueHandling; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.query.extraction.ExtractionFn; @@ -122,6 +123,9 @@ public EncodedKeyComponent processRowValsToUnsortedEncodedKeyComponent(@N encodedDimensionValues = pos == retVal.length ? retVal : Arrays.copyOf(retVal, pos); } + } else if (dimValues instanceof byte[]) { + encodedDimensionValues = + new int[]{dimLookup.add(emptyToNullIfNeeded(StringUtils.encodeBase64String((byte[]) dimValues)))}; } else { encodedDimensionValues = new int[]{dimLookup.add(emptyToNullIfNeeded(dimValues))}; } diff --git a/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java b/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java index 60540e2fe250..b43f3c1005f2 100644 --- a/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java @@ -20,6 +20,7 @@ package org.apache.druid.segment; import org.apache.druid.data.input.impl.DimensionSchema; +import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.testing.InitializedNullHandlingTest; import org.junit.Assert; import org.junit.Test; @@ -204,6 +205,23 @@ public void testProcessRowValsToEncodedKeyComponent_comparison() Assert.assertEquals(2940L, totalSizeWithAvgEstimates); } + @Test + public void testBinaryInputs() + { + final StringDimensionIndexer indexer = new StringDimensionIndexer( + DimensionSchema.MultiValueHandling.SORTED_ARRAY, + true, + false, + false + ); + final byte[] byteVal = new byte[]{0x01, 0x02, 0x03, 0x04}; + EncodedKeyComponent keyComponent = indexer.processRowValsToUnsortedEncodedKeyComponent(byteVal, false); + Assert.assertEquals( + StringUtils.encodeBase64String(byteVal), + indexer.convertUnsortedEncodedKeyComponentToActualList(keyComponent.getComponent()) + ); + } + private long verifyEncodedValues( StringDimensionIndexer indexer, Object dimensionValues, From 5aad2ccceb774165b11d0e38b789f3e437a4aaae Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Thu, 15 Dec 2022 15:47:33 -0800 Subject: [PATCH 2/3] make it build --- .../apache/druid/data/input/protobuf/ProtoTestEventWrapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java index 0b88be107d4d..b8fdb9b876c8 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java @@ -22,6 +22,7 @@ package org.apache.druid.data.input.protobuf; +@SuppressWarnings("MissingOverride") public final class ProtoTestEventWrapper { private ProtoTestEventWrapper() {} public static void registerAllExtensions( From e207cec44ec29087b7285318df662103a769140d Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Thu, 15 Dec 2022 17:15:26 -0800 Subject: [PATCH 3/3] does this work? --- .../apache/druid/data/input/protobuf/ProtoTestEventWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java index b8fdb9b876c8..91d8fb6e5644 100644 --- a/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java +++ b/extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/ProtoTestEventWrapper.java @@ -22,7 +22,7 @@ package org.apache.druid.data.input.protobuf; -@SuppressWarnings("MissingOverride") +@SuppressWarnings({"ALL", "MissingOverride"}) public final class ProtoTestEventWrapper { private ProtoTestEventWrapper() {} public static void registerAllExtensions(