diff options
author | michajlo <michajlo@google.com> | 2018-02-13 15:51:16 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-13 15:53:12 -0800 |
commit | f3300b3096a58599d63e64e025666c92e1aef1b1 (patch) | |
tree | 62600c1b639c445efc775ed8c3d8ed68d5fbb8d5 /src/main/java/com | |
parent | d8508989ac30be85f1fd8ac3af2f6f655198c0f9 (diff) |
Drop unused SerializerAdapter
Cleaning up references to {Des,S}erializationContext.UNTHREADED_PLEASE_REMOVE,
deleting the code is easier than deciding how to adapt context.
PiperOrigin-RevId: 185602054
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializerAdapter.java | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializerAdapter.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializerAdapter.java deleted file mode 100644 index 5eaed4e4ef..0000000000 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SerializerAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2018 The Bazel Authors. All rights reserved. -// -// Licensed 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 com.google.devtools.build.lib.skyframe.serialization; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.KryoException; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; -import com.google.protobuf.CodedInputStream; -import com.google.protobuf.CodedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -/** Converts an {@link ObjectCodec} into a Kryo {@link Serializer}. */ -public class SerializerAdapter<T> extends Serializer<T> { - private final ObjectCodec<T> codec; - - public SerializerAdapter(ObjectCodec<T> codec) { - this.codec = codec; - } - - @Override - public void write(Kryo kryo, Output output, T object) { - try { - ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); - CodedOutputStream codedOut = CodedOutputStream.newInstance(byteOutput); - // TODO(shahan): Determine if there's any context we can/should pass along from kryo. - codec.serialize(SerializationContext.UNTHREADED_PLEASE_FIX, object, codedOut); - codedOut.flush(); - byte[] byteData = byteOutput.toByteArray(); - output.writeInt(byteData.length, true); - output.writeBytes(byteData); - } catch (SerializationException | IOException e) { - throw new KryoException(e); - } - } - - @Override - public T read(Kryo kryo, Input input, Class<T> unusedClass) { - try { - byte[] byteData = input.readBytes(input.readInt(true)); - // TODO(shahan): Determine if there's any context we can/should pass along from kryo. - return codec.deserialize( - DeserializationContext.UNTHREADED_PLEASE_FIX, CodedInputStream.newInstance(byteData)); - } catch (SerializationException | IOException e) { - throw new KryoException(e); - } - } -} |