本文整理汇总了Java中com.yahoo.ycsb.StringByteIterator类的典型用法代码示例。如果您正苦于以下问题:Java StringByteIterator类的具体用法?Java StringByteIterator怎么用?Java StringByteIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringByteIterator类属于com.yahoo.ycsb包,在下文中一共展示了StringByteIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readImpl
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
VersionNotFoundException, NetworkException {
@SuppressWarnings("unchecked")
final LWWStringMapRegisterCRDT register = txn.get(new CRDTIdentifier(table, key), false,
LWWStringMapRegisterCRDT.class, notificationsSubscriber);
final HashMap<String, String> value = register.getValue();
if (value == null) {
return ERROR_NOT_FOUND;
}
if (fields == null) {
StringByteIterator.putAllAsByteIterators(result, value);
} else {
for (final String field : fields) {
result.put(field, new StringByteIterator(value.get(field)));
}
}
return 0;
}
示例2: updateImpl
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
protected int updateImpl(TxnHandle txn, String table, String key, HashMap<String, ByteIterator> values)
throws WrongTypeException, NoSuchObjectException, VersionNotFoundException, NetworkException {
@SuppressWarnings("unchecked")
final LWWStringMapRegisterCRDT register = txn.get(new CRDTIdentifier(table, key), false,
LWWStringMapRegisterCRDT.class, notificationsSubscriber);
final HashMap<String, String> value = register.getValue();
if (value == null) {
return ERROR_NOT_FOUND;
}
final HashMap<String, String> mutableValue = new HashMap<String, String>(value);
StringByteIterator.putAllAsStrings(mutableValue, values);
register.set(mutableValue);
return 0;
}
示例3: readImpl
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
VersionNotFoundException, NetworkException {
@SuppressWarnings("unchecked")
final PutOnlyLWWStringMapCRDT map = txn.get(new CRDTIdentifier(table, key), false,
PutOnlyLWWStringMapCRDT.class, notificationsSubscriber);
if (fields == null) {
final HashMap<String, String> value = map.getValue();
StringByteIterator.putAllAsByteIterators(result, value);
} else {
for (final String field : fields) {
final String keyValue = map.get(field);
if (keyValue == null) {
return ERROR_NOT_FOUND;
}
result.put(field, new StringByteIterator(keyValue));
}
}
return 0;
}
示例4: readImpl
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
VersionNotFoundException, NetworkException {
final HashMap<CRDTIdentifier, String> ids = getFieldIds(txn, table, key, fields, false);
// Just trigger parallel reads.
txn.bulkGet(notificationsSubscriber != null, ids.keySet(), null);
// Then do separate reads, to trigger notifications too.
for (final Entry<CRDTIdentifier, String> entry : ids.entrySet()) {
@SuppressWarnings("unchecked")
final LWWStringRegisterCRDT register = txn.get(entry.getKey(), false, LWWStringRegisterCRDT.class,
notificationsSubscriber);
final String value = register.getValue();
if (value == null) {
return ERROR_NOT_FOUND;
}
result.put(entry.getValue(), new StringByteIterator(register.getValue()));
}
return 0;
}
示例5: insert
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes" })
public Status insert(final String table, final String key, final HashMap<String, ByteIterator> values) {
HashMap fields;
if (byteFormat) {
fields = convertContent(values);
} else {
fields = StringByteIterator.getStringMap(values);
}
try {
if (xRepo.getDocumentManagement().storeDocument(key, fields, insertProps) == null) {
logger.debug("insert; document was not created for some reason; key: {}", key);
return Status.UNEXPECTED_STATE;
}
return Status.OK;
} catch (Exception ex) {
logger.error("insert.error", ex);
return Status.ERROR;
}
}
示例6: update
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes" })
public Status update(final String table, final String key, final HashMap<String, ByteIterator> values) {
HashMap fields;
if (byteFormat) {
fields = convertContent(values);
} else {
fields = StringByteIterator.getStringMap(values);
}
try {
if (xRepo.getDocumentManagement().storeDocument(key, fields, updateProps) == null) {
logger.debug("update; document was not updated for some reason; key: {}", key);
return Status.UNEXPECTED_STATE;
}
return Status.OK;
} catch (Exception ex) {
logger.error("update.error", ex);
return Status.ERROR;
}
}
示例7: insert
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Status insert(final String table, final String key, final HashMap<String, ByteIterator> values) {
HashMap<String, Object> params = new HashMap<>();
params.put("uri", URI.create(key));
HashMap content = StringByteIterator.getStringMap(values);
content.put("key", key);
params.put("content", content);
params.put("props", insertProps);
try (ResultCursor cursor = xRepo.getQueryManagement().executeQuery(qStore, params, queryProps)) {
if (cursor.isEmpty()) {
logger.debug("insert; document was not created for some reason; key: {}", key);
return Status.UNEXPECTED_STATE;
} else {
return Status.OK;
}
} catch (Exception ex) {
logger.error("insert.error; key: {}", key, ex);
return Status.ERROR;
}
}
示例8: update
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Status update(final String table, final String key, final HashMap<String, ByteIterator> values) {
HashMap<String, Object> params = new HashMap<>();
params.put("uri", URI.create(key));
HashMap content = StringByteIterator.getStringMap(values);
content.put("key", key);
params.put("content", content);
params.put("props", updateProps);
try (ResultCursor cursor = xRepo.getQueryManagement().executeQuery(qStore, params, queryProps)) {
if (cursor.isEmpty()) {
logger.debug("update; document was not updated for some reason; key: {}", key);
return Status.UNEXPECTED_STATE;
} else {
return Status.OK;
}
} catch (Exception ex) {
logger.error("update.error; key: {}", key, ex);
return Status.ERROR;
}
}
示例9: populateStringResult
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected void populateStringResult(final Map<String, Object> document, final Set<String> fields,
final HashMap<String, ByteIterator> result) {
// fill results
if (fields == null) {
for (Map.Entry<String, Object> entry: document.entrySet()) {
result.put(entry.getKey(), new StringByteIterator(entry.getValue().toString()));
}
} else {
for (String field: fields) {
Object value = document.get(field);
if (value != null) {
result.put(field, new StringByteIterator(value.toString()));
}
}
}
}
示例10: read
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
try {
Map<String, String> row;
if (clustered) {
row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key, false);
} else {
Cache<String, Map<String, String>> cache = infinispanManager.getCache(table);
row = cache.get(key);
}
if (row != null) {
result.clear();
if (fields == null || fields.isEmpty()) {
StringByteIterator.putAllAsByteIterators(result, row);
} else {
for (String field : fields) result.put(field, new StringByteIterator(row.get(field)));
}
}
return OK;
} catch (Exception e) {
return ERROR;
}
}
示例11: scan
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public int scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
try {
//XXX what to pass in for nulls / zeros?
RecordListResponse res = c.scan(table, ScanOrder.Ascending, bufStr(startkey), true, null, false, recordcount, 0);
int ret = ycsbThriftRet(res.responseCode, ResponseCode.Success, ResponseCode.ScanEnded);
if(ret == 0) {
for(Record r : res.records) {
HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>();
// Note: r.getKey() and r.getValue() call special helper methods that trim the buffer
// to an appropriate length, and memcpy it to a byte[]. Trying to manipulate the ByteBuffer
// directly leads to trouble.
tuple.put("key", new StringByteIterator(new String(r.getKey())));
decode(fields, new String(r.getValue())/*strBuf(r.bufferForValue())*/, tuple);
result.add(tuple);
}
}
return ret;
} catch(TException e) {
e.printStackTrace();
return 2;
}
}
示例12: read
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
if ( checkStore(table) == ERROR ) {
return ERROR;
}
Versioned<HashMap<String, String>> versionedValue = storeClient.get(key);
if ( versionedValue == null )
return NOT_FOUND;
if ( fields != null ) {
for (String field : fields) {
String val = versionedValue.getValue().get(field);
if ( val != null )
result.put(field, new StringByteIterator(val));
}
} else {
StringByteIterator.putAllAsByteIterators(result, versionedValue.getValue());
}
return OK;
}
示例13: read
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
HashMap<String, String> r = dmap.get(key);
if(r == null){
return Status.NOT_FOUND;
}else{
if(fields != null){
for(Entry<String, ByteIterator> e : StringByteIterator.getByteIteratorMap(r).entrySet()){
if(fields.contains(e.getKey())){
result.put(e.getKey(),e.getValue());
}
}
}else{
result.putAll(StringByteIterator.getByteIteratorMap(r));
}
return Status.OK;
}
}
示例14: scan
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public Status scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Command cmd = new Command(cmd_id.incrementAndGet(),CommandType.GETRANGE,startkey,("").getBytes(),recordcount);
try {
Response r = client.send(cmd);
if(r != null){
List<Command> lc = r.getResponse(10000);
if(lc.isEmpty()){ return Status.ERROR; }
for(Command c : lc){
if(c.getType() == CommandType.RESPONSE){
HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>();
tuple.put("key", new StringByteIterator(c.getKey()));
if(c.getValue() != null && c.getValue().length > 0){
decode(fields, new String(c.getValue()), tuple);
result.add(tuple);
}
}
}
return Status.OK;
}
} catch (Exception e) {
e.printStackTrace();
}
return Status.ERROR;
}
示例15: insert
import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
/**
* Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified
* record key.
*
* @param table The name of the table
* @param key The record key of the record to insert.
* @param values A HashMap of field/value pairs to insert in the record
* @return Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.
*/
public int insert(String table, String key, HashMap<String, ByteIterator> values) {
try {
final ODocument document = new ODocument(CLASS);
for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet())
document.field(entry.getKey(), entry.getValue());
document.save();
dictionary.put(key, document);
return 0;
} catch (Exception e) {
e.printStackTrace();
}
return 1;
}