Search in sources :

Example 1 with DmlBulkLoadDataConverter

use of org.apache.ignite.internal.processors.query.h2.dml.DmlBulkLoadDataConverter in project ignite by apache.

the class CommandProcessor method processBulkLoadCommand.

/**
 * Process bulk load COPY command.
 *
 * @param cmd The command.
 * @param qryId Query id.
 * @return The context (which is the result of the first request/response).
 * @throws IgniteCheckedException If something failed.
 */
private FieldsQueryCursor<List<?>> processBulkLoadCommand(SqlBulkLoadCommand cmd, long qryId) throws IgniteCheckedException {
    if (cmd.packetSize() == null)
        cmd.packetSize(BulkLoadAckClientParameters.DFLT_PACKET_SIZE);
    GridH2Table tbl = schemaMgr.dataTable(cmd.schemaName(), cmd.tableName());
    if (tbl == null) {
        throw new IgniteSQLException("Table does not exist: " + cmd.tableName(), IgniteQueryErrorCode.TABLE_NOT_FOUND);
    }
    H2Utils.checkAndStartNotStartedCache(ctx, tbl);
    UpdatePlan plan = UpdatePlanBuilder.planForBulkLoad(cmd, tbl);
    IgniteClosureX<List<?>, IgniteBiTuple<?, ?>> dataConverter = new DmlBulkLoadDataConverter(plan);
    IgniteDataStreamer<Object, Object> streamer = ctx.grid().dataStreamer(tbl.cacheName());
    BulkLoadCacheWriter outputWriter = new BulkLoadStreamerWriter(streamer);
    BulkLoadParser inputParser = BulkLoadParser.createParser(cmd.inputFormat());
    BulkLoadProcessor processor = new BulkLoadProcessor(inputParser, dataConverter, outputWriter, idx.runningQueryManager(), qryId, ctx.tracing());
    BulkLoadAckClientParameters params = new BulkLoadAckClientParameters(cmd.localFileName(), cmd.packetSize());
    return new BulkLoadContextCursor(processor, params);
}
Also used : BulkLoadContextCursor(org.apache.ignite.cache.query.BulkLoadContextCursor) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) BulkLoadCacheWriter(org.apache.ignite.internal.processors.bulkload.BulkLoadCacheWriter) DmlBulkLoadDataConverter(org.apache.ignite.internal.processors.query.h2.dml.DmlBulkLoadDataConverter) 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) ArrayList(java.util.ArrayList) List(java.util.List) 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 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)1 DmlBulkLoadDataConverter (org.apache.ignite.internal.processors.query.h2.dml.DmlBulkLoadDataConverter)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