本文整理汇总了Java中com.yahoo.ycsb.ByteIterator类的典型用法代码示例。如果您正苦于以下问题:Java ByteIterator类的具体用法?Java ByteIterator怎么用?Java ByteIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteIterator类属于com.yahoo.ycsb包,在下文中一共展示了ByteIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> values) {
try {
ReadOp readOp;
boolean complete;
readOp = new ReadOp(table, key, fields, values);
readOps.put(readOp);
if (debug) {
System.out.println("waiting for: "+ key +"\t"+ readOp);
}
complete = readOp.waitForCompletion(TimeUnit.SECONDS, 5);
if (debug) {
System.out.println("back from wait: "+ key +" "+ complete +"\t"+ readOp);
}
return readOp.returnCode;
} catch (InterruptedException ie) {
throw new RuntimeException("Unsupported interruption");
}
}
示例2: handleResult
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
private void handleResult(ReadOp op, Map.Entry<String,Map> result) {
HashMap<String,ByteIterator> keyValues;
if (debug) {
System.out.println("handleResult: "+ op);
}
keyValues = (HashMap<String,ByteIterator>)result.getValue();
if (keyValues != null) {
for (Map.Entry<String,ByteIterator> fieldEntry : keyValues.entrySet()) {
op.values.put(fieldEntry.getKey(), fieldEntry.getValue());
}
op.setComplete(0);
} else {
op.setComplete(1);
}
}
示例3: estimateSerializedSize
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public int estimateSerializedSize(Map _map) {
int size;
Map<String,ByteIterator> map;
map = (Map<String,ByteIterator>)_map;
size = 0;
for (Map.Entry<String, ByteIterator> entry : map.entrySet()) {
size += entry.getKey().length() + entry.getValue().bytesLeft() + (2 * NumConversion.BYTES_PER_INT);
//byte[] array;
//array = entry.getValue().toArray();
//System.out.println(entry.getKey() +"\t"+ entry.getValue().bytesLeft());
//size += entry.getKey().length() + array.length + (2 * NumConversion.BYTES_PER_INT);
}
return size;
}
示例4: deserialize
import com.yahoo.ycsb.ByteIterator; //导入依赖的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;
}
示例5: deserialize
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public ByteIterator deserialize(ByteBuffer[] buffers) {
throw new RuntimeException("Not yet implemented");
/*
if (buffers.length != 0) {
byte[] bytes;
ByteBuffer buffer;
buffer = buffers[0];
bytes = buffer.array();
return new String(bytes, buffer.position(), buffer.remaining());
} else {
throw new RuntimeException("Deserialization error");
}
*/
}
示例6: read
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public int read(String keyspace, String key, Set<String> columns, HashMap<String, ByteIterator> result)
{
try
{
ClientResponse response = m_client.callProcedure("Get", keyspace.getBytes(UTF8), key);
if (response.getStatus() != ClientResponse.SUCCESS)
{
return 1;
}
VoltTable table = response.getResults()[0];
if (table.advanceRow())
{
unpackRowData(table, columns, result);
}
return 0;
}
catch (Exception e)
{
e.printStackTrace();
return 1;
}
}
示例7: packRowData
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
private byte[] packRowData(HashMap<String, ByteIterator> columns)
{
m_writeBuf.clear();
m_writeBuf.putInt(columns.size());
for (String key : columns.keySet())
{
byte[] k = key.getBytes(UTF8);
m_writeBuf.putInt(k.length);
m_writeBuf.put(k);
ByteIterator v = columns.get(key);
int len = (int) v.bytesLeft();
m_writeBuf.putInt(len);
v.nextBuf(m_workingData, m_writeBuf.position());
m_writeBuf.position(m_writeBuf.position() + len);
}
byte[] data = new byte[m_writeBuf.position()];
System.arraycopy(m_workingData, 0, data, 0, data.length);
return data;
}
示例8: unpackRowData
import com.yahoo.ycsb.ByteIterator; //导入依赖的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;
}
示例9: read
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
long startTimestamp = 0;
if (reportEveryOperation) {
startTimestamp = System.currentTimeMillis();
}
final int returnCode = readTxn(table, key, fields, result);
if (reportEveryOperation) {
if (returnCode == 0) {
final long durationMs = System.currentTimeMillis() - startTimestamp;
SafeLog.report(ReportType.APP_OP, sessionId, "read", durationMs);
reportStalenessOnRead(table, key, result, startTimestamp);
} else {
SafeLog.report(ReportType.APP_OP_FAILURE, sessionId, "read", errorCause(returnCode));
}
}
return returnCode;
}
示例10: update
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public int update(String table, String key, HashMap<String, ByteIterator> values) {
long startTimestamp = 0;
if (reportEveryOperation) {
startTimestamp = System.currentTimeMillis();
setTimestamp( startTimestamp, values);
reportStalenessOnWrite(table, key, values);
}
final int returnCode = updateTxn(table, key, values);
if (reportEveryOperation) {
if (returnCode == 0) {
final long durationMs = System.currentTimeMillis() - startTimestamp;
SafeLog.report(ReportType.APP_OP, sessionId, "update", durationMs);
} else {
SafeLog.report(ReportType.APP_OP_FAILURE, sessionId, "update", errorCause(returnCode));
}
}
return returnCode;
}
示例11: insert
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
@Override
public int insert(String table, String key, HashMap<String, ByteIterator> values) {
long startTimestamp = 0;
if (reportEveryOperation) {
startTimestamp = System.currentTimeMillis();
setTimestamp( startTimestamp, values);
reportStalenessOnWrite(table, key, values);
}
final int returnCode = insertTxn(table, key, values);
if (reportEveryOperation) {
if (returnCode == 0) {
final long durationMs = System.currentTimeMillis() - startTimestamp;
SafeLog.report(ReportType.APP_OP, sessionId, "insert", durationMs);
} else {
SafeLog.report(ReportType.APP_OP_FAILURE, sessionId, "insert", errorCause(returnCode));
}
}
return returnCode;
}
示例12: insertTxn
import com.yahoo.ycsb.ByteIterator; //导入依赖的package包/类
private int insertTxn(String table, String key, HashMap<String, ByteIterator> values) {
TxnHandle txn = null;
try {
// WISHME: blind updates would help here
txn = session.beginTxn(isolationLevel, cachePolicy, false);
int res = insertImpl(txn, table, key, values);
if (res == 0) {
txnCommit(txn);
}
return res;
} catch (SwiftException x) {
return handleException(x);
} finally {
cleanUpTxn(txn);
}
}
示例13: readImpl
import com.yahoo.ycsb.ByteIterator; //导入依赖的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;
}
示例14: updateImpl
import com.yahoo.ycsb.ByteIterator; //导入依赖的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;
}
示例15: readImpl
import com.yahoo.ycsb.ByteIterator; //导入依赖的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;
}