• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataOutputBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cassandra.io.util.DataOutputBuffer的典型用法代码示例。如果您正苦于以下问题:Java DataOutputBuffer类的具体用法?Java DataOutputBuffer怎么用?Java DataOutputBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataOutputBuffer类属于org.apache.cassandra.io.util包,在下文中一共展示了DataOutputBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: build

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
public ByteBuffer build()
{
    try (DataOutputBuffer out = new DataOutputBufferFixed(serializedSize))
    {
        if (isStatic)
            out.writeShort(STATIC_MARKER);

        for (int i = 0; i < components.size(); i++)
        {
            ByteBufferUtil.writeWithShortLength(components.get(i), out);
            out.write(endOfComponents[i]);
        }
        return ByteBuffer.wrap(out.getData(), 0, out.getLength());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:CompositeType.java


示例2: build

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
public ByteBuffer build()
{
    try
    {
        DataOutputBuffer out = new DataOutputBuffer(serializedSize);
        if (isStatic)
            out.writeShort(STATIC_MARKER);

        for (int i = 0; i < components.size(); i++)
        {
            ByteBufferUtil.writeWithShortLength(components.get(i), out);
            out.write(endOfComponents[i]);
        }
        return ByteBuffer.wrap(out.getData(), 0, out.getLength());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:CompositeType.java


示例3: 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


示例4: testSerialization

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:MerkleTreeTest.java


示例5: test

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void test() throws IOException
{
    InetAddress endpoint = InetAddress.getByName("127.0.0.1");
    int generation = 0;
    int maxVersion = 123;
    GossipDigest expected = new GossipDigest(endpoint, generation, maxVersion);
    //make sure we get the same values out
    assertEquals(endpoint, expected.getEndpoint());
    assertEquals(generation, expected.getGeneration());
    assertEquals(maxVersion, expected.getMaxVersion());

    //test the serialization and equals
    DataOutputBuffer output = new DataOutputBuffer();
    GossipDigest.serializer.serialize(expected, output, MessagingService.current_version);

    ByteArrayInputStream input = new ByteArrayInputStream(output.getData(), 0, output.getLength());
    GossipDigest actual = GossipDigest.serializer.deserialize(new DataInputStream(input), MessagingService.current_version);
    assertEquals(0, expected.compareTo(actual));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:GossipDigestTest.java


示例6: testSerialization

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
    Pair<List<DecoratedKey>, IndexSummary> random = generateRandomIndex(100, 1);
    DataOutputBuffer dos = new DataOutputBuffer();
    IndexSummary.serializer.serialize(random.right, dos, false);
    // write junk
    dos.writeUTF("JUNK");
    dos.writeUTF("JUNK");
    FileUtils.closeQuietly(dos);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
    IndexSummary is = IndexSummary.serializer.deserialize(dis, DatabaseDescriptor.getPartitioner(), false, 1, 1);
    for (int i = 0; i < 100; i++)
        assertEquals(i, is.binarySearch(random.left.get(i)));
    // read the junk
    assertEquals(dis.readUTF(), "JUNK");
    assertEquals(dis.readUTF(), "JUNK");
    is.close();
    FileUtils.closeQuietly(dis);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:IndexSummaryTest.java


示例7: testAddEmptyKey

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    try (IndexSummaryBuilder builder = new IndexSummaryBuilder(1, 1, BASE_SAMPLING_LEVEL))
    {
        builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
        IndexSummary summary = builder.build(p);
        assertEquals(1, summary.size());
        assertEquals(0, summary.getPosition(0));
        assertArrayEquals(new byte[0], summary.getKey(0));

        DataOutputBuffer dos = new DataOutputBuffer();
        IndexSummary.serializer.serialize(summary, dos, false);
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
        IndexSummary loaded = IndexSummary.serializer.deserialize(dis, p, false, 1, 1);

        assertEquals(1, loaded.size());
        assertEquals(summary.getPosition(0), loaded.getPosition(0));
        assertArrayEquals(summary.getKey(0), summary.getKey(0));
        summary.close();
        loaded.close();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:IndexSummaryTest.java


示例8: truncationAsMapEntry

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
private static String truncationAsMapEntry(ColumnFamilyStore cfs, long truncatedAt, ReplayPosition position)
{
    DataOutputBuffer out = new DataOutputBuffer();
    try
    {
        ReplayPosition.serializer.serialize(position, out);
        out.writeLong(truncatedAt);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    return String.format("{%s: 0x%s}",
                         cfs.metadata.cfId,
                         ByteBufferUtil.bytesToHex(ByteBuffer.wrap(out.getData(), 0, out.getLength())));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:17,代码来源:SystemKeyspace.java


示例9: updateDigest

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
public void updateDigest(MessageDigest digest)
{
    digest.update(name.duplicate());
    digest.update(value.duplicate());

    DataOutputBuffer buffer = new DataOutputBuffer();
    try
    {
        buffer.writeLong(timestamp);
        buffer.writeByte(serializationFlags());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    digest.update(buffer.getData(), 0, buffer.getLength());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:Column.java


示例10: build

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
public ByteBuffer build()
{
    DataOutputBuffer out = new DataOutputBuffer(serializedSize);
    for (int i = 0; i < components.size(); i++)
    {
        try
        {
            ByteBufferUtil.writeWithShortLength(components.get(i), out);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        out.write(endOfComponents[i]);
    }
    return ByteBuffer.wrap(out.getData(), 0, out.getLength());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:CompositeType.java


示例11: updateDigest

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Override
public void updateDigest(MessageDigest digest)
{
    digest.update(name.duplicate());
    // We don't take the deltas into account in a digest
    contextManager.updateDigest(digest, value);
    DataOutputBuffer buffer = new DataOutputBuffer();
    try
    {
        buffer.writeLong(timestamp);
        buffer.writeByte(serializationFlags());
        buffer.writeLong(timestampOfLastDelete);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    digest.update(buffer.getData(), 0, buffer.getLength());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:CounterColumn.java


示例12: 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


示例13: updateDigest

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Override
public void updateDigest(MessageDigest digest)
{
    digest.update(name.duplicate());

    DataOutputBuffer buffer = new DataOutputBuffer();
    try
    {
        buffer.writeLong(timestamp);
        buffer.writeByte(serializationFlags());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    digest.update(buffer.getData(), 0, buffer.getLength());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:DeletedColumn.java


示例14: write

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
private void write(Hint hint)
{
    ByteBuffer buffer = (ByteBuffer) slab.duplicate().position(offset).limit(offset + totalSize);
    CRC32 crc = new CRC32();
    int hintSize = totalSize - ENTRY_OVERHEAD_SIZE;
    try (DataOutputBuffer dop = new DataOutputBufferFixed(buffer))
    {
        dop.writeInt(hintSize);
        updateChecksumInt(crc, hintSize);
        dop.writeInt((int) crc.getValue());

        Hint.serializer.serialize(hint, dop, MessagingService.current_version);
        updateChecksum(crc, buffer, buffer.position() - hintSize, hintSize);
        dop.writeInt((int) crc.getValue());
    }
    catch (IOException e)
    {
        throw new AssertionError(); // cannot happen
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:HintsBuffer.java


示例15: serialize

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
public void serialize(RowCacheKey rowCacheKey, ByteBuffer buf)
{
    @SuppressWarnings("resource")
    DataOutputBuffer dataOutput = new DataOutputBufferFixed(buf);
    try
    {
        dataOutput.writeUTF(rowCacheKey.ksAndCFName.left);
        dataOutput.writeUTF(rowCacheKey.ksAndCFName.right);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
    buf.putInt(rowCacheKey.key.length);
    buf.put(rowCacheKey.key);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:OHCProvider.java


示例16: testSerializer

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerializer() throws IOException
{
    long now = FBUtilities.timestampMicros();
    Mutation mutation = createMutation("testSerializer", now);
    Hint hint = Hint.create(mutation, now / 1000);

    // serialize
    int serializedSize = (int) Hint.serializer.serializedSize(hint, MessagingService.current_version);
    DataOutputBuffer dob = new DataOutputBuffer();
    Hint.serializer.serialize(hint, dob, MessagingService.current_version);
    assertEquals(serializedSize, dob.getLength());

    // deserialize
    DataInputPlus di = new DataInputBuffer(dob.buffer(), true);
    Hint deserializedHint = Hint.serializer.deserialize(di, MessagingService.current_version);

    // compare before/after
    assertHintsEqual(hint, deserializedHint);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:HintTest.java


示例17: testSerialization

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    DataInputPlus in = new DataInputBuffer(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:MerkleTreeTest.java


示例18: test

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void test() throws IOException
{
    InetAddress endpoint = InetAddress.getByName("127.0.0.1");
    int generation = 0;
    int maxVersion = 123;
    GossipDigest expected = new GossipDigest(endpoint, generation, maxVersion);
    //make sure we get the same values out
    assertEquals(endpoint, expected.getEndpoint());
    assertEquals(generation, expected.getGeneration());
    assertEquals(maxVersion, expected.getMaxVersion());

    //test the serialization and equals
    DataOutputBuffer output = new DataOutputBuffer();
    GossipDigest.serializer.serialize(expected, output, MessagingService.current_version);

    DataInputPlus input = new DataInputBuffer(output.getData());
    GossipDigest actual = GossipDigest.serializer.deserialize(input, MessagingService.current_version);
    assertEquals(0, expected.compareTo(actual));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:GossipDigestTest.java


示例19: testSerialization

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
    Pair<List<DecoratedKey>, IndexSummary> random = generateRandomIndex(100, 1);
    DataOutputBuffer dos = new DataOutputBuffer();
    IndexSummary.serializer.serialize(random.right, dos, false);
    // write junk
    dos.writeUTF("JUNK");
    dos.writeUTF("JUNK");
    FileUtils.closeQuietly(dos);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
    IndexSummary is = IndexSummary.serializer.deserialize(dis, partitioner, false, 1, 1);
    for (int i = 0; i < 100; i++)
        assertEquals(i, is.binarySearch(random.left.get(i)));
    // read the junk
    assertEquals(dis.readUTF(), "JUNK");
    assertEquals(dis.readUTF(), "JUNK");
    is.close();
    FileUtils.closeQuietly(dis);
    random.right.close();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:IndexSummaryTest.java


示例20: testSerialization

import org.apache.cassandra.io.util.DataOutputBuffer; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
    Pair<List<DecoratedKey>, IndexSummary> random = generateRandomIndex(100, 1);
    DataOutputBuffer dos = new DataOutputBuffer();
    IndexSummary.serializer.serialize(random.right, dos, false);
    // write junk
    dos.writeUTF("JUNK");
    dos.writeUTF("JUNK");
    FileUtils.closeQuietly(dos);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
    IndexSummary is = IndexSummary.serializer.deserialize(dis, DatabaseDescriptor.getPartitioner(), false, 1, 1);
    for (int i = 0; i < 100; i++)
        assertEquals(i, is.binarySearch(random.left.get(i)));
    // read the junk
    assertEquals(dis.readUTF(), "JUNK");
    assertEquals(dis.readUTF(), "JUNK");
    FileUtils.closeQuietly(dis);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:20,代码来源:IndexSummaryTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlayerInventory类代码示例发布时间:2022-05-22
下一篇:
Java ListAppender类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap