Merges the {@code message} with the byte array using the given {@code schema}.
489767
public static <T> void mergeFrom(byte[] data, int offset, int length, T message, 
            Schema<T> schema, boolean numeric) throws IOException
    {
        final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), 
                data, false);
        final JsonParser parser = newJsonParser(null, data, offset, offset+length, false, 
                context);
        /*final JsonParser parser = DEFAULT_JSON_FACTORY.createJsonParser(data, offset, 
                length);*/
        try
        {
            mergeFrom(parser, message, schema, numeric);
        }
        finally
        {
            parser.close();
        }
    }
1015952
private void adjustSchema(String schemaPath, String newElementString) {

        newElementString = newElementString.substring(0, 1).toUpperCase() + newElementString.substring(1);
        try {
            CmsFile file = m_cms.readFile(schemaPath);

            CmsMacroResolver macroResolver = new CmsMacroResolver();
            macroResolver.setKeepEmptyMacros(true);

            macroResolver.addMacro(SAMPLE_TYPE_SCHEMA_ELEMENT, newElementString);
            String bundleName = m_bundle.getValue();

            bundleName = bundleName.split("/")[bundleName.split("/").length - 1];
            if (bundleName.contains("_")) {
                bundleName = bundleName.split("_")[0];
            }
            macroResolver.addMacro("ResourceBundle", bundleName);
            macroResolver.addMacro("typeName", m_typeShortName.getValue());
            String encoding = m_cms.readPropertyObject(
                file,
                CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
                true).getValue(OpenCms.getSystemInfo().getDefaultEncoding());
            String newContent = macroResolver.resolveMacros(new String(file.getContents(), encoding));
            // update the content
            try {
                file.setContents(newContent.getBytes(encoding));
            } catch (UnsupportedEncodingException e) {
                try {
                    file.setContents(newContent.getBytes(Charset.defaultCharset().toString()));
                } catch (UnsupportedEncodingException e1) {
                    file.setContents(newContent.getBytes());
                }
            }
            // write the target file
            CmsLockUtil.ensureLock(m_cms, file);
            m_cms.writeFile(file);
            CmsLockUtil.tryUnlock(m_cms, file);
        } catch (

        CmsException e) {
            LOG.error("Unable to read schema definition", e);
        } catch (UnsupportedEncodingException e) {
            LOG.error("Unable to fetch encoding", e);
        }
    }
89571
public static <T> void writeListTo(LinkedBuffer buffer,
            List<T> messages, Schema<T> schema, boolean numeric)
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        if (messages.isEmpty())
        {
            System.arraycopy(EMPTY_ARRAY, 0, buffer.buffer, buffer.offset, EMPTY_ARRAY.length);
            buffer.offset += EMPTY_ARRAY.length;
            return;
        }

        final JsonXOutput output = new JsonXOutput(buffer, numeric, schema);

        try
        {
            output.writeStartArray();

            boolean first = true;
            for (T m : messages)
            {
                if (first)
                {
                    first = false;
                    output.writeStartObject();
                }
                else
                    output.writeCommaAndStartObject();

                schema.writeTo(output, m);
                if (output.isLastRepeated())
                    output.writeEndArray();

                output.writeEndObject().reset();
            }

            output.writeEndArray();
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
    }
813698
public static <T> List<T> parseListFrom(final InputStream in, final Schema<T> schema) 
    throws IOException
    {
        int size = in.read();
        if(size == -1)
            return Collections.emptyList();
        
        if(size > 0x7f)
            size = CodedInput.readRawVarint32(in, size);
        
        final ArrayList<T> list = new ArrayList<T>(size);
        final CodedInput input = new CodedInput(in, true);
        for(int i = 0; i < size; i++)
        {
            final T message = schema.newMessage();
            list.add(message);
            schema.mergeFrom(input, message);
            input.checkLastTagWas(0);
        }
        
        assert in.read() == -1;

        return list;
    }
913199
void compareUnionTypes(Schema oldSchema,
                                                Schema newSchema,
                                                List<Message> messages,
                                                String name) {
        if(oldSchema == null || newSchema == null || oldSchema.getType() != Schema.Type.UNION) {
            throw new IllegalArgumentException("Old and new schema must both be UNION types. Name="
                                               + name + ". Type=" + oldSchema);
        }

        // Build a list of type names, ignoring nulls which are checked
        // separately as optional/required fields
        List<Schema> newTypes = new ArrayList<Schema>();
        List<String> newTypeNames = new ArrayList<String>();
        List<Schema> oldTypes = new ArrayList<Schema>();
        List<String> oldTypeNames = new ArrayList<String>();

        if(newSchema.getType() == Type.UNION) {
            for(Schema schema: newSchema.getTypes()) {
                if(schema.getType() != Schema.Type.NULL) {
                    newTypes.add(schema);
                    newTypeNames.add(schema.getName());
                }
            }
        } else {
            newTypes.add(newSchema);
            newTypeNames.add(newSchema.getName());
        }

        for(Schema schema: oldSchema.getTypes()) {
            if(schema.getType() != Schema.Type.NULL) {
                oldTypes.add(schema);
                oldTypeNames.add(schema.getName());
            }
        }

        if(!newTypeNames.containsAll(oldTypeNames)) {
            messages.add(new Message(Level.ERROR,
                                     "Existing UNION field " + name
                                             + " had one or more types removed. The old types are:"
                                             + oldTypeNames + ". The new types are: "
                                             + newTypeNames));
        }
        if(!oldTypeNames.containsAll(newTypeNames)) {
            messages.add(new Message(Level.INFO,
                                     "Existing UNION field " + name
                                             + " had one or more types added. The old types are:"
                                             + oldTypeNames + ". The new types are: "
                                             + newTypeNames));
        }
        if(newTypeNames.containsAll(oldTypeNames) && oldTypeNames.containsAll(newTypeNames)
           && !newTypeNames.equals(oldTypeNames)) {
            messages.add(new Message(Level.INFO,
                                     "Existing UNION field "
                                             + name
                                             + " had one or more types reordered. The old types are:"
                                             + oldTypeNames + ". The new types are: "
                                             + newTypeNames));
        }

        for(int i = 0; i < newTypeNames.size(); i++) {
            String typeName = newTypeNames.get(i);
            int oldIndex = oldTypeNames.indexOf(typeName);
            if(oldIndex != -1) {
                compareTypes(oldTypes.get(oldIndex),
                             newTypes.get(i),
                             messages,
                             name + "." + oldTypes.get(oldIndex).getName());
            }
        }
    }
500294
NodeSchema join(NodeSchema schema) {
        NodeSchema copy = this.clone();
        for (SchemaColumn column: schema.getColumns()) {
            copy.addColumn(column.clone());
        }
        return copy;
    }
739187
def mergemessage(self, message):
        
        if isinstance(message, QueueMessage):
            """ merge queue message vars """
            for key, value in vars(message).items():
                if not value is None:
                    setattr(self, key, value)
                    if (key == 'content'):
                        content = literal_eval(message.content)
                        for metakey, metavalue in content.items():
                            default = getattr(self, metakey, None)
                            if not default is None:
                                if isinstance(default, datetime.date):
                                    setattr(self, metakey, safe_cast(metavalue, datetime.date, dformat=self._dateformat))
                                if isinstance(default, datetime.datetime):
                                    setattr(self, metakey, safe_cast(metavalue, datetime.date, dformat=self._datetimeformat))
                                else:
                                    setattr(self, metakey, metavalue)
804461
public void putTableSchema(String key, TableSchema schema) {
		checkNotNull(key);
		checkNotNull(schema);

		final String[] fieldNames = schema.getFieldNames();
		final TypeInformation<?>[] fieldTypes = schema.getFieldTypes();

		final List<List<String>> values = new ArrayList<>();
		for (int i = 0; i < schema.getFieldCount(); i++) {
			values.add(Arrays.asList(fieldNames[i], TypeStringUtils.writeTypeInfo(fieldTypes[i])));
		}

		putIndexedFixedProperties(
			key,
			Arrays.asList(TABLE_SCHEMA_NAME, TABLE_SCHEMA_TYPE),
			values);
	}
