com.amazon.redshift.core.v3

## Class CopyDualImpl

- java.lang.Object
- - com.amazon.redshift.core.v3.CopyOperationImpl
  - - com.amazon.redshift.core.v3.CopyDualImpl

All Implemented Interfaces:
  CopyDual, CopyIn, CopyOperation, CopyOut

    public class CopyDualImpl
    extends CopyOperationImpl
    implements CopyDual

### Constructor Summary

Constructors
Constructor and Description
`CopyDualImpl()`

### Method Summary

Methods
`long` `endCopy()` Finishes copy operation successfully.
`void` `flushCopy()` Force any buffered output to be sent over the network to the backend.
`void` `handleCommandStatus(String status)`
`protected void` `handleCopydata(byte[] data)` Consume received copy data.
`byte[]` `readFromCopy()` Blocks wait for a row of data to be received from server on an active copy operation.
`byte[]` `readFromCopy(boolean block)` Wait for a row of data to be received from server on an active copy operation.
`void` `writeToCopy(byte[] data, int off, int siz)` Writes specified part of given byte array to an open and writable copy operation.
`void` `writeToCopy(ByteStreamWriter from)` Writes a ByteStreamWriter to an open and writable copy operation.

### Methods inherited from class com.amazon.redshift.core.v3.CopyOperationImpl

`cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActive`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface com.amazon.redshift.copy.CopyOperation

`cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActive`

### Constructor Detail

#### CopyDualImpl

    public CopyDualImpl()

### Method Detail

#### writeToCopy

    public void writeToCopy(byte[] data,
                   int off,
                   int siz)
                     throws SQLException

Description copied from interface: `CopyIn`
Writes specified part of given byte array to an open and writable copy operation.

Specified by:
  `writeToCopy` in interface `CopyIn`
Parameters:
  `data` - array of bytes to write
  `off` - offset of first byte to write (normally zero)
  `siz` - number of bytes to write (normally buf.length)
Throws:
  `SQLException` - if the operation fails

#### writeToCopy

    public void writeToCopy(ByteStreamWriter from)
                     throws SQLException

Description copied from interface: `CopyIn`
Writes a ByteStreamWriter to an open and writable copy operation.

Specified by:
  `writeToCopy` in interface `CopyIn`
Parameters:
  `from` - the source of bytes, e.g. a ByteBufferByteStreamWriter
Throws:
  `SQLException` - if the operation fails

#### flushCopy

    public void flushCopy()
                   throws SQLException

Description copied from interface: `CopyIn`
Force any buffered output to be sent over the network to the backend. In general this is a useless operation as it will get pushed over in due time or when endCopy is called. Some specific modified server versions (Truviso) want this data sooner. If you are unsure if you need to use this method, don't.

Specified by:
  `flushCopy` in interface `CopyIn`
Throws:
  `SQLException` - if the operation fails.

#### endCopy

    public long endCopy()
                 throws SQLException

Description copied from interface: `CopyIn`
Finishes copy operation successfully.

Specified by:
  `endCopy` in interface `CopyIn`
Returns:
  number of updated rows for server 8.2 or newer (see getHandledRowCount())
Throws:
  `SQLException` - if the operation fails.

#### readFromCopy

    public byte[] readFromCopy()
                        throws SQLException

Description copied from interface: `CopyOut`
Blocks wait for a row of data to be received from server on an active copy operation.

Specified by:
  `readFromCopy` in interface `CopyOut`
Returns:
  byte array received from server, null if server complete copy operation
Throws:
  `SQLException` - if something goes wrong for example socket timeout

#### readFromCopy

    public byte[] readFromCopy(boolean block)
                        throws SQLException

Description copied from interface: `CopyOut`
Wait for a row of data to be received from server on an active copy operation.

Specified by:
  `readFromCopy` in interface `CopyOut`
Parameters:
  `block` - `true` if need wait data from server otherwise `false` and will read pending message from server
Returns:
  byte array received from server, if pending message from server absent and use no blocking mode return null
Throws:
  `SQLException` - if something goes wrong for example socket timeout

#### handleCommandStatus

    public void handleCommandStatus(String status)
                             throws RedshiftException

Overrides:
  `handleCommandStatus` in class `CopyOperationImpl`
Throws:
  `RedshiftException`

#### handleCopydata

    protected void handleCopydata(byte[] data)

Description copied from class: `CopyOperationImpl`
Consume received copy data.

Specified by:
  `handleCopydata` in class `CopyOperationImpl`
Parameters:
  `data` - data that was receive by copy protocol