本文整理汇总了Java中org.apache.cassandra.io.util.DataOutputBuffer.writeInt方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputBuffer.writeInt方法的具体用法?Java DataOutputBuffer.writeInt怎么用?Java DataOutputBuffer.writeInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.util.DataOutputBuffer
的用法示例。
在下文中一共展示了DataOutputBuffer.writeInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeMutations
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private static ByteBuffer serializeMutations(Collection<Mutation> mutations, int version)
{
DataOutputBuffer buf = new DataOutputBuffer();
try
{
buf.writeInt(mutations.size());
for (Mutation mutation : mutations)
Mutation.serializer.serialize(mutation, buf, version);
}
catch (IOException e)
{
throw new AssertionError(); // cannot happen.
}
return buf.asByteBuffer();
}
示例2: updateDigest
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
@Override
public void updateDigest(MessageDigest digest)
{
digest.update(name.duplicate());
digest.update(value.duplicate());
DataOutputBuffer buffer = new DataOutputBuffer();
try
{
buffer.writeLong(timestamp);
buffer.writeByte(serializationFlags());
buffer.writeInt(timeToLive);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
digest.update(buffer.getData(), 0, buffer.getLength());
}
示例3: updateDigest
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
@Override
public void updateDigest(MessageDigest digest)
{
digest.update(name.toByteBuffer().duplicate());
digest.update(value.duplicate());
DataOutputBuffer buffer = new DataOutputBuffer();
try
{
buffer.writeLong(timestamp);
buffer.writeByte(serializationFlags());
buffer.writeInt(timeToLive);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
digest.update(buffer.getData(), 0, buffer.getLength());
}
示例4: update
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
public void update(MessageDigest digest)
{
// no special-case for rows.size == 1, we're actually skipping some bytes here so just
// blindly updating everything wouldn't be correct
DataOutputBuffer out = new DataOutputBuffer();
try
{
ColumnFamily.serializer().serializeCFInfo(emptyColumnFamily, out);
out.writeInt(columnCount);
digest.update(out.getData(), 0, out.getLength());
}
catch (IOException e)
{
throw new IOError(e);
}
Iterator<IColumn> iter = iterator();
while (iter.hasNext())
{
iter.next().updateDigest(digest);
}
}
示例5: serialize
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
public ByteBuffer serialize()
{
try
{
DataOutputBuffer out = new DataOutputBuffer(serializedSize());
ByteBufferUtil.writeWithShortLength(partitionKey, out);
ByteBufferUtil.writeWithShortLength(cellName, out);
out.writeInt(remaining);
return out.asByteBuffer();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
示例6: serializeForSSTable
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
public static ByteBuffer serializeForSSTable(ColumnFamily cf)
{
try
{
DataOutputBuffer out = new DataOutputBuffer();
DeletionTime.serializer.serialize(cf.deletionInfo().getTopLevelDeletion(), out);
out.writeInt(cf.getColumnCount());
new ColumnIndex.Builder(cf, ByteBufferUtil.EMPTY_BYTE_BUFFER, out).build(cf);
return ByteBuffer.wrap(out.toByteArray());
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
示例7: getReply
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
public Message getReply(Message originalMessage) throws IOException
{
DataOutputBuffer dob = new DataOutputBuffer();
dob.writeInt(rows.size());
for (Row row : rows)
{
Row.serializer().serialize(row, dob, originalMessage.getVersion());
}
byte[] data = Arrays.copyOf(dob.getData(), dob.getLength());
return originalMessage.getReply(FBUtilities.getLocalAddress(), data, originalMessage.getVersion());
}
示例8: serializeOffsets
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
public static void serializeOffsets(DataOutputBuffer out, int[] indexOffsets, int columnIndexCount) throws IOException
{
for (int i = 0; i < columnIndexCount; i++)
out.writeInt(indexOffsets[i]);
}
示例9: testArtificialIndexOf
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
@Test
public void testArtificialIndexOf() throws IOException
{
CFMetaData cfMeta = CFMetaData.compile("CREATE TABLE pipe.dev_null (pk bigint, ck bigint, val text, PRIMARY KEY(pk, ck))", "foo");
DeletionTime deletionInfo = new DeletionTime(FBUtilities.timestampMicros(), FBUtilities.nowInSeconds());
SerializationHeader header = new SerializationHeader(true, cfMeta, cfMeta.partitionColumns(), EncodingStats.NO_STATS);
IndexHelper.IndexInfo.Serializer indexSerializer = new IndexHelper.IndexInfo.Serializer(cfMeta, BigFormat.latestVersion, header);
DataOutputBuffer dob = new DataOutputBuffer();
dob.writeUnsignedVInt(0);
DeletionTime.serializer.serialize(DeletionTime.LIVE, dob);
dob.writeUnsignedVInt(3);
int off0 = dob.getLength();
indexSerializer.serialize(new IndexHelper.IndexInfo(cn(0L), cn(5L), 0, 0, deletionInfo), dob);
int off1 = dob.getLength();
indexSerializer.serialize(new IndexHelper.IndexInfo(cn(10L), cn(15L), 0, 0, deletionInfo), dob);
int off2 = dob.getLength();
indexSerializer.serialize(new IndexHelper.IndexInfo(cn(20L), cn(25L), 0, 0, deletionInfo), dob);
dob.writeInt(off0);
dob.writeInt(off1);
dob.writeInt(off2);
@SuppressWarnings("resource") DataOutputBuffer dobRie = new DataOutputBuffer();
dobRie.writeUnsignedVInt(42L);
dobRie.writeUnsignedVInt(dob.getLength());
dobRie.write(dob.buffer());
ByteBuffer buf = dobRie.buffer();
RowIndexEntry<IndexHelper.IndexInfo> rie = new RowIndexEntry.Serializer(cfMeta, BigFormat.latestVersion, header).deserialize(new DataInputBuffer(buf, false));
Assert.assertEquals(42L, rie.position);
Assert.assertEquals(0, IndexHelper.indexFor(cn(-1L), rie.columnsIndex(), comp, false, -1));
Assert.assertEquals(0, IndexHelper.indexFor(cn(5L), rie.columnsIndex(), comp, false, -1));
Assert.assertEquals(1, IndexHelper.indexFor(cn(12L), rie.columnsIndex(), comp, false, -1));
Assert.assertEquals(2, IndexHelper.indexFor(cn(17L), rie.columnsIndex(), comp, false, -1));
Assert.assertEquals(3, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, false, -1));
Assert.assertEquals(3, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, false, 0));
Assert.assertEquals(3, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, false, 1));
Assert.assertEquals(3, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, false, 2));
Assert.assertEquals(3, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, false, 3));
Assert.assertEquals(-1, IndexHelper.indexFor(cn(-1L), rie.columnsIndex(), comp, true, -1));
Assert.assertEquals(0, IndexHelper.indexFor(cn(5L), rie.columnsIndex(), comp, true, 3));
Assert.assertEquals(0, IndexHelper.indexFor(cn(5L), rie.columnsIndex(), comp, true, 2));
Assert.assertEquals(1, IndexHelper.indexFor(cn(17L), rie.columnsIndex(), comp, true, 3));
Assert.assertEquals(2, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, true, 3));
Assert.assertEquals(2, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, true, 4));
Assert.assertEquals(1, IndexHelper.indexFor(cn(12L), rie.columnsIndex(), comp, true, 3));
Assert.assertEquals(1, IndexHelper.indexFor(cn(12L), rie.columnsIndex(), comp, true, 2));
Assert.assertEquals(1, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, true, 1));
Assert.assertEquals(2, IndexHelper.indexFor(cn(100L), rie.columnsIndex(), comp, true, 2));
}