public static <T> T deserialize(final byte[] serialForm) { return getKryo().deserialize(serialForm); }
@Override public Object getValue() { if (this.value == null) { return null; } return KryoManager.deserialize(this.value); }
@Override public byte[] serialize(final Object object) { return KryoManager.serialize(object); }
public <T> T deepCopy(final T element) { Kryo kryo = this.getKryo(); T copy = kryo.copy(element); // we have no idea how big the copied object is; // destroy our kryo instance as a precautionary measure this.destroyKryo(); return copy; }
public static List<Object> deserializeObjectsFromFile(final File file) { checkArgument(file.exists(), "Precondition violation - argument 'file' must refer to an existing file!"); checkArgument(file.isFile(), "Precondition violation - argument 'file' must refer to a file (not a directory)!"); checkArgument(file.canRead(), "Precondition violation - argument 'file' must be readable!"); try { return getKryo().deserializeObjectsFromFile(file); } catch (IOException e) { throw new ChronosIOException("Failed to deserialize object(s) from file!", e); } }
public static <T> T deserializeObjectFromFile(final File file) { checkNotNull(file, "Precondition violation - argument 'file' must not be NULL!"); checkArgument(file.exists(), "Precondition violation - argument 'file' must refer to an existing file!"); checkArgument(file.isFile(), "Precondition violation - argument 'file' must refer to a file (not a directory)!"); checkArgument(file.canRead(), "Precondition violation - argument 'file' must be readable!"); try { return getKryo().deserializeObjectFromFile(file); } catch (IOException e) { throw new ChronosIOException("Failed to deserialize object from file!", e); } }
public static void serializeObjectsToFile(final File file, final Object... objects) { checkNotNull(objects, "Precondition violation - argument 'objects' must not be NULL!"); checkNotNull(file, "Precondition violation - argument 'file' must not be NULL!"); checkArgument(file.exists(), "Precondition violation - argument 'file' must refer to an existing file!"); checkArgument(file.isFile(), "Precondition violation - argument 'file' must refer to a file (not a directory)!"); checkArgument(file.canWrite(), "Precondition violation - argument 'file' must be writable!"); try { getKryo().serializeToFile(file, objects); } catch (IOException e) { throw new ChronosIOException("Failed to serialize object to file!", e); } }
private void destroyKryoIfNecessary() { if (this.serializedBytes >= KRYO_REUSE_WRITTEN_BYTES_THRESHOLD_BYTES) { this.destroyKryo(); } if (this.usageCount >= KRYO_REUSE_USAGE_COUNT_THRESHOLD) { this.destroyKryo(); } } }
private Kryo getKryo() { if (this.kryoReference == null) { return this.produceKryo(); } Kryo kryo = this.kryoReference.get(); if (kryo == null) { return this.produceKryo(); } return kryo; }
private static KryoWrapper produceKryoWrapper() { KryoWrapper wrapper = new KryoWrapper(); THREAD_LOCAL_KRYO.set(wrapper); return wrapper; }
private static KryoWrapper getKryo() { KryoWrapper kryoWrapper = THREAD_LOCAL_KRYO.get(); if (kryoWrapper == null) { return produceKryoWrapper(); } return kryoWrapper; }
@Override public Object deserialize(final byte[] serialForm) { return KryoManager.deserialize(serialForm); }
public PropertyRecord(final String key, final Object value) { checkNotNull(key, "Precondition violation - argument 'key' must not be NULL!"); checkNotNull(value, "Precondition violation - argument 'value' must not be NULL!"); this.key = key; this.value = KryoManager.serialize(value); }
public Object getValue() { return KryoManager.deserialize(this.value); }
public void setIndexer(final Indexer<?> indexer) { if (indexer == null) { this.indexerData = null; } else { byte[] serialForm = KryoManager.serialize(indexer); this.indexerData = Base64.getEncoder().encodeToString(serialForm); } }
public Indexer<?> getIndexer() { if (this.indexerData == null) { return null; } else { byte[] serialForm = Base64.getDecoder().decode(this.indexerData); return KryoManager.deserialize(serialForm); } }
public BinaryPropertyDump(final PropertyRecord record) { super(record.getKey()); this.value = KryoManager.serialize(record.getValue()); }
public static IBranchMetadata getMetadata(final TuplTransaction tx, final String name) { checkNotNull(tx, "Precondition violation - argument 'tx' must not be NULL!"); checkNotNull(name, "Precondition violation - argument 'name' must not be NULL!"); byte[] loadedValue = tx.load(NAME, name); if (loadedValue == null) { return null; } return KryoManager.deserialize(loadedValue); }