use of com.yahoo.ycsb.ByteIterator in project voltdb by VoltDB.
the class VoltClient4 method packRowData.
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;
}
use of com.yahoo.ycsb.ByteIterator in project voltdb by VoltDB.
the class VoltClient4 method unpackRowData.
private HashMap<String, ByteIterator> unpackRowData(VoltTable data, Set<String> fields) {
byte[] rowData = data.getVarbinary(0);
ByteBuffer buf = ByteBuffer.wrap(rowData);
int nFields = buf.getInt();
int size = fields != null ? Math.min(fields.size(), nFields) : nFields;
HashMap<String, ByteIterator> res = new HashMap<String, ByteIterator>(size, (float) 1.25);
return unpackRowData(rowData, buf, nFields, fields, res);
}
Aggregations