1092183
public static <T> byte[] toByteArray(T message, Schema<T> schema)
    {
        return toByteArray(message, schema, DEFAULT_OUTPUT_FACTORY);
    }
495226
public DataWriterBuilder<S, D> withSchema(S schema) {
    this.schema = schema;
    log.debug("withSchema : {}", this.schema);
    return this;
  }
1049901
public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema,
            LinkedBuffer buffer) throws IOException
    {
        final CodedInput input = new CodedInput(in, buffer.buffer, true);
        final GraphCodedInput graphInput = new GraphCodedInput(input);
        schema.mergeFrom(graphInput, message);
        input.checkLastTagWas(0);
    }
105181
static void saveSchemas(MessageStore msgStore, JMFSchema[] schemas) throws MessageEncodeFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "saveSchemas");
    try {
      // Get the SchemaStore reference, creating a new one if necessary
      SchemaStoreItemStream schemaStore = getSchemaStore(msgStore);

      // Check if any new schemas need to be persisted to the SchemaStore
      for (int i = 0; i < schemas.length; i++) {
        if (!schemaStore.containsSchema(schemas[i].getLongID())) {
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Saving schema:" + schemas[i].getID());
          schemaStore.addSchema(schemas[i], msgStore.getTransactionFactory().createAutoCommitTransaction());
        }
      }
    } catch (MessageStoreException e) {
      FFDCFilter.processException(e, "saveSchemas", "83");
      throw new MessageEncodeFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "saveSchemas");
  }
14200
public static byte schemaToColumnType(Schema s) {
    Schema.Type typ =  s.getType();
    switch (typ) {
      case BOOLEAN:
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
        return Vec.T_NUM;
      case ENUM:
        return Vec.T_CAT;
      case STRING:
        return Vec.T_STR;
      case NULL:
        return Vec.T_BAD;
      case BYTES:
        return Vec.T_STR;
      case UNION: // Flattenize the union
        List<Schema> unionSchemas = s.getTypes();
        if (unionSchemas.size() == 1) {
          return schemaToColumnType(unionSchemas.get(0));
        } else if (unionSchemas.size() == 2) {
          Schema s1 = unionSchemas.get(0);
          Schema s2 = unionSchemas.get(1);
          if (s1.getType().equals(Schema.Type.NULL)) return schemaToColumnType(s2);
          else if (s2.getType().equals(Schema.Type.NULL)) return schemaToColumnType(s1);
        }
      default:
        throw new IllegalArgumentException("Unsupported Avro schema type: " + s);
    }
  }
597232
def merge!(schema)
      if schema.is_a?(Schema)
        @data.merge!(schema.data)
      else
        @data.merge!(schema)
      end
    end
534092
def MergeMessage(
      self, source, destination,
      replace_message, replace_repeated):
    """"""
    _MergeMessage(
        self._root, source, destination, replace_message, replace_repeated)
469805
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema,
            boolean numeric) throws IOException
    {
        final IOContext context = new IOContext(DEFAULT_SMILE_FACTORY._getBufferRecycler(),
                out, false);

        final SmileGenerator generator = newSmileGenerator(out,
                context.allocWriteEncodingBuffer(), 0, true, context);

        // final SmileGenerator generator = DEFAULT_SMILE_FACTORY.createJsonGenerator(out);

        try
        {
            JsonIOUtil.writeTo(generator, message, schema, numeric);
        }
        finally
        {
            generator.close();
        }
    }
804350
public static <T> void writeTo(XMLStreamWriter writer, T message, Schema<T> schema)
            throws IOException, XMLStreamException, XmlOutputException
    {
        writer.writeStartElement(schema.messageName());

        schema.writeTo(new XmlOutput(writer, schema), message);

        writer.writeEndElement();
    }