You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2015/08/13 11:53:43 UTC
incubator-kylin git commit: asm conflict
Repository: incubator-kylin
Updated Branches:
refs/heads/KYLIN-909 63ab20daf -> 578759809
asm conflict
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/57875980
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/57875980
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/57875980
Branch: refs/heads/KYLIN-909
Commit: 578759809eef15e1c7798cc96f62268aff0aac78
Parents: 63ab20d
Author: honma <ho...@ebay.com>
Authored: Thu Aug 13 17:54:37 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Thu Aug 13 17:54:37 2015 +0800
----------------------------------------------------------------------
core-common/pom.xml | 10 +---
.../kylin/common/util/CompressionUtils.java | 8 +--
.../org/apache/kylin/common/util/KryoUtils.java | 62 --------------------
.../org/apache/kylin/common/util/BasicTest.java | 34 ++---------
.../java/org/apache/kylin/gridtable/GTInfo.java | 11 ++--
pom.xml | 27 +++++----
storage/pom.xml | 5 ++
.../storage/cube/CubeHBaseEndpointRPC.java | 2 +-
.../apache/kylin/storage/cube/CubeScanner.java | 14 +++--
.../coprocessor/endpoint/CubeVisitService.java | 2 +-
.../kylin/storage/util/BitSetSerializer.java | 62 ++++++++++++++++++++
.../apache/kylin/storage/util/KryoUtils.java | 61 +++++++++++++++++++
12 files changed, 169 insertions(+), 129 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/core-common/pom.xml
----------------------------------------------------------------------
diff --git a/core-common/pom.xml b/core-common/pom.xml
index a439801..76d6868 100644
--- a/core-common/pom.xml
+++ b/core-common/pom.xml
@@ -84,15 +84,7 @@
<groupId>com.ning</groupId>
<artifactId>compress-lzf</artifactId>
</dependency>
- <dependency>
- <groupId>com.esotericsoftware</groupId>
- <artifactId>kryo</artifactId>
- </dependency>
- <dependency>
- <groupId>de.javakaffee</groupId>
- <artifactId>kryo-serializers</artifactId>
- <version>0.35</version>
- </dependency>
+
<!-- Logging -->
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/core-common/src/main/java/org/apache/kylin/common/util/CompressionUtils.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/CompressionUtils.java b/core-common/src/main/java/org/apache/kylin/common/util/CompressionUtils.java
index 6dda7ec..a1d256b 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/CompressionUtils.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/CompressionUtils.java
@@ -29,8 +29,8 @@ public class CompressionUtils {
outputStream.close();
byte[] output = outputStream.toByteArray();
- logger.info("Original: " + data.length / 1024 + " Kb");
- logger.info("Compressed: " + output.length / 1024 + " Kb");
+ logger.info("Original: " + data.length + " bytes");
+ logger.info("Compressed: " + output.length + " bytes");
return output;
}
@@ -47,8 +47,8 @@ public class CompressionUtils {
outputStream.close();
byte[] output = outputStream.toByteArray();
- logger.info("Original: " + data.length);
- logger.info("Decompressed: " + output.length);
+ logger.info("Original: " + data.length + " bytes");
+ logger.info("Decompressed: " + output.length + " bytes");
return output;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/core-common/src/main/java/org/apache/kylin/common/util/KryoUtils.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/KryoUtils.java b/core-common/src/main/java/org/apache/kylin/common/util/KryoUtils.java
deleted file mode 100644
index 42b0d73..0000000
--- a/core-common/src/main/java/org/apache/kylin/common/util/KryoUtils.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.kylin.common.util;
-
-import java.util.BitSet;
-
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-import de.javakaffee.kryoserializers.BitSetSerializer;
-
-public class KryoUtils {
-
- private static ThreadLocal<Kryo> _Kryo = new ThreadLocal<>();
-
- public static byte[] serialize(Object obj) {
- Kryo kryo = getKryo();
- Output output = new Output(1024, 2014 * 1024);
- kryo.writeObject(output, obj);
- return output.toBytes();
- }
-
- public static <T> T deserialize(byte[] bytes, Class<T> clazz) {
- Kryo kryo = getKryo();
- Input input = new Input(bytes);
- return kryo.readObject(input, clazz);
- }
-
- public static <T> T copy(T origin, Class<T> clazz) {
- byte[] bytes = serialize(origin);
- return deserialize(bytes, clazz);
- }
-
- private static Kryo getKryo() {
- if (_Kryo.get() == null) {
- Kryo kryo = new Kryo();
- kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
- kryo.register(BitSet.class, new BitSetSerializer());
- _Kryo.set(kryo);
- }
-
- return _Kryo.get();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/core-common/src/test/java/org/apache/kylin/common/util/BasicTest.java
----------------------------------------------------------------------
diff --git a/core-common/src/test/java/org/apache/kylin/common/util/BasicTest.java b/core-common/src/test/java/org/apache/kylin/common/util/BasicTest.java
index 46f4b78..cf2d3fc 100644
--- a/core-common/src/test/java/org/apache/kylin/common/util/BasicTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/util/BasicTest.java
@@ -23,24 +23,17 @@ import java.nio.ByteBuffer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.BitSet;
import java.util.Calendar;
import java.util.IdentityHashMap;
-import com.google.protobuf.ByteString;
import org.apache.commons.configuration.ConfigurationException;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
-import org.objenesis.strategy.StdInstantiatorStrategy;
import org.slf4j.LoggerFactory;
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
import com.google.common.collect.Lists;
import com.google.common.collect.TreeMultiset;
-import de.javakaffee.kryoserializers.BitSetSerializer;
/**
* <p/>
@@ -72,12 +65,12 @@ public class BasicTest {
@Test
public void testxx() {
byte[] temp = new byte[] { 1, 2, 3 };
-
+
ByteBuffer buffer = ByteBuffer.allocateDirect(3);
- buffer.put((byte)1);
- buffer.put((byte)1);
- buffer.put((byte)1);
- buffer.put((byte)1);
+ buffer.put((byte) 1);
+ buffer.put((byte) 1);
+ buffer.put((byte) 1);
+ buffer.put((byte) 1);
System.out.println(buffer.position());
System.out.println(buffer.limit());
System.out.println(buffer.capacity());
@@ -87,23 +80,6 @@ public class BasicTest {
@Test
public void test0() throws Exception {
- FatherBean father = new FatherBean();
- father.age = 50;
- father.name = "yuan";
-
- father.init();
-
- Kryo kryo = new Kryo();
-
- kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
- kryo.register(BitSet.class, new BitSetSerializer());
- Output output = new Output(1024, 2014 * 1024);
- kryo.writeObject(output, father);
- byte[] persisted = output.toBytes();
-
- Input input = new Input(persisted);
- FatherBean newFather = kryo.readObject(input, FatherBean.class);
-
TreeMultiset<Long> xx = TreeMultiset.create();
xx.add(2L);
xx.add(1L);
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
index c78586e..b45a015 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
@@ -6,7 +6,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import org.apache.kylin.common.util.ImmutableBitSet;
-import org.apache.kylin.common.util.KryoUtils;
import org.apache.kylin.metadata.model.DataType;
import org.apache.kylin.metadata.model.TblColRef;
@@ -40,12 +39,14 @@ public class GTInfo {
private GTInfo() {
}
- public byte[] serializedTrimmedVersion() {
+ public IGTCodeSystem trimCodeSystemForCoprocessor() {
IGTCodeSystem originalCodeSystem = this.codeSystem;
codeSystem = this.codeSystem.trim();
- byte[] bytes = KryoUtils.serialize(this);
- this.codeSystem = originalCodeSystem;
- return bytes;
+ return originalCodeSystem;
+ }
+
+ public void setIGTCodeSystem(IGTCodeSystem codeSystem) {
+ this.codeSystem = codeSystem;
}
public String getTableName() {
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 38c39bc..0429cbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,8 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -422,7 +423,7 @@
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
- <artifactId>kryo</artifactId>
+ <artifactId>kryo-shaded</artifactId>
<version>${kryo.version}</version>
</dependency>
@@ -536,17 +537,17 @@
</configuration>
</plugin>
<!--<plugin>-->
- <!--<groupId>org.apache.maven.plugins</groupId>-->
- <!--<artifactId>maven-failsafe-plugin</artifactId>-->
- <!--<version>2.6</version>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<goals>-->
- <!--<goal>integration-test</goal>-->
- <!--<goal>verify</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <!--</executions>-->
+ <!--<groupId>org.apache.maven.plugins</groupId>-->
+ <!--<artifactId>maven-failsafe-plugin</artifactId>-->
+ <!--<version>2.6</version>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<goals>-->
+ <!--<goal>integration-test</goal>-->
+ <!--<goal>verify</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/pom.xml
----------------------------------------------------------------------
diff --git a/storage/pom.xml b/storage/pom.xml
index 3d783fe..6c2af3f 100644
--- a/storage/pom.xml
+++ b/storage/pom.xml
@@ -40,6 +40,10 @@
<artifactId>kylin-storage-hbase</artifactId>
<version>${project.parent.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.esotericsoftware</groupId>
+ <artifactId>kryo-shaded</artifactId>
+ </dependency>
<!-- Env & Test -->
<dependency>
@@ -145,6 +149,7 @@
<include>org.apache.kylin:kylin-invertedindex</include>
<include>com.ning:compress-lzf</include>
<include>com.n3twork.druid:extendedset</include>
+ <include>net.sf.trove4j:*</include>
<include>com.esotericsoftware:kryo</include>
<include>com.esotericsoftware:reflectasm</include>
<include>org.ow2.asm:asm</include>
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/src/main/java/org/apache/kylin/storage/cube/CubeHBaseEndpointRPC.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/cube/CubeHBaseEndpointRPC.java b/storage/src/main/java/org/apache/kylin/storage/cube/CubeHBaseEndpointRPC.java
index 4de7882..4c24d76 100644
--- a/storage/src/main/java/org/apache/kylin/storage/cube/CubeHBaseEndpointRPC.java
+++ b/storage/src/main/java/org/apache/kylin/storage/cube/CubeHBaseEndpointRPC.java
@@ -35,7 +35,7 @@ import org.apache.hadoop.hbase.ipc.BlockingRpcCallback;
import org.apache.hadoop.hbase.ipc.ServerRpcController;
import org.apache.kylin.common.util.CompressionUtils;
import org.apache.kylin.common.util.ImmutableBitSet;
-import org.apache.kylin.common.util.KryoUtils;
+import org.apache.kylin.storage.util.KryoUtils;
import org.apache.kylin.common.util.Pair;
import org.apache.kylin.cube.CubeSegment;
import org.apache.kylin.cube.cuboid.Cuboid;
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/src/main/java/org/apache/kylin/storage/cube/CubeScanner.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/cube/CubeScanner.java b/storage/src/main/java/org/apache/kylin/storage/cube/CubeScanner.java
index 4b29bd1..2411a6c 100644
--- a/storage/src/main/java/org/apache/kylin/storage/cube/CubeScanner.java
+++ b/storage/src/main/java/org/apache/kylin/storage/cube/CubeScanner.java
@@ -11,7 +11,7 @@ import java.util.NoSuchElementException;
import java.util.Set;
import org.apache.kylin.common.util.ImmutableBitSet;
-import org.apache.kylin.common.util.KryoUtils;
+import org.apache.kylin.storage.util.KryoUtils;
import org.apache.kylin.cube.CubeSegment;
import org.apache.kylin.cube.cuboid.Cuboid;
import org.apache.kylin.cube.gridtable.CubeGridTable;
@@ -23,6 +23,7 @@ import org.apache.kylin.gridtable.GTScanRange;
import org.apache.kylin.gridtable.GTScanRangePlanner;
import org.apache.kylin.gridtable.GTScanRequest;
import org.apache.kylin.gridtable.GTUtil;
+import org.apache.kylin.gridtable.IGTCodeSystem;
import org.apache.kylin.gridtable.IGTScanner;
import org.apache.kylin.metadata.filter.TupleFilter;
import org.apache.kylin.metadata.model.FunctionDesc;
@@ -37,7 +38,7 @@ public class CubeScanner implements IGTScanner {
final CubeSegment cubeSeg;
final GTInfo info;
- final byte[] trimmedInfo;
+ final byte[] trimmedInfoBytes;
final List<GTScanRequest> scanRequests;
final Scanner scanner;
final Cuboid cuboid;
@@ -64,10 +65,13 @@ public class CubeScanner implements IGTScanner {
scanRequests = Lists.newArrayListWithCapacity(scanRanges.size());
- trimmedInfo = info.serializedTrimmedVersion();
- GTInfo x = KryoUtils.deserialize(trimmedInfo, GTInfo.class);
+ IGTCodeSystem origin = info.trimCodeSystemForCoprocessor();
+ trimmedInfoBytes = KryoUtils.serialize(info);
+ info.setIGTCodeSystem(origin);
+ GTInfo trimmedInfo = KryoUtils.deserialize(this.trimmedInfoBytes, GTInfo.class);
+
for (GTScanRange range : scanRanges) {
- scanRequests.add(new GTScanRequest(x, range, gtDimensions, gtAggrGroups, gtAggrMetrics, gtAggrFuncs, gtFilter, allowPreAggregate));
+ scanRequests.add(new GTScanRequest(trimmedInfo, range, gtDimensions, gtAggrGroups, gtAggrMetrics, gtAggrFuncs, gtFilter, allowPreAggregate));
}
scanner = new Scanner();
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/CubeVisitService.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/CubeVisitService.java b/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/CubeVisitService.java
index 6963045..c1a242d 100644
--- a/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/CubeVisitService.java
+++ b/storage/src/main/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/CubeVisitService.java
@@ -35,7 +35,7 @@ import org.apache.hadoop.hbase.protobuf.ResponseConverter;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.kylin.common.util.CompressionUtils;
-import org.apache.kylin.common.util.KryoUtils;
+import org.apache.kylin.storage.util.KryoUtils;
import org.apache.kylin.cube.kv.RowConstants;
import org.apache.kylin.gridtable.GTRawScanner;
import org.apache.kylin.gridtable.GTRecord;
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/src/main/java/org/apache/kylin/storage/util/BitSetSerializer.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/util/BitSetSerializer.java b/storage/src/main/java/org/apache/kylin/storage/util/BitSetSerializer.java
new file mode 100644
index 0000000..aa423b1
--- /dev/null
+++ b/storage/src/main/java/org/apache/kylin/storage/util/BitSetSerializer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.kylin.storage.util;
+
+import java.util.BitSet;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+public class BitSetSerializer extends Serializer<BitSet> {
+
+ @Override
+ public BitSet copy(final Kryo kryo, final BitSet original) {
+ final BitSet result = new BitSet();
+ final int length = original.length();
+ for(int i = 0; i < length; i++) {
+ result.set(i, original.get(i));
+ }
+ return result;
+ }
+
+ @Override
+ public void write(final Kryo kryo, final Output output, final BitSet bitSet) {
+ final int len = bitSet.length();
+
+ output.writeInt(len, true);
+
+ for(int i = 0; i < len; i++) {
+ output.writeBoolean(bitSet.get(i));
+ }
+ }
+
+ @Override
+ public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) {
+ final int len = input.readInt(true);
+ final BitSet ret = new BitSet(len);
+
+ for(int i = 0; i < len; i++) {
+ ret.set(i, input.readBoolean());
+ }
+
+ return ret;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/57875980/storage/src/main/java/org/apache/kylin/storage/util/KryoUtils.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/util/KryoUtils.java b/storage/src/main/java/org/apache/kylin/storage/util/KryoUtils.java
new file mode 100644
index 0000000..3f67fa0
--- /dev/null
+++ b/storage/src/main/java/org/apache/kylin/storage/util/KryoUtils.java
@@ -0,0 +1,61 @@
+/*
+ * 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.kylin.storage.util;
+
+import java.util.BitSet;
+
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+public class KryoUtils {
+
+ private static ThreadLocal<Kryo> _Kryo = new ThreadLocal<>();
+
+ public static byte[] serialize(Object obj) {
+ Kryo kryo = getKryo();
+ Output output = new Output(1024, 2014 * 1024);
+ kryo.writeObject(output, obj);
+ return output.toBytes();
+ }
+
+ public static <T> T deserialize(byte[] bytes, Class<T> clazz) {
+ Kryo kryo = getKryo();
+ Input input = new Input(bytes);
+ return kryo.readObject(input, clazz);
+ }
+
+ public static <T> T copy(T origin, Class<T> clazz) {
+ byte[] bytes = serialize(origin);
+ return deserialize(bytes, clazz);
+ }
+
+ private static Kryo getKryo() {
+ if (_Kryo.get() == null) {
+ Kryo kryo = new Kryo();
+ kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
+ kryo.register(BitSet.class, new BitSetSerializer());
+ _Kryo.set(kryo);
+ }
+
+ return _Kryo.get();
+ }
+}