Read an embedded message field value from the stream.
975056
public void readMessage(final MessageLite.Builder builder,
                          final ExtensionRegistryLite extensionRegistry)
      throws IOException {
    final int length = readRawVarint32();
    if (recursionDepth >= recursionLimit) {
      throw InvalidProtocolBufferException.recursionLimitExceeded();
    }
    final int oldLimit = pushLimit(length);
    ++recursionDepth;
    builder.mergeFrom(this, extensionRegistry);
    checkLastTagWas(0);
    --recursionDepth;
    popLimit(oldLimit);
  }
762126
def _field_value_text(self, field):
        """"""
        if field in self.fields:
            return unicode(self.get(field))
        else:
            return self.get_timemachine_instance(field)._object_name_text()
70635
def reader(stream, fieldnames=None):
    """"""
    if not fieldnames:
        fieldnames = load_line(stream.readline())
    for line in stream:
        values = load_line(line)
        item = Item()
        item.__dict__ = dict(zip(fieldnames, values))
        yield item
1055169
def read (self, stream):
        """"""
        self._data = stream.read(self._size)

        if len(self._data) >= self._size:
            values = struct.unpack(self._format, self._data)
        else:
            values = None, None, None, None, None, None, None

        if   values[0] == 0xA1B2C3D4 or values[0] == 0xA1B23C4D:
            self._swap = '@'
        elif values[0] == 0xD4C3B2A1 or values[0] == 0x4D3CB2A1:
            self._swap = EndianSwap

        if values[0] is not None:
            values = struct.unpack(self._swap + self._format, self._data)

        self.magic_number  = values[0]
        self.version_major = values[1]
        self.version_minor = values[2]
        self.thiszone      = values[3]
        self.sigfigs       = values[4]
        self.snaplen       = values[5]
        self.network       = values[6]
914369
@SuppressWarnings("resource")
    private static BerDataValue readDataValue(InputStream input)
            throws BerDataValueFormatException {
        RecordingInputStream in = new RecordingInputStream(input);

        try {
            int firstIdentifierByte = in.read();
            if (firstIdentifierByte == -1) {
                // End of input
                return null;
            }
            int tagNumber = readTagNumber(in, firstIdentifierByte);

            int firstLengthByte = in.read();
            if (firstLengthByte == -1) {
                throw new BerDataValueFormatException("Missing length");
            }

            boolean constructed = BerEncoding.isConstructed((byte) firstIdentifierByte);
            int contentsLength;
            int contentsOffsetInDataValue;
            if ((firstLengthByte & 0x80) == 0) {
                // short form length
                contentsLength = readShortFormLength(firstLengthByte);
                contentsOffsetInDataValue = in.getReadByteCount();
                skipDefiniteLengthContents(in, contentsLength);
            } else if ((firstLengthByte & 0xff) != 0x80) {
                // long form length
                contentsLength = readLongFormLength(in, firstLengthByte);
                contentsOffsetInDataValue = in.getReadByteCount();
                skipDefiniteLengthContents(in, contentsLength);
            } else {
                // indefinite length
                contentsOffsetInDataValue = in.getReadByteCount();
                contentsLength =
                        constructed
                                ? skipConstructedIndefiniteLengthContents(in)
                                : skipPrimitiveIndefiniteLengthContents(in);
            }

            byte[] encoded = in.getReadBytes();
            ByteBuffer encodedContents =
                    ByteBuffer.wrap(encoded, contentsOffsetInDataValue, contentsLength);
            return new BerDataValue(
                    ByteBuffer.wrap(encoded),
                    encodedContents,
                    BerEncoding.getTagClass((byte) firstIdentifierByte),
                    constructed,
                    tagNumber);
        } catch (IOException e) {
            throw new BerDataValueFormatException("Failed to read data value", e);
        }
    }
1270287
def read(message):
    """"""
    require_compatible_version(message.physt_compatible)

    # Currently the only implementation
    a_dict = _dict_from_v0342(message)
    return create_from_dict(a_dict, "Message")
121543
def _ValueMessageToJsonObject(self, message):
    """"""
    which = message.WhichOneof('kind')
    # If the Value message is not set treat as null_value when serialize
    # to JSON. The parse back result will be different from original message.
    if which is None or which == 'null_value':
      return None
    if which == 'list_value':
      return self._ListValueMessageToJsonObject(message.list_value)
    if which == 'struct_value':
      value = message.struct_value
    else:
      value = getattr(message, which)
    oneof_descriptor = message.DESCRIPTOR.fields_by_name[which]
    return self._FieldToJsonObject(oneof_descriptor, value)
