[
https://issues.apache.org/jira/browse/BEAM-7557?focusedWorklogId=271209&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-271209
]
ASF GitHub Bot logged work on BEAM-7557:
----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Jul/19 20:55
Start Date: 02/Jul/19 20:55
Worklog Time Spent: 10m
Work Description: iemejia commented on pull request #8987: [BEAM-7557] -
Migrate DynamoDBIO to AWS SDK for Java 2
URL: https://github.com/apache/beam/pull/8987#discussion_r299649344
##########
File path:
sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java
##########
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.aws2.dynamodb;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.beam.sdk.coders.AtomicCoder;
+import org.apache.beam.sdk.coders.BooleanCoder;
+import org.apache.beam.sdk.coders.ByteArrayCoder;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.ListCoder;
+import org.apache.beam.sdk.coders.MapCoder;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import software.amazon.awssdk.core.SdkBytes;
+import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
+
+/** A {@link Coder} that serializes and deserializes the {@link
AttributeValue} objects. */
+public class AttributeValueCoder extends AtomicCoder<AttributeValue> {
+
+ /** Data type of each value type in AttributeValue object. */
+ private enum AttributeValueType {
+ s, // for String
+ n, // for Number
+ b, // for Byte
+ ss, // for List of String
+ ns, // for List of Number
+ bs, // for List of Byte
+ m, // for Map of String and AttributeValue
+ l, // for list of AttributeValue
+ bool, // for Boolean
+ nul, // for null
+ }
+
+ private static final AttributeValueCoder INSTANCE = new
AttributeValueCoder();
+
+ private static final ListCoder<String> LIST_STRING_CODER =
ListCoder.of(StringUtf8Coder.of());
+ private static final ListCoder<byte[]> LIST_BYTE_CODER =
ListCoder.of(ByteArrayCoder.of());
+
+ private static final ListCoder<AttributeValue> LIST_ATTRIBUTE_CODER =
+ ListCoder.of(AttributeValueCoder.of());
+ private static final MapCoder<String, AttributeValue> MAP_ATTRIBUTE_CODER =
+ MapCoder.of(StringUtf8Coder.of(), AttributeValueCoder.of());
+
+ private AttributeValueCoder() {}
+
+ public static AttributeValueCoder of() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void encode(AttributeValue value, OutputStream outStream) throws
IOException {
+
Review comment:
remove whitespace
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 271209)
Time Spent: 1h 10m (was: 1h)
> Migrate DynamoDBIO to AWS SDK for Java 2
> ----------------------------------------
>
> Key: BEAM-7557
> URL: https://issues.apache.org/jira/browse/BEAM-7557
> Project: Beam
> Issue Type: Sub-task
> Components: io-java-aws
> Reporter: Ismaël Mejía
> Assignee: Cam Mach
> Priority: Minor
> Labels: backward-incompatible
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> DynamoDBIO uses the old style API ScanRequestAPI, translating into the
> ScanSpec
> API can bring us improvements because we can eventually align Scans and
> Querys
> in the DynamoDBIO API. Also this is needed for migration to AWS SDK for Java
> 2.x.
> We should use for this the new ScanSpec API.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)