/** * Get a {@code DynamicMessage} representing the default instance of the * given type. */ public static DynamicMessage getDefaultInstance(Descriptor type) { int oneofDeclCount = type.toProto().getOneofDeclCount(); FieldDescriptor[] oneofCases = new FieldDescriptor[oneofDeclCount]; return new DynamicMessage(type, FieldSet.<FieldDescriptor>emptySet(), oneofCases, UnknownFieldSet.getDefaultInstance()); }
/** Construct a {@code Builder} for the given type. */ private Builder(Descriptor type) { this.type = type; this.fields = FieldSet.newFieldSet(); this.unknownFields = UnknownFieldSet.getDefaultInstance(); this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()]; // A MapEntry has all of its fields present at all times. if (type.getOptions().getMapEntry()) { populateMapEntry(); } }
proto.getOneofIndex() >= parent.toProto().getOneofDeclCount()) { throw new DescriptorValidationException(this, "FieldDescriptorProto.oneof_index is out of range for type "
/** * Create a placeholder FileDescriptor for a message Descriptor. */ FileDescriptor(String packageName, Descriptor message) throws DescriptorValidationException { this.pool = new DescriptorPool(new FileDescriptor[0], true); this.proto = FileDescriptorProto.newBuilder() .setName(message.getFullName() + ".placeholder.proto") .setPackage(packageName).addMessageType(message.toProto()).build(); this.dependencies = new FileDescriptor[0]; this.publicDependencies = new FileDescriptor[0]; messageTypes = new Descriptor[] {message}; enumTypes = new EnumDescriptor[0]; services = new ServiceDescriptor[0]; extensions = new FieldDescriptor[0]; pool.addPackage(packageName, this); pool.addSymbol(message); }
/** * Create a placeholder FileDescriptor for a message Descriptor. */ FileDescriptor(String packageName, Descriptor message) throws DescriptorValidationException { this.pool = new DescriptorPool(new FileDescriptor[0], true); this.proto = FileDescriptorProto.newBuilder() .setName(message.getFullName() + ".placeholder.proto") .setPackage(packageName).addMessageType(message.toProto()).build(); this.dependencies = new FileDescriptor[0]; this.publicDependencies = new FileDescriptor[0]; messageTypes = new Descriptor[] {message}; enumTypes = new EnumDescriptor[0]; services = new ServiceDescriptor[0]; extensions = new FieldDescriptor[0]; pool.addPackage(packageName, this); pool.addSymbol(message); }
private void javaDoc() { line("/**"); line(" * <pre>"); line(" * Column value description {", ""); line(" * type: ", TypeName(col), ";"); if (col.getValue().getProtoDescriptor() != null) { String protoDescription = col.getValue().getProtoDescriptor().toProto().toString(); for (String line : protoDescription.split("\n")) { line(" * ", line, ""); } } line(" * }", ""); line(" * </pre>"); line(" */"); }
@Override public Object create() { return descriptor.toProto().toBuilder().build(); }
@Override public DescriptorProtos.DescriptorProto getDescriptorProto() { if (descriptor != null) { return descriptor.toProto(); } return null; }
/** Construct a {@code Builder} for the given type. */ private Builder(Descriptor type) { this.type = type; this.fields = FieldSet.newFieldSet(); this.unknownFields = UnknownFieldSet.getDefaultInstance(); this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()]; }
public MessageType convert(Class<? extends Message> protobufClass) { LOG.debug("Converting protocol buffer class \"" + protobufClass + "\" to parquet schema."); Descriptors.Descriptor descriptor = Protobufs.getMessageDescriptor(protobufClass); MessageType messageType = convertFields(Types.buildMessage(), descriptor.getFields()) .named(descriptor.getFullName()); LOG.debug("Converter info:\n " + descriptor.toProto() + " was converted to \n" + messageType); return messageType; }
/** Construct a {@code Builder} for the given type. */ private Builder(Descriptor type) { this.type = type; this.fields = FieldSet.newFieldSet(); this.unknownFields = UnknownFieldSet.getDefaultInstance(); this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()]; }
/** * Get a {@code DynamicMessage} representing the default instance of the * given type. */ public static DynamicMessage getDefaultInstance(Descriptor type) { int oneofDeclCount = type.toProto().getOneofDeclCount(); FieldDescriptor[] oneofCases = new FieldDescriptor[oneofDeclCount]; return new DynamicMessage(type, FieldSet.<FieldDescriptor>emptySet(), oneofCases, UnknownFieldSet.getDefaultInstance()); }
@Override public DescriptorProtos.DescriptorProto getDescriptorProto() { if (descriptor != null) { return descriptor.toProto(); } return null; }
/** * Get a {@code DynamicMessage} representing the default instance of the * given type. */ public static DynamicMessage getDefaultInstance(Descriptor type) { int oneofDeclCount = type.toProto().getOneofDeclCount(); FieldDescriptor[] oneofCases = new FieldDescriptor[oneofDeclCount]; return new DynamicMessage(type, FieldSet.<FieldDescriptor>emptySet(), oneofCases, UnknownFieldSet.getDefaultInstance()); }
private Descriptors.Descriptor mutateUnionDescriptor(@Nonnull UnaryOperator<DescriptorProtos.DescriptorProto> mutation) throws Descriptors.DescriptorValidationException { final Descriptors.Descriptor oldUnionDescriptor = metaData.getUnionDescriptor(); final DescriptorProtos.DescriptorProto oldUnionDescriptorProto = oldUnionDescriptor.toProto(); final DescriptorProtos.FileDescriptorProto fileDescriptorProto = metaData.getRecordsDescriptor().toProto(); int unionDescriptorIndex = fileDescriptorProto.getMessageTypeList().indexOf(oldUnionDescriptorProto); final DescriptorProtos.FileDescriptorProto newFileDescriptorProto = metaData.getRecordsDescriptor().toProto().toBuilder() .setMessageType(unionDescriptorIndex, mutation.apply(oldUnionDescriptorProto)) .build(); return buildRecordDescriptor(newFileDescriptorProto).findMessageTypeByName(oldUnionDescriptor.getName()); }
@Override public DescriptorProtos.DescriptorProto getDescriptorProto() { if (descriptor != null) { return descriptor.toProto(); } return null; }
/** Returns message descriptor as JSON String*/ private String serializeDescriptor(Class<? extends Message> protoClass) { Descriptors.Descriptor descriptor = Protobufs.getMessageDescriptor(protoClass); DescriptorProtos.DescriptorProto asProto = descriptor.toProto(); return TextFormat.printToString(asProto); }
private void javaDoc() { line("/**"); line(" * <pre>"); line(" * Column name description {", ""); for (NameComponentDescription comp : col.getRowParts()) { boolean descending = comp.getOrder() == ValueByteOrder.DESCENDING; line(" * {@literal ", descending ? "@Descending " : "", TypeName(comp), " ", varName(comp), "};"); } line(" * }", ""); line(" * Column value description {", ""); line(" * type: ", val.getJavaObjectTypeName(), ";"); if (val.getProtoDescriptor() != null) { String protoDescription = val.getProtoDescriptor().toProto().toString(); for (String line : protoDescription.split("\n")) { line(" * ", line, ""); } } line(" * }", ""); line(" * </pre>"); line(" */"); }
private void javaDoc() { line("/**"); line(" * <pre>"); line(" * Column value description {", ""); line(" * type: ", TypeName(col), ";"); if (col.getValue().getProtoDescriptor() != null) { String protoDescription = col.getValue().getProtoDescriptor().toProto().toString(); for (String line : protoDescription.split("\n")) { line(" * ", line, ""); } } line(" * }", ""); line(" * </pre>"); line(" */"); }
/** * Create a placeholder FileDescriptor for a message Descriptor. */ FileDescriptor(String packageName, Descriptor message) throws DescriptorValidationException { this.pool = new DescriptorPool(new FileDescriptor[0], true); this.proto = FileDescriptorProto.newBuilder() .setName(message.getFullName() + ".placeholder.proto") .setPackage(packageName).addMessageType(message.toProto()).build(); this.dependencies = new FileDescriptor[0]; this.publicDependencies = new FileDescriptor[0]; messageTypes = new Descriptor[] {message}; enumTypes = new EnumDescriptor[0]; services = new ServiceDescriptor[0]; extensions = new FieldDescriptor[0]; pool.addPackage(packageName, this); pool.addSymbol(message); }