
com.qiniu.process.qoss.StatFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qsuits Show documentation
Show all versions of qsuits Show documentation
qiniu-suits is a efficient tools for qiniu api implemented by java8.
package com.qiniu.process.qoss;
import com.google.gson.*;
import com.qiniu.common.QiniuException;
import com.qiniu.process.Base;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.BucketManager.*;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.model.FileInfo;
import com.qiniu.util.Auth;
import com.qiniu.util.HttpResponseUtils;
import com.qiniu.util.JsonConvertUtils;
import com.qiniu.util.LineUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class StatFile extends Base {
private BucketManager bucketManager;
private BatchOperations batchOperations;
private String format;
private String separator;
public StatFile(String accessKey, String secretKey, Configuration configuration, String bucket, String rmPrefix,
String savePath, String format, String separator, int saveIndex) throws IOException {
super("stat", accessKey, secretKey, configuration, bucket, rmPrefix, savePath, saveIndex);
this.bucketManager = new BucketManager(Auth.create(accessKey, secretKey), configuration.clone());
this.batchOperations = new BatchOperations();
set(format, separator);
this.batchSize = 1000;
}
public void updateStat(String bucket, String format, String separator, String rmPrefix) throws IOException {
this.bucket = bucket;
set(format, separator);
this.rmPrefix = rmPrefix;
}
private void set(String format, String separator) throws IOException {
this.format = format;
if ("csv".equals(format) || "tab".equals(format)) {
this.separator = "csv".equals(format) ? "," : separator;
} else if (!"json".equals(this.format)) {
throw new IOException("please check your format for line to map.");
}
}
public StatFile(String accessKey, String secretKey, Configuration configuration, String bucket, String rmPrefix,
String savePath, String format, String separator) throws IOException {
this(accessKey, secretKey, configuration, bucket, rmPrefix, savePath, format, separator, 0);
}
public StatFile clone() throws CloneNotSupportedException {
StatFile statFile = (StatFile)super.clone();
statFile.bucketManager = new BucketManager(Auth.create(accessKey, secretKey), configuration.clone());
if (batchSize > 1) statFile.batchOperations = new BatchOperations();
return statFile;
}
@Override
synchronized protected String batchResult(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy