Compresses <code>src</code> into <code>dest</code>. Calling this method
will update the positions of both {@link ByteBuffer}s.

@param src the source data
@param dest the destination buffer
@throws LZ4Exception if dest is too small
975629
public void compress(ByteBuffer src, ByteBuffer dest) {
    final int compressedLength = compress(src, src.position(), src.remaining(), dest, dest.position(), dest.remaining());
    src.position(src.limit());
    dest.position(dest.position() + compressedLength);
  }
525180
private void copy(ByteBuf src, ByteBuffer dst) {
		// This branch is necessary, because an Exception is thrown if the
		// destination buffer has more remaining (writable) bytes than
		// currently readable from the Netty ByteBuf source.
		if (src.isReadable()) {
			if (src.readableBytes() < dst.remaining()) {
				int oldLimit = dst.limit();

				dst.limit(dst.position() + src.readableBytes());
				src.readBytes(dst);
				dst.limit(oldLimit);
			}
			else {
				src.readBytes(dst);
			}
		}
	}
973450
public static void copyStream(final InputStream src, OutputStream dest) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while ((read = src.read(buffer)) > -1) {
            dest.write(buffer, 0, read);
        }
        dest.flush();
    }
968980
public final void copyTo(AbstractCoalescingBufferQueue dest) {
        dest.bufAndListenerPairs.addAll(bufAndListenerPairs);
        dest.incrementReadableBytes(readableBytes);
    }
1186341
public static void copyFile(File src, File dest) throws IOException {

        if (src == null)
            throw new NullPointerException("Source must not be null");
        if (dest == null)
            throw new NullPointerException("Destination must not be null");
        if (!src.exists())
            throw new FileNotFoundException("Source '" + src + "' does not exist");
        if (!src.isFile())
            throw new IOException("Source '" + src + "' is not a file");
        if (dest.exists())
            throw new IOException("Destination '" + dest + "' is already exists");

        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(src).getChannel();
            out = new FileOutputStream(dest).getChannel();

            in.transferTo(0, in.size(), out);
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        if (src.length() != dest.length()) {
            throw new IOException("Failed to copy full contents from '" +
                src + "' to '" + dest + "'");
        }

        dest.setLastModified(src.lastModified());
    }
275950
@Override
  public Compressor createCompressor() {
    if (!isNativeCodeLoaded()) {
      throw new RuntimeException("native lz4 library not available");
    }
    int bufferSize = conf.getInt(
        IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_KEY,
        IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_DEFAULT);
    boolean useLz4HC = conf.getBoolean(
        IO_COMPRESSION_CODEC_LZ4_USELZ4HC_KEY,
        IO_COMPRESSION_CODEC_LZ4_USELZ4HC_DEFAULT); 
    return new Lz4Compressor(bufferSize, useLz4HC);
  }
41654
public static Byte decodeByteObjDesc(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            int b = src[srcOffset];
            if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) {
                return null;
            }
            return decodeByteDesc(src, srcOffset + 1);
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
379366
public static IoBuffer copy(ByteBuffer src) {
        IoBuffer copy = IoBuffer.allocate(src.remaining());
        copy.put(src);
        copy.flip();
        return copy;
    }
1180425
private static void copy(ByteBuffer dst, ByteBuffer src) {
    if (dst.hasRemaining() && src.hasRemaining()) {
      // Avoid an allocation if possible.
      if (dst.remaining() >= src.remaining()) {
        dst.put(src);
      } else {
        int count = Math.min(dst.remaining(), src.remaining());
        ByteBuffer slice = src.slice();
        slice.limit(count);
        dst.put(slice);
        src.position(src.position() + count);
      }
    }
  }
