You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: binaryReader.go
    path of file: ./repos/plumber/vendor/github.com/linkedin/goavro/v2
    
    the code of the file until where you have to start completion: // Copyright [2019] LinkedIn Corp. Licensed under the Apache License, Version
// 2.0 (the "License"); you ma
    
func metadataBinaryReader(ior io.Reader) (map[string][]byte, error) {
	var err error
	var value interface{}

	// block count and block size
	if value, err = longBinaryReader(ior); err != nil {
		return nil, fmt.Errorf("cannot read map block count: %s", err)
	}
	blockCount := value.(int64)
	if blockCount < 0 {
		if blockCount == math.MinInt64 {
			// The minimum number for any signed numerical type can never be
			// made positive
			return nil, fmt.Errorf("cannot read map with block count: %d", blockCount)
		}
		// NOTE: A negative block count implies there is a long encoded block
		// size following the negative block count. We have no use for the block
		// size in this decoder, so we read and discard the value.
		blockCount = -blockCount // convert to its positive equivalent
		if _, err = longBinaryReader(ior); err != nil {
			return nil, fmt.Errorf("cannot read map block size: %s", err)
		}
	}
	// Ensure block count does not exceed some sane value.
	if blockCount > MaxBlockCount {
		return nil, fmt.Errorf("cannot read map when block count exceeds MaxBlockCount: %d > %d", blockCount, MaxBlockCount)
	}
	// NOTE: While the attempt of a RAM optimization shown below is not
	// necessary, many encoders will encode all items in a single block.  We can
	// optimize amount of RAM allocated by runtime for the array by initializing
	// the array for that number of items.
	mapValues := make(map[string][]byte, blockCount)

	for blockCount != 0 {
		// Decode `blockCount` datum values from buffer
		for i := int64(0); i < blockCount; i++ {
			// first decode the key string
			keyBytes, err := bytesBinaryReader(ior)
			if err != nil {
				return nil, fmt.Errorf("cannot read map key: %s", err)
			}
			key := string(keyBytes)
			if _, ok := mapValues[key]; ok {
				return nil, fmt.Errorf("cannot read map: duplicate key: %q", key)
			}
			// metadata values are always bytes
			buf, err := bytesBinaryReader(ior)
			if err != nil {
				return nil, fmt.Errorf("cannot read map value for key %q: %s", key, err)
			}
			mapValues[key] = buf
		}
		// Decode next blockCount from buffer, because there may be more blocks
		if value, err = longBinaryReader(ior); err != nil {
			return nil, fmt.Errorf("cannot read map block count: %s", err)
		}
		blockCount = value.(int64)
		if blockCount < 0 {
			if blockCount == math.MinInt64 {
				// The minimum number for any signed numerical type can never be
				// made positive
				return nil, fmt.Errorf("cannot read map with block count: %d", blockCount)
			}
			// NOTE: A negative block count implies there is a long encoded
			// block size following the negative block count. We have no use for
			// the block size in this decoder, so we read and discard the value.
			blockCount = -blockCount // convert to its positive equivalent
			if _, err = longBinaryReader(ior); err != nil {
				return nil, fmt.Errorf("cannot read map block size: %s", err)
			}
		}
		// Ensure block count does not exceed some sane value.
		if blockCount > MaxBlockCount {
			return nil, fmt.Errorf("cannot read map when block count exceeds MaxBlockCount: %d > %d", blockCount, MaxBlockCount)
		}
	}
	return mapValues, nil
}