/** * Get object from the storage, by key * * @param key */ @Override public INDArray get(T key) { try { if (emulateIsAbsent) lock.readLock().lock(); if (containsKey(key)) { INDArray result = compressedEntries.get(key); // TODO: we don't save decompressed entries here, but something like LRU might be good idea return compressor.decompress(result); } else { return null; } } finally { if (emulateIsAbsent) lock.readLock().unlock(); } }
/** * Decompress the given databuffer * @param buffer the databuffer to compress * @return the decompressed databuffer */ public DataBuffer decompress(DataBuffer buffer) { if (buffer.dataType() != DataBuffer.Type.COMPRESSED) throw new IllegalStateException("You can't decompress DataBuffer with dataType of: " + buffer.dataType()); CompressedDataBuffer comp = (CompressedDataBuffer) buffer; CompressionDescriptor descriptor = comp.getCompressionDescriptor(); if (!codecs.containsKey(descriptor.getCompressionAlgorithm())) throw new RuntimeException("Non-existent compression algorithm requested: [" + descriptor.getCompressionAlgorithm() + "]"); return codecs.get(descriptor.getCompressionAlgorithm()).decompress(buffer); }
/** * * @param array * @return */ public INDArray decompress(INDArray array) { if (array.data().dataType() != DataBuffer.Type.COMPRESSED) return array; CompressedDataBuffer comp = (CompressedDataBuffer) array.data(); CompressionDescriptor descriptor = comp.getCompressionDescriptor(); if (!codecs.containsKey(descriptor.getCompressionAlgorithm())) throw new RuntimeException("Non-existent compression algorithm requested: [" + descriptor.getCompressionAlgorithm() + "]"); return codecs.get(descriptor.getCompressionAlgorithm()).decompress(array); }
/** * Get object from the storage, by key * * @param key */ @Override public INDArray get(T key) { try { if (emulateIsAbsent) lock.readLock().lock(); if (containsKey(key)) { INDArray result = compressedEntries.get(key); // TODO: we don't save decompressed entries here, but something like LRU might be good idea return compressor.decompress(result); } else { return null; } } finally { if (emulateIsAbsent) lock.readLock().unlock(); } }
/** * Decompress the given databuffer * @param buffer the databuffer to compress * @return the decompressed databuffer */ public DataBuffer decompress(DataBuffer buffer) { if (buffer.dataType() != DataBuffer.Type.COMPRESSED) throw new IllegalStateException("You can't decompress DataBuffer with dataType of: " + buffer.dataType()); CompressedDataBuffer comp = (CompressedDataBuffer) buffer; CompressionDescriptor descriptor = comp.getCompressionDescriptor(); if (!codecs.containsKey(descriptor.getCompressionAlgorithm())) throw new RuntimeException("Non-existent compression algorithm requested: [" + descriptor.getCompressionAlgorithm() + "]"); return codecs.get(descriptor.getCompressionAlgorithm()).decompress(buffer); }
/** * * @param array * @return */ public INDArray decompress(INDArray array) { if (array.data().dataType() != DataBuffer.Type.COMPRESSED) return array; CompressedDataBuffer comp = (CompressedDataBuffer) array.data(); CompressionDescriptor descriptor = comp.getCompressionDescriptor(); if (!codecs.containsKey(descriptor.getCompressionAlgorithm())) throw new RuntimeException("Non-existent compression algorithm requested: [" + descriptor.getCompressionAlgorithm() + "]"); return codecs.get(descriptor.getCompressionAlgorithm()).decompress(array); }