public static DataBuffer readUnknown(DataInputStream s, long length) {
    """
	Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
	@param s
	@return
    """
        DataBuffer buffer = Nd4j.createBuffer(length);
        buffer.read(s);
        // if buffer is uncompressed, it'll be valid buffer, so we'll just return it
        if (buffer.dataType() != Type.COMPRESSED)
            return buffer;
        else {
            try {

                // if buffer is compressed one, we''ll restore it here
                String compressionAlgorithm = s.readUTF();
                long compressedLength = s.readLong();
                long originalLength = s.readLong();
                long numberOfElements = s.readLong();

                byte[] temp = new byte[(int) compressedLength];
                for (int i = 0; i < compressedLength; i++) {
                    temp[i] = s.readByte();
                }

                Pointer pointer = new BytePointer(temp);
                CompressionDescriptor descriptor = new CompressionDescriptor();
                descriptor.setCompressedLength(compressedLength);
                descriptor.setCompressionAlgorithm(compressionAlgorithm);
                descriptor.setOriginalLength(originalLength);
                descriptor.setNumberOfElements(numberOfElements);
                return new CompressedDataBuffer(pointer, descriptor);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
public static DataBuffer readUnknown(DataInputStream s, long length) {
        DataBuffer buffer = Nd4j.createBuffer(length);
        buffer.read(s);
        // if buffer is uncompressed, it'll be valid buffer, so we'll just return it
        if (buffer.dataType() != Type.COMPRESSED)
            return buffer;
        else {
            try {

                // if buffer is compressed one, we''ll restore it here
                String compressionAlgorithm = s.readUTF();
                long compressedLength = s.readLong();
                long originalLength = s.readLong();
                long numberOfElements = s.readLong();

                byte[] temp = new byte[(int) compressedLength];
                for (int i = 0; i < compressedLength; i++) {
                    temp[i] = s.readByte();
                }

                Pointer pointer = new BytePointer(temp);
                CompressionDescriptor descriptor = new CompressionDescriptor();
                descriptor.setCompressedLength(compressedLength);
                descriptor.setCompressionAlgorithm(compressionAlgorithm);
                descriptor.setOriginalLength(originalLength);
                descriptor.setNumberOfElements(numberOfElements);
                return new CompressedDataBuffer(pointer, descriptor);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
public static DataBuffer readUnknown ( DataInputStream s , long length ) { DataBuffer buffer = Nd4j . createBuffer ( length ) ; buffer . read ( s ) ; // if buffer is uncompressed, it'll be valid buffer, so we'll just return it if ( buffer . dataType ( ) != Type . COMPRESSED ) return buffer ; else { try { // if buffer is compressed one, we''ll restore it here String compressionAlgorithm = s . readUTF ( ) ; long compressedLength = s . readLong ( ) ; long originalLength = s . readLong ( ) ; long numberOfElements = s . readLong ( ) ; byte [ ] temp = new byte [ ( int ) compressedLength ] ; for ( int i = 0 ; i < compressedLength ; i ++ ) { temp [ i ] = s . readByte ( ) ; } Pointer pointer = new BytePointer ( temp ) ; CompressionDescriptor descriptor = new CompressionDescriptor ( ) ; descriptor . setCompressedLength ( compressedLength ) ; descriptor . setCompressionAlgorithm ( compressionAlgorithm ) ; descriptor . setOriginalLength ( originalLength ) ; descriptor . setNumberOfElements ( numberOfElements ) ; return new CompressedDataBuffer ( pointer , descriptor ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } }
Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
@param s
@return
Drop - in replacement wrapper for BaseDataBuffer . read () method aware of CompressedDataBuffer