1176989
function serializeInnerMessage(spec, message, buffer, bufferOffset) {
  spec.fields.forEach(function(field) {
    var fieldValue = message[field.name];

    if (field.isArray) {
      if (field.arrayLen === null) {
        buffer.writeUInt32LE(fieldValue.length, bufferOffset);
        bufferOffset += 4; // only for variable length arrays
      }

      var arrayType = field.baseType;
      fieldValue.forEach(function(value) {
        if (field.isBuiltin) {
          bufferOffset = fieldsUtil.serializePrimitive(
            arrayType, value, buffer, bufferOffset);
        }
        else if (fieldsUtil.isMessage(arrayType)) {
          bufferOffset = serializeInnerMessage(spec.getMsgSpecForType(arrayType), value, buffer, bufferOffset);
        }
      });
    }
    else if (field.isBuiltin) {
      bufferOffset = fieldsUtil.serializePrimitive(
        field.type, fieldValue, buffer, bufferOffset);
    }
    else { // is message
      bufferOffset = serializeInnerMessage(spec.getMsgSpecForType(field.baseType), fieldValue, buffer, bufferOffset);
    }
  });

  return bufferOffset;
}
402605
private Object extractCurrentField(JsonParser p, HCatFieldSchema hcatFieldSchema,
                                     boolean isTokenCurrent) throws IOException {
    Object val = null;
    JsonToken valueToken;
    if (isTokenCurrent) {
      valueToken = p.getCurrentToken();
    } else {
      valueToken = p.nextToken();
    }
    switch (hcatFieldSchema.getType()) {
    case INT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getIntValue();
      break;
    case TINYINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getByteValue();
      break;
    case SMALLINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getShortValue();
      break;
    case BIGINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getLongValue();
      break;
    case BOOLEAN:
      String bval = (valueToken == JsonToken.VALUE_NULL) ? null : p.getText();
      if (bval != null) {
        val = Boolean.valueOf(bval);
      } else {
        val = null;
      }
      break;
    case FLOAT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getFloatValue();
      break;
    case DOUBLE:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getDoubleValue();
      break;
    case STRING:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getText();
      break;
    case BINARY:
      throw new IOException("JsonSerDe does not support BINARY type");
    case DATE:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : Date.valueOf(p.getText());
      break;
    case TIMESTAMP:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : tsParser.parseTimestamp(p.getText());
      break;
    case DECIMAL:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : HiveDecimal.create(p.getText());
      break;
    case VARCHAR:
      int vLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveVarchar(p.getText(), vLen);
      break;
    case CHAR:
      int cLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveChar(p.getText(), cLen);
      break;
    case ARRAY:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_ARRAY) {
        throw new IOException("Start of Array expected");
      }
      List<Object> arr = new ArrayList<Object>();
      while ((valueToken = p.nextToken()) != JsonToken.END_ARRAY) {
        arr.add(extractCurrentField(p, hcatFieldSchema.getArrayElementSchema().get(0), true));
      }
      val = arr;
      break;
    case MAP:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_OBJECT) {
        throw new IOException("Start of Object expected");
      }
      Map<Object, Object> map = new LinkedHashMap<Object, Object>();
      HCatFieldSchema valueSchema = hcatFieldSchema.getMapValueSchema().get(0);
      while ((valueToken = p.nextToken()) != JsonToken.END_OBJECT) {
        Object k = getObjectOfCorrespondingPrimitiveType(p.getCurrentName(), hcatFieldSchema.getMapKeyTypeInfo());
        Object v = extractCurrentField(p, valueSchema, false);
        map.put(k, v);
      }
      val = map;
      break;
    case STRUCT:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_OBJECT) {
        throw new IOException("Start of Object expected");
      }
      HCatSchema subSchema = hcatFieldSchema.getStructSubSchema();
      int sz = subSchema.getFieldNames().size();

      List<Object> struct = new ArrayList<Object>(Collections.nCopies(sz, null));
      while ((valueToken = p.nextToken()) != JsonToken.END_OBJECT) {
        populateRecord(struct, valueToken, p, subSchema);
      }
      val = struct;
      break;
    default:
      LOG.error("Unknown type found: " + hcatFieldSchema.getType());
      return null;
    }
    return val;
  }
838103
def pipe_value(self, message):
        ''
        jmsg = json.dumps(message)
        self.send(jmsg)
