Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read-only ByteBuffer not supported #143

Open
praetp opened this issue Mar 4, 2021 · 0 comments
Open

read-only ByteBuffer not supported #143

praetp opened this issue Mar 4, 2021 · 0 comments

Comments

@praetp
Copy link

praetp commented Mar 4, 2021

I was trying to write a read-only ByteBuffer to DynamoDb using the connector but I got

Caused by: java.nio.ReadOnlyBufferException
	at java.nio.ByteBuffer.array(ByteBuffer.java:996)
	at org.apache.hadoop.dynamodb.DynamoDBUtil.getAttributeSizeBytes(DynamoDBUtil.java:176)
	at org.apache.hadoop.dynamodb.DynamoDBUtil.getItemSizeBytes(DynamoDBUtil.java:149)
	at org.apache.hadoop.dynamodb.DynamoDBClient.putBatch(DynamoDBClient.java:199)
	at org.apache.hadoop.dynamodb.write.AbstractDynamoDBRecordWriter.write(AbstractDynamoDBRecordWriter.java:112)
	at org.apache.spark.internal.io.HadoopMapRedWriteConfigUtil.write(SparkHadoopWriter.scala:238)
	at org.apache.spark.internal.io.SparkHadoopWriter$$anonfun$4.apply(SparkHadoopWriter.scala:132)
	at org.apache.spark.internal.io.SparkHadoopWriter$$anonfun$4.apply(SparkHadoopWriter.scala:129)
	at org.apache.spark.util.Utils$.tryWithSafeFinallyAndFailureCallbacks(Utils.scala:1439)
	at org.apache.spark.internal.io.SparkHadoopWriter$.org$apache$spark$internal$io$SparkHadoopWriter$$executeTask(SparkHadoopWriter.scala:141)
	... 10 more

This is very unexpected as the API of AttributeValue().withB() clearly states:

Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future major version of the SDK.

So the API docs are actually encouraging us to provided a ReadOnly buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant