本文整理汇总了Java中org.apache.cassandra.io.util.DataOutputBuffer.getData方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputBuffer.getData方法的具体用法?Java DataOutputBuffer.getData怎么用?Java DataOutputBuffer.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.util.DataOutputBuffer
的用法示例。
在下文中一共展示了DataOutputBuffer.getData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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.current_version);
DataInputPlus input = new DataInputBuffer(output.getData());
GossipDigest actual = GossipDigest.serializer.deserialize(input, MessagingService.current_version);
assertEquals(0, expected.compareTo(actual));
}
示例3: 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));
}
示例4: populateAndReserialize
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private void populateAndReserialize(IBitSet bs) throws IOException
{
for (long i = 0; i < bs.capacity(); i++)
if (random.nextBoolean())
bs.set(i);
DataOutputBuffer out = new DataOutputBuffer();
bs.serialize(out);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(out.getData()));
OffHeapBitSet newbs = OffHeapBitSet.deserialize(in);
compare(bs, newbs);
}
示例5: 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);
}
示例6: populateAndReserialize
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private static void populateAndReserialize(IBitSet bs) throws IOException
{
for (long i = 0; i < bs.capacity(); i++)
if (random.nextBoolean())
bs.set(i);
DataOutputBuffer out = new DataOutputBuffer();
bs.serialize(out);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(out.getData()));
try (OffHeapBitSet newbs = OffHeapBitSet.deserialize(in))
{
compare(bs, newbs);
}
}
示例7: serializeAndDeserializeReadMessage
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm) throws IOException
{
IVersionedSerializer<ReadCommand> rms = ReadCommand.serializer;
DataOutputBuffer out = new DataOutputBuffer();
rms.serialize(rm, out, MessagingService.current_version);
DataInputPlus dis = new DataInputBuffer(out.getData());
return rms.deserialize(dis, MessagingService.current_version);
}
示例8: populateAndReserialize
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
private void populateAndReserialize(IBitSet bs) throws IOException
{
for (long i = 0; i < bs.capacity(); i++)
if (random.nextBoolean())
bs.set(i);
DataOutputBuffer dos = new DataOutputBuffer();
bs.serialize(dos);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.getData()));
OffHeapBitSet newbs = OffHeapBitSet.deserialize(dis);
compare(bs, newbs);
}
示例9: 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);
}
示例10: 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_);
}
示例11: 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;
}
示例12: testSerialization
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
@Test
public void testSerialization() throws IOException
{
CFMetaData cfm = Keyspace.open(KEYSPACE).getColumnFamilyStore(CF_STANDARD).metadata;
long now = FBUtilities.timestampMicros();
int version = MessagingService.current_version;
UUID uuid = UUIDGen.getTimeUUID();
List<Mutation> mutations = new ArrayList<>(10);
for (int i = 0; i < 10; i++)
{
mutations.add(new RowUpdateBuilder(cfm, FBUtilities.timestampMicros(), bytes(i))
.clustering("name" + i)
.add("val", "val" + i)
.build());
}
Batch batch1 = Batch.createLocal(uuid, now, mutations);
assertEquals(uuid, batch1.id);
assertEquals(now, batch1.creationTime);
assertEquals(mutations, batch1.decodedMutations);
DataOutputBuffer out = new DataOutputBuffer();
Batch.serializer.serialize(batch1, out, version);
assertEquals(out.getLength(), Batch.serializer.serializedSize(batch1, version));
DataInputPlus dis = new DataInputBuffer(out.getData());
Batch batch2 = Batch.serializer.deserialize(dis, version);
assertEquals(batch1.id, batch2.id);
assertEquals(batch1.creationTime, batch2.creationTime);
assertEquals(batch1.decodedMutations.size(), batch2.encodedMutations.size());
Iterator<Mutation> it1 = batch1.decodedMutations.iterator();
Iterator<ByteBuffer> it2 = batch2.encodedMutations.iterator();
while (it1.hasNext())
{
try (DataInputBuffer in = new DataInputBuffer(it2.next().array()))
{
assertEquals(it1.next().toString(), Mutation.serializer.deserialize(in, version).toString());
}
}
}
示例13: testSerializationNonCurrentVersion
import org.apache.cassandra.io.util.DataOutputBuffer; //导入方法依赖的package包/类
/**
* This is just to test decodeMutations() when deserializing,
* since Batch will never be serialized at a version 2.2.
* @throws IOException
*/
@Test
public void testSerializationNonCurrentVersion() throws IOException
{
CFMetaData cfm = Keyspace.open(KEYSPACE).getColumnFamilyStore(CF_STANDARD).metadata;
long now = FBUtilities.timestampMicros();
int version = MessagingService.VERSION_22;
UUID uuid = UUIDGen.getTimeUUID();
List<Mutation> mutations = new ArrayList<>(10);
for (int i = 0; i < 10; i++)
{
mutations.add(new RowUpdateBuilder(cfm, FBUtilities.timestampMicros(), bytes(i))
.clustering("name" + i)
.add("val", "val" + i)
.build());
}
Batch batch1 = Batch.createLocal(uuid, now, mutations);
assertEquals(uuid, batch1.id);
assertEquals(now, batch1.creationTime);
assertEquals(mutations, batch1.decodedMutations);
DataOutputBuffer out = new DataOutputBuffer();
Batch.serializer.serialize(batch1, out, version);
assertEquals(out.getLength(), Batch.serializer.serializedSize(batch1, version));
DataInputPlus dis = new DataInputBuffer(out.getData());
Batch batch2 = Batch.serializer.deserialize(dis, version);
assertEquals(batch1.id, batch2.id);
assertEquals(batch1.creationTime, batch2.creationTime);
assertEquals(batch1.decodedMutations.size(), batch2.decodedMutations.size());
Iterator<Mutation> it1 = batch1.decodedMutations.iterator();
Iterator<Mutation> it2 = batch2.decodedMutations.iterator();
while (it1.hasNext())
assertEquals(it1.next().toString(), it2.next().toString());
}