Search in sources :

Example 1 with BulkLoadParser

use of org.apache.ignite.internal.processors.bulkload.BulkLoadParser in project ignite by apache.

the class DmlStatementsProcessor method processBulkLoadCommand.

/**
 * Process bulk load COPY command.
 *
 * @param cmd The command.
 * @return The context (which is the result of the first request/response).
 * @throws IgniteCheckedException If something failed.
 */
public FieldsQueryCursor<List<?>> processBulkLoadCommand(SqlBulkLoadCommand cmd) throws IgniteCheckedException {
    if (cmd.packetSize() == null)
        cmd.packetSize(BulkLoadAckClientParameters.DFLT_PACKET_SIZE);
    GridH2Table tbl = idx.dataTable(cmd.schemaName(), cmd.tableName());
    if (tbl == null) {
        idx.kernalContext().cache().createMissingQueryCaches();
        tbl = idx.dataTable(cmd.schemaName(), cmd.tableName());
    }
    if (tbl == null) {
        throw new IgniteSQLException("Table does not exist: " + cmd.tableName(), IgniteQueryErrorCode.TABLE_NOT_FOUND);
    }
    UpdatePlan plan = UpdatePlanBuilder.planForBulkLoad(cmd, tbl);
    IgniteClosureX<List<?>, IgniteBiTuple<?, ?>> dataConverter = new BulkLoadDataConverter(plan);
    GridCacheContext cache = tbl.cache();
    IgniteDataStreamer<Object, Object> streamer = cache.grid().dataStreamer(cache.name());
    BulkLoadCacheWriter outputWriter = new BulkLoadStreamerWriter(streamer);
    BulkLoadParser inputParser = BulkLoadParser.createParser(cmd.inputFormat());
    BulkLoadProcessor processor = new BulkLoadProcessor(inputParser, dataConverter, outputWriter);
    BulkLoadAckClientParameters params = new BulkLoadAckClientParameters(cmd.localFileName(), cmd.packetSize());
    return new BulkLoadContextCursor(processor, params);
}
Also used : BulkLoadContextCursor(org.apache.ignite.cache.query.BulkLoadContextCursor) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) BulkLoadCacheWriter(org.apache.ignite.internal.processors.bulkload.BulkLoadCacheWriter) BulkLoadAckClientParameters(org.apache.ignite.internal.processors.bulkload.BulkLoadAckClientParameters) BulkLoadParser(org.apache.ignite.internal.processors.bulkload.BulkLoadParser) BulkLoadProcessor(org.apache.ignite.internal.processors.bulkload.BulkLoadProcessor) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) BulkLoadStreamerWriter(org.apache.ignite.internal.processors.bulkload.BulkLoadStreamerWriter) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) List(java.util.List) ArrayList(java.util.ArrayList) UpdatePlan(org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 BulkLoadContextCursor (org.apache.ignite.cache.query.BulkLoadContextCursor)1 BulkLoadAckClientParameters (org.apache.ignite.internal.processors.bulkload.BulkLoadAckClientParameters)1 BulkLoadCacheWriter (org.apache.ignite.internal.processors.bulkload.BulkLoadCacheWriter)1 BulkLoadParser (org.apache.ignite.internal.processors.bulkload.BulkLoadParser)1 BulkLoadProcessor (org.apache.ignite.internal.processors.bulkload.BulkLoadProcessor)1 BulkLoadStreamerWriter (org.apache.ignite.internal.processors.bulkload.BulkLoadStreamerWriter)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)1 UpdatePlan (org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan)1 GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)1 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)1