本文整理了Java中com.aerospike.client.Bin
类的一些代码示例,展示了Bin
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bin
类的具体详情如下:
包路径:com.aerospike.client.Bin
类名称:Bin
[英]Column name/value pair.
[中]列名/值对。
代码示例来源:origin: brianfrankcooper/YCSB
private Status write(String table, String key, WritePolicy writePolicy,
Map<String, ByteIterator> values) {
Bin[] bins = new Bin[values.size()];
int index = 0;
for (Map.Entry<String, ByteIterator> entry: values.entrySet()) {
bins[index] = new Bin(entry.getKey(), entry.getValue().toArray());
++index;
}
Key keyObj = new Key(namespace, table, key);
try {
client.put(writePolicy, keyObj, bins);
return Status.OK;
} catch (AerospikeException e) {
System.err.println("Error while writing key " + key + ": " + e);
return Status.ERROR;
}
}
代码示例来源:origin: com.spikeify/core
if (value == null) {
if (!isReplace) {
bins.add(Bin.asNull(propName));
bins.add(new Bin(propName, (List) value));
nonNullField = true;
} else if (value instanceof Map<?, ?>) {
bins.add(new Bin(propName, (Map) value));
nonNullField = true;
} else {
bins.add(new Bin(propName, value));
nonNullField = true;
代码示例来源:origin: aerospike/aerospike-client-java
ptsb.append("] }");
Key key = new Key(params.namespace, params.set, keyPrefix + i);
Bin bin1 = Bin.asGeoJSON(binName1, ptsb.toString());
Bin bin2;
if (i % 7 == 0) {
bin2 = new Bin(binName2, "hospital");
bin2 = new Bin(binName2, "school");
bin2 = new Bin(binName2, "store");
代码示例来源:origin: aerospike/aerospike-client-java
private void writeRecords(
AerospikeClient client,
Parameters params,
String keyPrefix,
String binName,
int size
) throws Exception {
console.info("Write " + size + " records.");
for (int i = 0; i < size; i++) {
double lng = -122 + (0.1 * i);
double lat = 37.5 + (0.1 * i);
StringBuilder ptsb = new StringBuilder();
ptsb.append("{ \"type\": \"Point\", \"coordinates\": [");
ptsb.append(String.valueOf(lng));
ptsb.append(", ");
ptsb.append(String.valueOf(lat));
ptsb.append("] }");
Key key = new Key(params.namespace, params.set, keyPrefix + i);
Bin bin = Bin.asGeoJSON(binName, ptsb.toString());
client.put(params.writePolicy, key, bin);
}
}
代码示例来源:origin: com.spikeify/core
if (value == null) {
if (!forceReplace) {
bins.add(Bin.asNull(propName));
bins.add(new Bin(propName, (List) value));
nonNullField = true;
} else if (value instanceof Map<?, ?>) {
bins.add(new Bin(propName, (Map) value));
nonNullField = true;
} else {
bins.add(new Bin(propName, value));
nonNullField = true;
代码示例来源:origin: aerospike/aerospike-loader
private Bin createBinForString(String binName, String binRawValue) {
return new Bin(binName, binRawValue);
}
代码示例来源:origin: org.apache.gora/gora-aerospike
bin = new Bin(mappingBinName,
getSerializableValue(persistentValue, fields.get(i).schema()));
} else {
bin = Bin.asNull(mappingBinName);
代码示例来源:origin: apache/apex-malhar
@Override
public void storeCommittedWindowId(String appId, int operatorId, long windowId)
{
try {
String keyString = appId + String.valueOf(operatorId);
Key key = new Key(namespace,metaSet,keyString.hashCode());
Bin bin1 = new Bin(metaTableAppIdColumn,appId);
Bin bin2 = new Bin(metaTableOperatorIdColumn,operatorId);
Bin bin3 = new Bin(metaTableWindowColumn,windowId);
client.put(null, key, bin1,bin2,bin3);
} catch (AerospikeException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/gora
bin = new Bin(mappingBinName,
getSerializableValue(persistentValue, fields.get(i).schema()));
} else {
bin = Bin.asNull(mappingBinName);
代码示例来源:origin: aerospike/aerospike-loader
private Bin createBinForJson(String binName, String binRawValue) {
try {
log.debug(binRawValue);
if (jsonParser == null) {
jsonParser = new JSONParser();
}
Object obj = jsonParser.parse(binRawValue);
if (obj instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) obj;
return new Bin(binName, jsonArray);
} else {
JSONObject jsonObj = (JSONObject) obj;
return new Bin(binName, jsonObj);
}
} catch (ParseException e) {
log.error("Failed to parse JSON: " + e);
return null;
}
}
代码示例来源:origin: com.spikeify/core
if (value == null) {
if (!isReplace) {
bins.add(Bin.asNull(propName));
bins.add(new Bin(propName, (List) value));
nonNullField = true;
} else if (value instanceof Map<?, ?>) {
bins.add(new Bin(propName, (Map) value));
nonNullField = true;
} else {
bins.add(new Bin(propName, value));
nonNullField = true;
代码示例来源:origin: org.apache.apex/malhar-contrib
@Override
public void storeCommittedWindowId(String appId, int operatorId, long windowId) {
try {
String keyString = appId + String.valueOf(operatorId);
Key key = new Key(namespace,metaSet,keyString.hashCode());
Bin bin1 = new Bin(metaTableAppIdColumn,appId);
Bin bin2 = new Bin(metaTableOperatorIdColumn,operatorId);
Bin bin3 = new Bin(metaTableWindowColumn,windowId);
client.put(null, key, bin1,bin2,bin3);
}
catch (AerospikeException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.spikeify/core
if (value == null) {
if (!isReplace) {
bins.add(Bin.asNull(propName));
bins.add(new Bin(propName, (List) value));
nonNullField = true;
} else if (value instanceof Map<?, ?>) {
bins.add(new Bin(propName, (Map) value));
nonNullField = true;
} else {
bins.add(new Bin(propName, value));
nonNullField = true;
代码示例来源:origin: com.aerospike/aerospike-client
/**
* Create bin with a GeoJSON value.
*
* @param name bin name, current limit is 14 characters
* @param value bin value
*/
public static Bin asGeoJSON(String name, String value) {
return new Bin(name, Value.getAsGeoJSON(value));
}
代码示例来源:origin: aerospike/aerospike-client-java
String binName1 = params.getBinName("bin1");
String binName2 = params.getBinName("bin2");
Bin bin1 = new Bin(binName1, "value1");
Bin bin2 = new Bin(binName2, "value2");
client.put(params.writePolicy, key, bin1, bin2);
bin1 = Bin.asNull(binName1); // Set bin value to null to drop bin.
client.put(params.writePolicy, key, bin1);
代码示例来源:origin: aerospike/aerospike-client-java
/**
* Create bin with a null value. This is useful for bin deletions within a record.
* For servers configured as "single-bin", enter a null or empty name.
*
* @param name bin name, current limit is 14 characters
*/
public static Bin asNull(String name) {
return new Bin(name, Value.getAsNull());
}
代码示例来源:origin: com.aerospike/aerospike-client
/**
* Create bin with a null value. This is useful for bin deletions within a record.
* For servers configured as "single-bin", enter a null or empty name.
*
* @param name bin name, current limit is 14 characters
*/
public static Bin asNull(String name) {
return new Bin(name, Value.getAsNull());
}
代码示例来源:origin: com.aerospike/aerospike-client
/**
* Create bin with a blob value. The value will be java serialized.
* This method is faster than the bin Object constructor because the blob is converted
* directly instead of using multiple "instanceof" type checks with a blob default.
* <p>
* For servers configured as "single-bin", enter a null or empty name.
*
* @param name bin name, current limit is 14 characters
* @param value bin value
*/
public static Bin asBlob(String name, Object value) {
return new Bin(name, Value.getAsBlob(value));
}
代码示例来源:origin: aerospike/aerospike-loader
private Bin createBinForInteger(String binName, String binRawValue) {
try {
// Server stores all integer type data in 64bit so use long.
Long integer = Long.parseLong(binRawValue);
return new Bin(binName, integer);
} catch (Exception pi) {
log.error("File: " + Utils.getFileName(this.fileName) + " Line: " + lineNumber
+ " Integer/Long Parse Error: " + pi);
return null;
}
}
代码示例来源:origin: aerospike/aerospike-client-java
/**
* Create bin with a GeoJSON value.
*
* @param name bin name, current limit is 14 characters
* @param value bin value
*/
public static Bin asGeoJSON(String name, String value) {
return new Bin(name, Value.getAsGeoJSON(value));
}
内容来源于网络,如有侵权,请联系作者删除!