10310
def _ConvertFieldValuePair(self, js, message):
    
    names = []
    message_descriptor = message.DESCRIPTOR
    fields_by_json_name = dict((f.json_name, f)
                               for f in message_descriptor.fields)
    for name in js:
      try:
        field = fields_by_json_name.get(name, None)
        if not field:
          field = message_descriptor.fields_by_name.get(name, None)
        if not field:
          if self.ignore_unknown_fields:
            continue
          raise ParseError(
              'Message type "{0}" has no field named "{1}".'.format(
                  message_descriptor.full_name, name))
        if name in names:
          raise ParseError('Message type "{0}" should not have multiple '
                           '"{1}" fields.'.format(
                               message.DESCRIPTOR.full_name, name))
        names.append(name)
        # Check no other oneof field is parsed.
        if field.containing_oneof is not None:
          oneof_name = field.containing_oneof.name
          if oneof_name in names:
            raise ParseError('Message type "{0}" should not have multiple '
                             '"{1}" oneof fields.'.format(
                                 message.DESCRIPTOR.full_name, oneof_name))
          names.append(oneof_name)

        value = js[name]
        if value is None:
          if (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE
              and field.message_type.full_name == 'google.protobuf.Value'):
            sub_message = getattr(message, field.name)
            sub_message.null_value = 0
          else:
            message.ClearField(field.name)
          continue

        # Parse field value.
        if _IsMapEntry(field):
          message.ClearField(field.name)
          self._ConvertMapFieldValue(value, message, field)
        elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
          message.ClearField(field.name)
          if not isinstance(value, list):
            raise ParseError('repeated field {0} must be in [] which is '
                             '{1}.'.format(name, value))
          if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
            # Repeated message field.
            for item in value:
              sub_message = getattr(message, field.name).add()
              # None is a null_value in Value.
              if (item is None and
                  sub_message.DESCRIPTOR.full_name != 'google.protobuf.Value'):
                raise ParseError('null is not allowed to be used as an element'
                                 ' in a repeated field.')
              self.ConvertMessage(item, sub_message)
          else:
            # Repeated scalar field.
            for item in value:
              if item is None:
                raise ParseError('null is not allowed to be used as an element'
                                 ' in a repeated field.')
              getattr(message, field.name).append(
                  _ConvertScalarFieldValue(item, field))
        elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
          sub_message = getattr(message, field.name)
          sub_message.SetInParent()
          self.ConvertMessage(value, sub_message)
        else:
          setattr(message, field.name, _ConvertScalarFieldValue(value, field))
      except ParseError as e:
        if field and field.containing_oneof is None:
          raise ParseError('Failed to parse {0} field: {1}'.format(name, e))
        else:
          raise ParseError(str(e))
      except ValueError as e:
        raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
      except TypeError as e:
        raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
1211862
def _StructMessageToJsonObject(self, message):
    """"""
    fields = message.fields
    ret = {}
    for key in fields:
      ret[key] = self._ValueMessageToJsonObject(fields[key])
    return ret
777679
@Override
	public byte readByte() throws JMSException
    {
    	backupState();
    	try
    	{
    		return MessageConvertTools.asByte(internalReadObject());
    	}
    	catch (JMSException e)
    	{
    		restoreState();
    		throw e;	
    	}
    	catch (RuntimeException e)
    	{
    		restoreState();
    		throw e;
    	}
    }
546918
public static Object getFieldValue(FieldMetadata fieldMetadata, Object target) {
    MethodHandle readMethod = fieldMetadata.getReadMethod();
    try {
      return readMethod.invoke(target);
    } catch (Throwable t) {
      throw new EntityManagerException(t.getMessage(), t);
    }
  }
1262495
def CheckDataReceived(self):
        """"""
        currentLength = len(self.buffer_in)
        if currentLength < 24:
            return False
        # Extract the message header from the buffer, and return if not enough
        # buffer to fully deserialize the message object.

        try:
            # Construct message
            mstart = self.buffer_in[:24]
            ms = StreamManager.GetStream(mstart)
            reader = BinaryReader(ms)
            m = Message()

            # Extract message metadata
            m.Magic = reader.ReadUInt32()
            m.Command = reader.ReadFixedString(12).decode('utf-8')
            m.Length = reader.ReadUInt32()
            m.Checksum = reader.ReadUInt32()

            # Return if not enough buffer to fully deserialize object.
            messageExpectedLength = 24 + m.Length
            if currentLength < messageExpectedLength:
                return False

        except Exception as e:
            logger.debug(f"{self.prefix} Error: could not read message header from stream {e}")
            # self.Log('Error: Could not read initial bytes %s ' % e)
            return False

        finally:
            StreamManager.ReleaseStream(ms)
            del reader

        # The message header was successfully extracted, and we have enough enough buffer
        # to extract the full payload
        try:
            # Extract message bytes from buffer and truncate buffer
            mdata = self.buffer_in[:messageExpectedLength]
            self.buffer_in = self.buffer_in[messageExpectedLength:]

            # Deserialize message with payload
            stream = StreamManager.GetStream(mdata)
            reader = BinaryReader(stream)
            message = Message()
            message.Deserialize(reader)

            if self.incoming_client and self.expect_verack_next:
                if message.Command != 'verack':
                    self.Disconnect("Expected 'verack' got {}".format(message.Command))

            # Propagate new message
            self.MessageReceived(message)

        except Exception as e:
            logger.debug(f"{self.prefix} Could not extract message {e}")
            # self.Log('Error: Could not extract message: %s ' % e)
            return False

        finally:
            StreamManager.ReleaseStream(stream)

        return True
771198
def read_attribute (field, context)
      if field.multivalued?
        arr = json_attributes[field.name]
        unless arr
          arr = EmbeddedDocumentArray.new(field.type, context)
          json_attributes[field.name] = arr
        end
        return arr
      else
        val = json_attributes[field.name]
        if val.nil? and !field.default.nil?
          val = field.default.dup rescue field.default
          json_attributes[field.name] = val
        end
        return val
      end
    end
907242
def read_message_from_pipe(pipe_handle):
    
    data = yield From(read_message_bytes_from_pipe(pipe_handle))
    assert isinstance(data, bytes)
    raise Return(data.decode('utf-8', 'ignore'))