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


Java DataOutputBuffer.getLength方法代码示例

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


在下文中一共展示了DataOutputBuffer.getLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例2: 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.version_);
    
    ByteArrayInputStream input = new ByteArrayInputStream(output.getData(), 0, output.getLength());
    GossipDigest actual = GossipDigest.serializer().deserialize(new DataInputStream(input), MessagingService.version_);
    assertEquals(0, expected.compareTo(actual));
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:21,代码来源:GossipDigestTest.java

示例3: serializeAndDeserializeReadMessage

import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm) throws IOException
{
    ReadCommandSerializer rms = ReadCommand.serializer;
    DataOutputBuffer out = new DataOutputBuffer();
    ByteArrayInputStream bis;

    rms.serialize(rm, out, MessagingService.current_version);
    bis = new ByteArrayInputStream(out.getData(), 0, out.getLength());
    return rms.deserialize(new DataInputStream(bis), MessagingService.current_version);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:ReadMessageTest.java

示例4: serializeAndDeserializeReadMessage

import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm) throws IOException
{
    ReadCommandSerializer rms = ReadCommand.serializer;
    DataOutputBuffer dos = new DataOutputBuffer();
    ByteArrayInputStream bis;

    rms.serialize(rm, dos, MessagingService.current_version);
    bis = new ByteArrayInputStream(dos.getData(), 0, dos.getLength());
    return rms.deserialize(new DataInputStream(bis), MessagingService.current_version);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:11,代码来源:ReadMessageTest.java

示例5: serializeAndDeserializeReadMessage

import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm) throws IOException
{
    ReadCommandSerializer rms = ReadCommand.serializer();
    DataOutputBuffer dos = new DataOutputBuffer();
    ByteArrayInputStream bis;

    rms.serialize(rm, dos, MessagingService.version_);
    bis = new ByteArrayInputStream(dos.getData(), 0, dos.getLength());
    return rms.deserialize(new DataInputStream(bis), MessagingService.version_);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:11,代码来源:ReadMessageTest.java

示例6: uncompress

import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private static String uncompress(ByteBuffer query, Compression compression) throws InvalidRequestException
{
    String queryString = null;

    // Decompress the query string.
    try
    {
        switch (compression)
        {
            case GZIP:
                DataOutputBuffer decompressed = new DataOutputBuffer();
                byte[] outBuffer = new byte[1024], inBuffer = new byte[1024];

                Inflater decompressor = new Inflater();

                int lenRead = 0;
                while (true)
                {
                    if (decompressor.needsInput())
                        lenRead = query.remaining() < 1024 ? query.remaining() : 1024;
                    query.get(inBuffer, 0, lenRead);
                    decompressor.setInput(inBuffer, 0, lenRead);

                    int lenWrite = 0;
                    while ((lenWrite = decompressor.inflate(outBuffer)) != 0)
                        decompressed.write(outBuffer, 0, lenWrite);

                    if (decompressor.finished())
                        break;
                }

                decompressor.end();

                queryString = new String(decompressed.getData(), 0, decompressed.getLength(), StandardCharsets.UTF_8);
                break;
            case NONE:
                try
                {
                    queryString = ByteBufferUtil.string(query);
                }
                catch (CharacterCodingException ex)
                {
                    throw new InvalidRequestException(ex.getMessage());
                }
                break;
        }
    }
    catch (DataFormatException e)
    {
        throw new InvalidRequestException("Error deflating query string.");
    }
    return queryString;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:54,代码来源:CassandraServer.java

示例7: 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.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。