view src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java @ 74:17365ed26611 embedded

In Java, you cannot get a pointer to a String, in order to make a faster memory copy. So I had to change a StringBuilder to a CharBuffer which allows to retrieve the pointer and make a faster processing.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Thu, 15 Dec 2016 11:25:04 +0100 (2016-12-15)
parents 953422c41194
children 0ae34196c54e
line wrap: on
line source
package nl.cwi.monetdb.mcl.protocol;

import nl.cwi.monetdb.jdbc.MonetConnection;
import nl.cwi.monetdb.mcl.responses.AutoCommitResponse;
import nl.cwi.monetdb.mcl.responses.SchemaResponse;
import nl.cwi.monetdb.mcl.responses.UpdateResponse;
import nl.cwi.monetdb.mcl.responses.DataBlockResponse;
import nl.cwi.monetdb.mcl.responses.ResultSetResponse;

import java.io.IOException;
import java.util.Map;

/**
 * Created by ferreira on 11/30/16.
 */
public abstract class AbstractProtocol {

    protected ServerResponses currentServerResponseHeader = ServerResponses.UNKNOWN;

    public abstract ServerResponses waitUntilPrompt() throws IOException;

    public abstract void fetchNextResponseData() throws IOException; //UPDATE currentData!!!

    public ServerResponses getCurrentServerResponseHeader() {
        return currentServerResponseHeader;
    }

    public abstract Object getCurrentData();

    public abstract StarterHeaders getNextStarterHeader();

    public abstract ResultSetResponse getNextResultSetResponse(MonetConnection con, MonetConnection.ResponseList list,
                                                               int seqnr) throws ProtocolException;

    public abstract UpdateResponse getNextUpdateResponse() throws ProtocolException;

    public SchemaResponse getNextSchemaResponse() {
        return new SchemaResponse();
    }

    public abstract AutoCommitResponse getNextAutoCommitResponse() throws ProtocolException;

    public abstract DataBlockResponse getNextDatablockResponse(Map<Integer, ResultSetResponse> rsresponses)
            throws ProtocolException;

    public abstract TableResultHeaders getNextTableHeader(Object line, String[] stringValues, int[] intValues)
            throws ProtocolException;

    public abstract int parseTupleLine(int lineNumber, Object line, int[] typesMap, Object[] values, boolean[] nulls)
            throws ProtocolException;

    public abstract String getRemainingStringLine(int startIndex);

    public abstract void writeNextQuery(String prefix, String query, String suffix) throws IOException;
}