本文整理汇总了Java中com.yahoo.ycsb.ByteArrayByteIterator类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayByteIterator类的具体用法?Java ByteArrayByteIterator怎么用?Java ByteArrayByteIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayByteIterator类属于com.yahoo.ycsb包,在下文中一共展示了ByteArrayByteIterator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public Map<String,ByteIterator> deserialize(ByteBuffer buf) {
Map<String,ByteIterator> map;
buf = buf.asReadOnlyBuffer();
if (debug) {
System.out.println("\n\ndeserialize **** "+ buf);
}
map = new HashMap<>();
while (buf.hasRemaining()) {
if (debug) {
System.out.println("\n"+ buf);
}
map.put(new String(readArray(buf)), new ByteArrayByteIterator(readArray(buf)));
}
return map;
}
示例2: unpackRowData
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
private HashMap<String, ByteIterator> unpackRowData(byte[] rowData, ByteBuffer buf, int nFields, Set<String> fields, HashMap<String, ByteIterator> result)
{
for (int i = 0; i < nFields; i++)
{
int len = buf.getInt();
int off = buf.position();
String key = new String(rowData, off, len, UTF8);
buf.position(off + len);
len = buf.getInt();
off = buf.position();
if (fields == null || fields.contains(key))
{
result.put(key, new ByteArrayByteIterator(rowData, off, len));
}
buf.position(off + len);
}
return result;
}
示例3: populateByteResult
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
protected void populateByteResult(final Map document, final Set<String> fields,
final HashMap<String, ByteIterator> result) {
// fill results
if (fields == null) {
for (Map.Entry<String, byte[]> entry: (Set<Map.Entry<String, byte[]>>) document.entrySet()) {
result.put(entry.getKey(), new ByteArrayByteIterator(entry.getValue()));
}
} else {
for (String field: fields) {
byte[] value = (byte[]) document.get(field);
if (value != null) {
result.put(field, new ByteArrayByteIterator(value));
}
}
}
}
示例4: scan
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public int scan(String table, String startkey, int limit, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
KeyRange range = KeyRange.closed(new Key(startkey)).open(Key.INF);
RangeResponse resp = client.rangeRequest(table, range, Limit.toItems(limit));
if (resp.code != ResponseCode.SUCCESS) {
return 2;
}
if (resp.results == null || resp.results.isEmpty()) {
return 1;
}
for (Entry<Key, byte[]> e : resp.results.entrySet()) {
String key = new String(e.getKey().getArray());
HashMap<String, ByteIterator> r = new HashMap<String, ByteIterator>();
r.put(key, new ByteArrayByteIterator(e.getValue()));
result.add(r);
}
return 0;
}
示例5: read
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Region<String, Map<String, byte[]>> r = getRegion(table);
Map<String, byte[]> val = r.get(key);
if (val != null) {
if (fields == null) {
for (String k : val.keySet()) {
result.put(key, new ByteArrayByteIterator(val.get(key)));
}
} else {
for (String field : fields) {
result.put(field, new ByteArrayByteIterator(val.get(field)));
}
}
return SUCCESS;
}
return ERROR;
}
示例6: read
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
Key kvKey = createKey(table, key);
SortedMap<Key, ValueVersion> kvResult;
try {
kvResult = store.multiGet(kvKey, null, null);
} catch (FaultException e) {
System.err.println(e);
return ERROR;
}
for (Map.Entry<Key, ValueVersion> entry : kvResult.entrySet()) {
/* If fields is null, read all fields */
String field = getFieldFromKey(entry.getKey());
if (fields != null && !fields.contains(field)) {
continue;
}
result.put(field, new ByteArrayByteIterator(entry.getValue().getValue().getValue()));
}
return OK;
}
示例7: read
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
Key k = new Key(key);
GetResponse resp = client.get(table, k);
if (resp.code != ResponseCode.SUCCESS) {
return 2;
}
if (resp.data == null) {
return 1;
}
result.put(key, new ByteArrayByteIterator(resp.data));
return 0;
}
示例8: fillMap
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
/**
* Fills the map with the ByteIterators from the document.
*
* @param result
* The map to fill.
* @param queryResult
* The document to fill from.
*/
protected final void fillMap(final HashMap<String, ByteIterator> result,
final Document queryResult) {
for (final Element be : queryResult) {
if (be instanceof BinaryElement) {
result.put(be.getName(), new ByteArrayByteIterator(
((BinaryElement) be).getValue()));
}
}
}
示例9: read
import com.yahoo.ycsb.ByteArrayByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
try {
ByteBuffer ret = client.get(key);
if(ret == null || ret.array() == null) {
if(fields != null)
result.put(fields.iterator().next(), new ByteArrayByteIterator("null".getBytes()));
else
result.put("value", new ByteArrayByteIterator("null".getBytes()));
return OK;
}
if(fields != null)
result.put(fields.iterator().next(), new ByteArrayByteIterator(ret.array()));
else
result.put("value", new ByteArrayByteIterator(ret.array()));
} catch (Exception e) {
logger.warn("Error on read:", e);
// e.printStackTrace();
return ERROR;
}
return OK;
}