extract buffer calculation logic into separate method, make
array/arrayOffset use BytesRef container for bytes/offset