当前位置: 首页>>代码示例>>Java>>正文


Java DataOutputBuffer.writeInt方法代码示例

本文整理汇总了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();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:BatchlogManager.java

示例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());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:ExpiringColumn.java

示例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());
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:20,代码来源:ExpiringCell.java

示例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);
    }
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:24,代码来源:LazilyCompactedRow.java

示例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);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:PagingState.java

示例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);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:Util.java

示例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());
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:12,代码来源:RangeSliceReply.java

示例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]);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:6,代码来源:RowIndexEntry.java

示例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));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:57,代码来源:RowIndexEntryTest.java


注:本文中的org.apache.cassandra.io.util.DataOutputBuffer.writeInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。