Package org.postgresql.core.v3
Class CopyDualImpl
- java.lang.Object
-
- org.postgresql.core.v3.CopyOperationImpl
-
- org.postgresql.core.v3.CopyDualImpl
-
- All Implemented Interfaces:
CopyDual,CopyIn,CopyOperation,CopyOut
public class CopyDualImpl extends CopyOperationImpl implements CopyDual
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<byte[]>received-
Fields inherited from class org.postgresql.core.v3.CopyOperationImpl
fieldFormats, handledRowCount, queryExecutor, rowFormat
-
-
Constructor Summary
Constructors Constructor Description CopyDualImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longendCopy()Finishes copy operation successfully.voidflushCopy()Force any buffered output to be sent over the network to the backend.voidhandleCommandStatus(java.lang.String status)protected voidhandleCopydata(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.voidwriteToCopy(byte[] data, int off, int siz)Writes specified part of given byte array to an open and writable copy operation.voidwriteToCopy(ByteStreamWriter from)Writes a ByteStreamWriter to an open and writable copy operation.-
Methods inherited from class org.postgresql.core.v3.CopyOperationImpl
cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, getQueryExecutor, init, isActive
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.postgresql.copy.CopyOperation
cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActive
-
-
-
-
Method Detail
-
writeToCopy
public void writeToCopy(byte[] data, int off, int siz) throws java.sql.SQLExceptionDescription copied from interface:CopyInWrites specified part of given byte array to an open and writable copy operation.- Specified by:
writeToCopyin interfaceCopyIn- Parameters:
data- array of bytes to writeoff- offset of first byte to write (normally zero)siz- number of bytes to write (normally buf.length)- Throws:
java.sql.SQLException- if the operation fails
-
writeToCopy
public void writeToCopy(ByteStreamWriter from) throws java.sql.SQLException
Description copied from interface:CopyInWrites a ByteStreamWriter to an open and writable copy operation.- Specified by:
writeToCopyin interfaceCopyIn- Parameters:
from- the source of bytes, e.g. a ByteBufferByteStreamWriter- Throws:
java.sql.SQLException- if the operation fails
-
flushCopy
public void flushCopy() throws java.sql.SQLExceptionDescription copied from interface:CopyInForce 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.
-
endCopy
public long endCopy() throws java.sql.SQLExceptionDescription copied from interface:CopyInFinishes copy operation successfully.
-
readFromCopy
public byte[] readFromCopy() throws java.sql.SQLExceptionDescription copied from interface:CopyOutBlocks wait for a row of data to be received from server on an active copy operation.- Specified by:
readFromCopyin interfaceCopyOut- Returns:
- byte array received from server, null if server complete copy operation
- Throws:
java.sql.SQLException- if something goes wrong for example socket timeout
-
readFromCopy
public byte[] readFromCopy(boolean block) throws java.sql.SQLExceptionDescription copied from interface:CopyOutWait for a row of data to be received from server on an active copy operation.- Specified by:
readFromCopyin interfaceCopyOut- Parameters:
block-trueif need wait data from server otherwisefalseand 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:
java.sql.SQLException- if something goes wrong for example socket timeout
-
handleCommandStatus
public void handleCommandStatus(java.lang.String status) throws PSQLException- Overrides:
handleCommandStatusin classCopyOperationImpl- Throws:
PSQLException
-
handleCopydata
protected void handleCopydata(byte[] data)
Description copied from class:CopyOperationImplConsume received copy data.- Specified by:
handleCopydatain classCopyOperationImpl- Parameters:
data- data that was receive by copy protocol
-
-