public static <T> T deserialize(byte[] buffer, Class<T> clazz) { Kryo kryo = SerializationUtilities.borrowKryo(); kryo.setClassLoader(Thread.currentThread().getContextClassLoader()); T result = null; try { result = kryo.readObject(new Input(new ByteArrayInputStream(buffer)), clazz); } finally { SerializationUtilities.releaseKryo(kryo); } return result; }
private static byte[] serializeObjectToKryo(Serializable object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Output output = new Output(baos); Kryo kryo = borrowKryo(); try { kryo.writeObject(output, object); } finally { releaseKryo(kryo); } output.close(); return baos.toByteArray(); }
private static <T extends Serializable> T deserializeObjectFromKryo(byte[] bytes, Class<T> clazz) { Input inp = new Input(new ByteArrayInputStream(bytes)); Kryo kryo = borrowKryo(); T func = null; try { func = kryo.readObject(inp, clazz); } finally { releaseKryo(kryo); } inp.close(); return func; }
public static byte[] serialize(Object object) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Output output = new Output(stream); Kryo kryo = SerializationUtilities.borrowKryo(); kryo.setClassLoader(Thread.currentThread().getContextClassLoader()); try { kryo.writeObject(output, object); } finally { SerializationUtilities.releaseKryo(kryo); } output.close(); // close() also calls flush() return stream.toByteArray(); }
public void add(ROW row) { Kryo kryo = SerializationUtilities.borrowKryo(); try { kryo.writeClassAndObject(output, row); } finally { SerializationUtilities.releaseKryo(kryo); } rowsOnDisk++; }
private static void serializePlan(Object plan, OutputStream out, boolean cloningPlan) { Kryo kryo = borrowKryo(); try { serializePlan(kryo, plan, out, cloningPlan); } finally { releaseKryo(kryo); } }
private static <T> T deserializePlan(InputStream in, Class<T> planClass, boolean cloningPlan) { Kryo kryo = borrowKryo(); T result = null; try { result = deserializePlan(kryo, in, planClass, cloningPlan); } finally { releaseKryo(kryo); } return result; }
public static <T> T deserialize(byte[] buffer, Class<T> clazz) { Kryo kryo = SerializationUtilities.borrowKryo(); kryo.setClassLoader(Thread.currentThread().getContextClassLoader()); T result = null; try { result = kryo.readObject(new Input(new ByteArrayInputStream(buffer)), clazz); } finally { SerializationUtilities.releaseKryo(kryo); } return result; }
private static <T> T deserializePlan(InputStream in, Class<T> planClass, boolean cloningPlan) { Kryo kryo = borrowKryo(); T result = null; try { result = deserializePlan(kryo, in, planClass, cloningPlan); } finally { releaseKryo(kryo); } return result; }
public void add(ROW row) { Kryo kryo = SerializationUtilities.borrowKryo(); try { kryo.writeClassAndObject(output, row); } finally { SerializationUtilities.releaseKryo(kryo); } rowsOnDisk++; }
private static void serializePlan(Object plan, OutputStream out, boolean cloningPlan) { Kryo kryo = borrowKryo(); try { serializePlan(kryo, plan, out, cloningPlan); } finally { releaseKryo(kryo); } }
Utilities.FILE_OP_LOGGER.trace("About to read stats file {} ", file.getPath()); Input in = new Input(fs.open(file.getPath())); Kryo kryo = SerializationUtilities.borrowKryo(); try { statsMap = kryo.readObject(in, statsMap.getClass());
private static byte[] serializeObjectToKryo(Serializable object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Output output = new Output(baos); Kryo kryo = borrowKryo(); try { kryo.writeObject(output, object); } finally { releaseKryo(kryo); } output.close(); return baos.toByteArray(); }
private static <T extends Serializable> T deserializeObjectFromKryo(byte[] bytes, Class<T> clazz) { Input inp = new Input(new ByteArrayInputStream(bytes)); Kryo kryo = borrowKryo(); T func = null; try { func = kryo.readObject(inp, clazz); } finally { releaseKryo(kryo); } inp.close(); return func; }
public static byte[] serialize(Object object) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Output output = new Output(stream); Kryo kryo = SerializationUtilities.borrowKryo(); kryo.setClassLoader(Thread.currentThread().getContextClassLoader()); try { kryo.writeObject(output, object); } finally { SerializationUtilities.releaseKryo(kryo); } output.close(); // close() also calls flush() return stream.toByteArray(); }
LOG.debug("Created file : " + statsFile); LOG.debug("Writing stats in it : " + statsMap); Kryo kryo = SerializationUtilities.borrowKryo(); try { kryo.writeObject(output, statsMap);
public BytesBytesMultiHashMap getHashMapFromDisk(int rowCount) throws IOException, ClassNotFoundException { if (hashMapSpilledOnCreation) { return new BytesBytesMultiHashMap(rowCount, loadFactor, wbSize, -1); } else { InputStream inputStream = Files.newInputStream(hashMapLocalPath); com.esotericsoftware.kryo.io.Input input = new com.esotericsoftware.kryo.io.Input(inputStream); Kryo kryo = SerializationUtilities.borrowKryo(); BytesBytesMultiHashMap restoredHashMap = null; try { restoredHashMap = kryo.readObject(input, BytesBytesMultiHashMap.class); } finally { SerializationUtilities.releaseKryo(kryo); } if (rowCount > 0) { restoredHashMap.expandAndRehashToTarget(rowCount); } // some bookkeeping rowsOnDisk = 0; hashMapOnDisk = false; input.close(); inputStream.close(); Files.delete(hashMapLocalPath); return restoredHashMap; } }
public BytesBytesMultiHashMap getHashMapFromDisk(int rowCount) throws IOException, ClassNotFoundException { if (hashMapSpilledOnCreation) { return new BytesBytesMultiHashMap(rowCount, loadFactor, wbSize, -1); } else { InputStream inputStream = Files.newInputStream(hashMapLocalPath); com.esotericsoftware.kryo.io.Input input = new com.esotericsoftware.kryo.io.Input(inputStream); Kryo kryo = SerializationUtilities.borrowKryo(); BytesBytesMultiHashMap restoredHashMap = null; try { restoredHashMap = kryo.readObject(input, BytesBytesMultiHashMap.class); } finally { SerializationUtilities.releaseKryo(kryo); } if (rowCount > 0) { restoredHashMap.expandAndRehashToTarget(rowCount); } // some bookkeeping rowsOnDisk = 0; hashMapOnDisk = false; input.close(); inputStream.close(); Files.delete(hashMapLocalPath); return restoredHashMap; } }
private ByteBuffer getSerializedSargForMetastore(boolean isOriginal) { if (sarg == null) { return null; } ByteBuffer serializedSarg = isOriginal ? sargIsOriginal : sargNotIsOriginal; if (serializedSarg != null) { return serializedSarg; } SearchArgument sarg2 = sarg; Kryo kryo = SerializationUtilities.borrowKryo(); try { if ((isOriginal ? sargNotIsOriginal : sargIsOriginal) == null) { sarg2 = kryo.copy(sarg2); // In case we need it for the other case. } translateSargToTableColIndexes(sarg2, conf, OrcInputFormat.getRootColumn(isOriginal)); ExternalCache.Baos baos = new Baos(); Output output = new Output(baos); kryo.writeObject(output, sarg2); output.flush(); serializedSarg = baos.get(); if (isOriginal) { sargIsOriginal = serializedSarg; } else { sargNotIsOriginal = serializedSarg; } } finally { SerializationUtilities.releaseKryo(kryo); } return serializedSarg; }
private ByteBuffer getSerializedSargForMetastore(boolean isOriginal) { if (sarg == null) return null; ByteBuffer serializedSarg = isOriginal ? sargIsOriginal : sargNotIsOriginal; if (serializedSarg != null) return serializedSarg; SearchArgument sarg2 = sarg; Kryo kryo = SerializationUtilities.borrowKryo(); try { if ((isOriginal ? sargNotIsOriginal : sargIsOriginal) == null) { sarg2 = kryo.copy(sarg2); // In case we need it for the other case. } translateSargToTableColIndexes(sarg2, conf, OrcInputFormat.getRootColumn(isOriginal)); ExternalCache.Baos baos = new Baos(); Output output = new Output(baos); kryo.writeObject(output, sarg2); output.flush(); serializedSarg = baos.get(); if (isOriginal) { sargIsOriginal = serializedSarg; } else { sargNotIsOriginal = serializedSarg; } } finally { SerializationUtilities.releaseKryo(kryo); } return serializedSarg; }