本文整理汇总了Java中com.aerospike.client.policy.WritePolicy类的典型用法代码示例。如果您正苦于以下问题:Java WritePolicy类的具体用法?Java WritePolicy怎么用?Java WritePolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WritePolicy类属于com.aerospike.client.policy包,在下文中一共展示了WritePolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: update
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
private Map<String, Long> update(KeyRecordIterator results, List<Bin> bins) {
long readCount = 0;
long updateCount = 0;
while (results.hasNext()) {
KeyRecord keyRecord = results.next();
readCount++;
WritePolicy up = new WritePolicy(updatePolicy);
up.generation = keyRecord.record.generation;
try {
client.put(up, keyRecord.key, bins.toArray(new Bin[0]));
updateCount++;
} catch (AerospikeException e) {
System.out.println(keyRecord.key);
}
}
Map<String, Long> map = new HashMap<String, Long>();
map.put("read", readCount);
map.put("write", updateCount);
return map;
}
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:21,代码来源:QueryEngine.java
示例2: init
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
protected void init() throws IOException {
String host = AerospikeConfigUtil.getOutputHost(cfg);
int port = AerospikeConfigUtil.getOutputPort(cfg);
namespace = AerospikeConfigUtil.getOutputNamespace(cfg);
setName = AerospikeConfigUtil.getOutputSetName(cfg);
log.info(String.format("init: %s %d %s %s",
host, port, namespace, setName));
ClientPolicy policy = new ClientPolicy();
policy.user = "";
policy.password = "";
policy.failIfNotConnected = true;
client = AerospikeClientSingleton.getInstance(policy, host, port);
writePolicy = new WritePolicy();
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:21,代码来源:AerospikeRecordWriter.java
示例3: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(Text sessid,
Session session,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
writePolicy.timeout = 10000;
Key kk = new Key(namespace, setName, sessid.toString());
Bin bin0 = new Bin("userid", session.userid);
Bin bin1 = new Bin("start", session.start);
Bin bin2 = new Bin("end", session.end);
Bin bin3 = new Bin("nhits", session.nhits);
Bin bin4 = new Bin("age", session.age);
Bin bin5 = new Bin("isMale", session.isMale);
client.put(writePolicy, kk, bin0, bin1, bin2, bin3, bin4, bin5);
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:18,代码来源:ExternalJoin.java
示例4: AerospikeDB
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public AerospikeDB(String namespace) {
AerospikeDB.NAMESPACE = namespace;
writePolicy = new WritePolicy();
readPolicy = new Policy();
batchPolicy = new BatchPolicy();
client = new AerospikeClient(Constants.IP, Constants.PORT);
}
开发者ID:pawankumbhare4213,项目名称:TinyURL,代码行数:8,代码来源:AerospikeDB.java
示例5: handleLine
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
private void handleLine(String line) throws Exception {
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(line);
JsonObject obj = element.getAsJsonObject();
double latitude = obj.get("latitude").getAsDouble();
double longitude = obj.get("longitude").getAsDouble();
String busid = obj.get("business_id").getAsString();
JsonObject locobj = new JsonObject();
locobj.addProperty("type", "Point");
JsonArray coords = new JsonArray();
coords.add(longitude);
coords.add(latitude);
locobj.add("coordinates", coords);
Gson gson = new GsonBuilder().create();
String locstr = gson.toJson(locobj);
java.lang.reflect.Type mapType =
new TypeToken<Map<String, Object>>(){}.getType();
Gson gson2 = new Gson();
Map<String, Object> mapval = gson2.fromJson(line, mapType);
Key key = new Key(params.namespace, params.set, busid);
WritePolicy policy = new WritePolicy();
policy.timeout = 10 * 1000;
Bin locbin = Bin.asGeoJSON(params.locbin, locstr);
Bin valbin = new Bin(params.valbin, line);
Bin mapbin = new Bin(params.mapbin, mapval);
client.put(policy, key, locbin, valbin, mapbin);
if (++count % 1000 == 0) {
System.err.write('.');
System.err.flush();
}
}
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:39,代码来源:Load.java
示例6: setClient
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
/**
* Sets the AerospikeClient
*
* @param client An instance of AerospikeClient
*/
public void setClient(AerospikeClient client) {
this.client = client;
this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
this.queryPolicy = client.queryPolicyDefault;
refreshCluster();
registerUDF();
}
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:16,代码来源:QueryEngine.java
示例7: TimeSeries
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public TimeSeries(AerospikeClient client, WritePolicy policy, Key key, String binName) {
super();
this.client = client;
this.policy = policy;
this.key = key;
this.binName = binName;
config();
}
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:9,代码来源:TimeSeries.java
示例8: setDelete
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public void setDelete(WritePolicy policy, Key key) {
begin();
int fieldCount = estimateKeySize(key);
sizeBuffer();
writeHeader(policy, 0, Command.INFO2_WRITE | Command.INFO2_DELETE, fieldCount, 0);
writeKey(key);
end();
}
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:9,代码来源:Command.java
示例9: setTouch
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public final void setTouch(WritePolicy policy, Key key) {
begin();
int fieldCount = estimateKeySize(key);
estimateOperationSize();
sizeBuffer();
writeHeader(policy, 0, Command.INFO2_WRITE, fieldCount, 1);
writeKey(key);
writeOperation(Operation.Type.TOUCH);
end();
}
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:11,代码来源:Command.java
示例10: AsyncWrite
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public AsyncWrite(AsyncCluster cluster, WritePolicy policy, WriteListener listener, Key key, Bin[] bins, Operation.Type operation) {
super(cluster, key);
this.policy = (policy == null)? new WritePolicy() : policy;
this.listener = listener;
this.bins = bins;
this.operation = operation;
}
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:8,代码来源:AsyncWrite.java
示例11: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(Object key,
AerospikeRecord record,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
Key k = new Key(namespace, setName, key.toString());
List<Bin> bins = new ArrayList<>();
for (Map.Entry<String, Object> bin : record.bins.entrySet()) {
Bin aerospikeBin = new Bin(bin.getKey(), bin.getValue());
bins.add(aerospikeBin);
}
client.put(writePolicy, k, bins.toArray(new Bin[bins.size()]));
}
开发者ID:Stratio,项目名称:deep-spark,代码行数:16,代码来源:AerospikeDeepOutputFormat.java
示例12: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(Text sessid,
Session session,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
Key kk = new Key(namespace, setName, sessid.toString());
Bin bin0 = new Bin("userid", session.userid);
Bin bin1 = new Bin("start", session.start);
Bin bin2 = new Bin("end", session.end);
Bin bin3 = new Bin("nhits", session.nhits);
client.put(writePolicy, kk, bin0, bin1, bin2, bin3);
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:15,代码来源:SessionRollup.java
示例13: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(Text key,
IntWritable value,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
Key kk = new Key(namespace, setName, key.toString());
Bin bin1 = new Bin("word", key.toString());
Bin bin2 = new Bin("count", value.get());
client.put(writePolicy, kk, bin1, bin2);
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:13,代码来源:WordCountOutput.java
示例14: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(LongWritable userid,
Profile profile,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
writePolicy.timeout = 10000;
Key kk = new Key(namespace, setName, userid.get());
Bin bin0 = new Bin("userid", profile.userid);
Bin bin1 = new Bin("age", profile.age);
Bin bin2 = new Bin("isMale", profile.isMale);
client.put(writePolicy, kk, bin0, bin1, bin2);
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:15,代码来源:GenerateProfiles.java
示例15: writeAerospike
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public void writeAerospike(String sessid,
Session session,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
Key kk = new Key(namespace, setName, sessid.toString());
Bin bin0 = new Bin("userid", session.userid);
Bin bin1 = new Bin("start", session.start);
Bin bin2 = new Bin("end", session.end);
Bin bin3 = new Bin("nhits", session.nhits);
client.put(writePolicy, kk, bin0, bin1, bin2, bin3);
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:15,代码来源:SparkSessionRollup.java
示例16: run
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public static void run(String[] args) throws Exception {
int argi = 0;
String asspec = args[argi++];
String dataType = args[argi++];
log.info(String.format("saw %s %s", asspec, dataType));
String[] inparam = asspec.split(":");
host = inparam[0];
port = Integer.parseInt(inparam[1]);
namespace = inparam[2];
setName = inparam[3];
binName = inparam[4];
ClientPolicy policy = new ClientPolicy();
policy.user = "";
policy.password = "";
policy.failIfNotConnected = true;
client = new AerospikeClient(policy, host, port);
writePolicy = new WritePolicy();
if (dataType.equals("text-file"))
runTextFile(args, argi);
else if (dataType.equals("seq-int"))
runSeqInt(args, argi);
else
throw new RuntimeException(String.format("unknown dataType \"%s\"",
dataType));
}
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:33,代码来源:SampleData.java
示例17: DbParameters
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
protected DbParameters(String host, int port,
String namespace, String baseNamespace, String cacheNamespace) {
this.host = host;
this.port = port;
this.namespace = namespace;
this.baseNamespace = baseNamespace;
this.cacheNamespace = cacheNamespace;
this.writePolicy = new WritePolicy();
this.writePolicy.timeout = 1000;
this.writePolicy.maxRetries = 0;
this.policy = new Policy();
}
开发者ID:aerospike,项目名称:url-tracker,代码行数:13,代码来源:DbParameters.java
示例18: makeWritePolicy
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
private WritePolicy makeWritePolicy() {
writePolicy = new WritePolicy();
writePolicy.recordExistsAction = RecordExistsAction.REPLACE;
return writePolicy;
}
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:6,代码来源:AerospikeDrones.java
示例19: getDefaultWritePolicy
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
@Override
public WritePolicy getDefaultWritePolicy() {
return aerospikeClient.writePolicyDefault;
}
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:5,代码来源:ClientImpl.java
示例20: getWritePolicy
import com.aerospike.client.policy.WritePolicy; //导入依赖的package包/类
public WritePolicy getWritePolicy() {
return writePolicy;
}
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:4,代码来源:EntityStructure.java
注:本文中的com.aerospike.client.policy.WritePolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论