It would be great to factor out the common code with PlainBinaryDictionaryValuesWriter