All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alicloud.openservices.tablestore.writer.handle.BatchWriteRowRequestManager Maven / Gradle / Ivy

Go to download

Aliyun Open Services SDK for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com

There is a newer version: 5.17.5
Show newest version
package com.alicloud.openservices.tablestore.writer.handle;

import com.alicloud.openservices.tablestore.AsyncClientInterface;
import com.alicloud.openservices.tablestore.TableStoreCallback;
import com.alicloud.openservices.tablestore.model.*;
import com.alicloud.openservices.tablestore.writer.*;
import com.alicloud.openservices.tablestore.writer.config.BucketConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;

public class BatchWriteRowRequestManager extends BaseRequestManager {
    private Logger logger = LoggerFactory.getLogger(BatchWriteRowRequestManager.class);

    public BatchWriteRowRequestManager(AsyncClientInterface ots, WriterConfig writerConfig, BucketConfig bucketConfig, Executor executor,
                                       WriterHandleStatistics writerStatistics, TableStoreCallback callback,
                                       Semaphore callbackSemaphore, Semaphore bucketSemaphore) {
        super(ots, writerConfig, bucketConfig, executor, writerStatistics, callback, callbackSemaphore, bucketSemaphore);
    }

    @Override
    public RequestWithGroups makeRequest() {
        if (rowChangeWithGroups.size() > 0) {
            BatchWriteRowRequest request = new BatchWriteRowRequest();
            List groupFutureList = new ArrayList(rowChangeWithGroups.size());

            for (RowChangeWithGroup rowChangeWithGroup : rowChangeWithGroups) {
                request.addRowChange(rowChangeWithGroup.rowChange);
                groupFutureList.add(rowChangeWithGroup.group);
            }
            clear();
            return new RequestWithGroups(request, groupFutureList);
        }

        return null;
    }

    @Override
    public void sendRequest(RequestWithGroups requestWithGroups) {
        BatchWriteRowRequest finalRequest = (BatchWriteRowRequest) requestWithGroups.getRequest();
        List finalGroupFuture = requestWithGroups.getGroupList();

        ots.batchWriteRow(finalRequest, callbackFactory.newInstance(finalGroupFuture));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy