beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [1/4] beam git commit: Use guava Base64 encoding instead of google api client
Date Tue, 09 May 2017 16:55:30 GMT
Repository: beam
Updated Branches:
  refs/heads/release-2.0.0 e282601b7 -> 5763c384d


Use guava Base64 encoding instead of google api client


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/8ea53a4b
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/8ea53a4b
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/8ea53a4b

Branch: refs/heads/release-2.0.0
Commit: 8ea53a4b087b4a4df5ff142250c1d6f4d7004009
Parents: f6a0c67
Author: Vikas Kedigehalli <vikasrk@google.com>
Authored: Fri May 5 19:33:45 2017 -0700
Committer: Luke Cwik <lcwik@google.com>
Committed: Tue May 9 09:54:29 2017 -0700

----------------------------------------------------------------------
 .../org/apache/beam/sdk/coders/StructuralByteArray.java   |  4 ++--
 .../org/apache/beam/sdk/testing/MatcherDeserializer.java  |  4 ++--
 .../org/apache/beam/sdk/testing/MatcherSerializer.java    |  4 ++--
 .../main/java/org/apache/beam/sdk/util/CoderUtils.java    | 10 +++++++---
 4 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/8ea53a4b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/StructuralByteArray.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/StructuralByteArray.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/StructuralByteArray.java
index 226f79c..edde68e 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/StructuralByteArray.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/StructuralByteArray.java
@@ -17,8 +17,8 @@
  */
 package org.apache.beam.sdk.coders;
 
-import static com.google.api.client.util.Base64.encodeBase64String;
 
+import com.google.common.io.BaseEncoding;
 import java.util.Arrays;
 
 /**
@@ -53,6 +53,6 @@ public class StructuralByteArray {
 
   @Override
   public String toString() {
-    return "base64:" + encodeBase64String(value);
+    return "base64:" + BaseEncoding.base64().encode(value);
   }
 }

http://git-wip-us.apache.org/repos/asf/beam/blob/8ea53a4b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherDeserializer.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherDeserializer.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherDeserializer.java
index 6ca07ba..e7aa5a7 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherDeserializer.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherDeserializer.java
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.JsonDeserializer;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.api.client.util.Base64;
+import com.google.common.io.BaseEncoding;
 import java.io.IOException;
 import org.apache.beam.sdk.util.SerializableUtils;
 
@@ -36,7 +36,7 @@ class MatcherDeserializer extends JsonDeserializer<SerializableMatcher<?>>
{
       throws IOException, JsonProcessingException {
     ObjectNode node = jsonParser.readValueAsTree();
     String matcher = node.get("matcher").asText();
-    byte[] in = Base64.decodeBase64(matcher);
+    byte[] in = BaseEncoding.base64().decode(matcher);
     return (SerializableMatcher<?>) SerializableUtils
         .deserializeFromByteArray(in, "SerializableMatcher");
   }

http://git-wip-us.apache.org/repos/asf/beam/blob/8ea53a4b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherSerializer.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherSerializer.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherSerializer.java
index 2b4584c..35375f6 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherSerializer.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/MatcherSerializer.java
@@ -21,7 +21,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonSerializer;
 import com.fasterxml.jackson.databind.SerializerProvider;
-import com.google.api.client.util.Base64;
+import com.google.common.io.BaseEncoding;
 import java.io.IOException;
 import org.apache.beam.sdk.util.SerializableUtils;
 
@@ -33,7 +33,7 @@ class MatcherSerializer extends JsonSerializer<SerializableMatcher<?>>
{
   public void serialize(SerializableMatcher<?> matcher, JsonGenerator jsonGenerator,
       SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
     byte[] out = SerializableUtils.serializeToByteArray(matcher);
-    String encodedString = Base64.encodeBase64String(out);
+    String encodedString = BaseEncoding.base64().encode(out);
     jsonGenerator.writeStartObject();
     jsonGenerator.writeStringField("matcher", encodedString);
     jsonGenerator.writeEndObject();

http://git-wip-us.apache.org/repos/asf/beam/blob/8ea53a4b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/CoderUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/CoderUtils.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/CoderUtils.java
index 3380a10..da77829 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/CoderUtils.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/CoderUtils.java
@@ -17,8 +17,9 @@
  */
 package org.apache.beam.sdk.util;
 
-import com.google.api.client.util.Base64;
 import com.google.common.base.Throwables;
+import com.google.common.io.BaseEncoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -26,6 +27,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.ref.SoftReference;
 import java.lang.reflect.ParameterizedType;
+
 import org.apache.beam.sdk.coders.Coder;
 import org.apache.beam.sdk.coders.CoderException;
 import org.apache.beam.sdk.values.TypeDescriptor;
@@ -163,7 +165,7 @@ public final class CoderUtils {
   public static <T> String encodeToBase64(Coder<T> coder, T value)
       throws CoderException {
     byte[] rawValue = encodeToByteArray(coder, value);
-    return Base64.encodeBase64URLSafeString(rawValue);
+    return BaseEncoding.base64Url().omitPadding().encode(rawValue);
   }
 
   /**
@@ -171,7 +173,9 @@ public final class CoderUtils {
    */
   public static <T> T decodeFromBase64(Coder<T> coder, String encodedValue) throws
CoderException {
     return decodeFromSafeStream(
-        coder, new ByteArrayInputStream(Base64.decodeBase64(encodedValue)), Coder.Context.OUTER);
+        coder,
+        new ByteArrayInputStream(BaseEncoding.base64Url().omitPadding().decode(encodedValue)),
+        Coder.Context.OUTER);
   }
 
   /**


Mime
View raw message