737104
public static <S, D extends S> void copyFields(final S src, D dest) throws IllegalArgumentException {
		Class<?> targetClass = src.getClass();

		do {
			Field[] fields = targetClass.getDeclaredFields();
			for (Field field : fields) {
				// Skip static fields:
				if (Modifier.isStatic(field.getModifiers())) {
					continue;
				}
				try {
					if ((!Modifier.isPublic(field.getModifiers())
					            || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
					            || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
						field.setAccessible(true);
					}
					Object srcValue = field.get(src);
					field.set(dest, srcValue);
				}
				catch (IllegalAccessException ex) {
					throw new IllegalStateException(
					            "Shouldn't be illegal to access field '" + field.getName() + "': " + ex);
				}
			}
			targetClass = targetClass.getSuperclass();
		}
		while (targetClass != null && targetClass != Object.class);
	}
850130
public void write_compressed(final OtpErlangObject o, final int level) {
        @SuppressWarnings("resource")
        final OtpOutputStream oos = new OtpOutputStream(o);
        /*
         * similar to erts_term_to_binary() in external.c: We don't want to
         * compress if compression actually increases the size. Since
         * compression uses 5 extra bytes (COMPRESSED tag + size), don't
         * compress if the original term is smaller.
         */
        if (oos.size() < 5) {
            // fast path for small terms
            try {
                oos.writeToAndFlush(this);
                // if the term is written as a compressed term, the output
                // stream is closed, so we do this here, too
                close();
            } catch (final IOException e) {
                throw new java.lang.IllegalArgumentException(
                        "Intermediate stream failed for Erlang object " + o);
            }
        } else {
            final int startCount = super.count;
            // we need destCount bytes for an uncompressed term
            // -> if compression uses more, use the uncompressed term!
            final int destCount = startCount + oos.size();
            fixedSize = destCount;
            final Deflater def = new Deflater(level);
            final java.util.zip.DeflaterOutputStream dos = new java.util.zip.DeflaterOutputStream(
                    this, def);
            try {
                write1(OtpExternal.compressedTag);
                write4BE(oos.size());
                oos.writeTo(dos);
                dos.close(); // note: closes this, too!
            } catch (final IllegalArgumentException e) {
                /*
                 * Discard further un-compressed data (if not called, there may
                 * be memory leaks).
                 *
                 * After calling java.util.zip.Deflater.end(), the deflater
                 * should not be used anymore, not even the close() method of
                 * dos. Calling dos.close() before def.end() is prevented since
                 * an unfinished DeflaterOutputStream will try to deflate its
                 * unprocessed data to the (fixed) byte array which is prevented
                 * by ensureCapacity() and would also unnecessarily process
                 * further data that is discarded anyway.
                 *
                 * Since we are re-using the byte array of this object below, we
                 * must not call close() in e.g. a finally block either (with or
                 * without a call to def.end()).
                 */
                def.end();
                // could not make the value smaller than originally
                // -> reset to starting count, write uncompressed
                super.count = startCount;
                try {
                    oos.writeTo(this);
                    // if the term is written as a compressed term, the output
                    // stream is closed, so we do this here, too
                    close();
                } catch (final IOException e2) {
                    throw new java.lang.IllegalArgumentException(
                            "Intermediate stream failed for Erlang object " + o);
                }
            } catch (final IOException e) {
                throw new java.lang.IllegalArgumentException(
                        "Intermediate stream failed for Erlang object " + o);
            } finally {
                fixedSize = Integer.MAX_VALUE;
            }
        }
    }
1047629
public static void addAll(final Vector dest, final Object[] src) {
    if (src == null) {
      return;
    }
    for (final Object element : src) {
      dest.addElement(element);
    }
  }
939074
def xz_decompress_stream(src):
    
    dec = lzma.LZMADecompressor()
    for block in src:
        decoded = dec.decompress(block)
        if decoded:
            yield decoded

    if dec.unused_data:  # pragma: nocover; can't figure out how to test this
        raise IOError('Read unused data at end of compressed stream')
263618
public static void memcopy(byte[] dest, byte[] src, int copyToIndex) {
		System.arraycopy(src, 0, dest, copyToIndex, src.length);
	}
152225
private static int spliceIn(ByteBuffer src, ByteBuffer dest) {
    int position = dest.position();
    int srcPos = src.position();
    dest.put(src);
    src.position(srcPos);
    return position;
  }
831639
public void decompose(CharSequence s, int src, int limit, StringBuilder dest,
                   int destLengthEstimate) {
        if(destLengthEstimate<0) {
            destLengthEstimate=limit-src;
        }
        dest.setLength(0);
        ReorderingBuffer buffer=new ReorderingBuffer(this, dest, destLengthEstimate);
        decompose(s, src, limit, buffer);
    }
334664
public final void compress(ByteBuffer src, ByteBuffer dest) {
    final int cpLen = compress(src, src.position(), src.remaining(), dest, dest.position(), dest.remaining());
    src.position(src.limit());
    dest.position(dest.position() + cpLen);
  }