Java Code Examples for org.apache.cassandra.utils.ByteBufferUtil#writeWithShortLength()

The following examples show how to use org.apache.cassandra.utils.ByteBufferUtil#writeWithShortLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositeType.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: SSTableWriter.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public void append(DecoratedKey key, RowIndexEntry indexEntry, long dataEnd)
{
    bf.add(key.getKey());
    long indexStart = indexFile.getFilePointer();
    try
    {
        ByteBufferUtil.writeWithShortLength(key.getKey(), indexFile.stream);
        metadata.comparator.rowIndexEntrySerializer().serialize(indexEntry, indexFile.stream);
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, indexFile.getPath());
    }
    long indexEnd = indexFile.getFilePointer();

    if (logger.isTraceEnabled())
        logger.trace("wrote index entry: " + indexEntry + " at " + indexStart);

    summary.maybeAddEntry(key, indexStart, indexEnd, dataEnd);
    builder.addPotentialBoundary(indexStart);
}
 
Example 3
Source File: OnDiskIndexBuilder.java    From sasi with Apache License 2.0 5 votes vote down vote up
public void serialize(DataOutput out) throws IOException
{
    if (termSize.isConstant())
        ByteBufferUtil.write(term, out);
    else
        ByteBufferUtil.writeWithShortLength(term, out);
}
 
Example 4
Source File: PrepareResponse.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public void serialize(PrepareResponse response, DataOutputPlus out, int version) throws IOException
{
    out.writeBoolean(response.promised);
    ByteBufferUtil.writeWithShortLength(response.inProgressCommit.key, out);
    UUIDSerializer.serializer.serialize(response.inProgressCommit.ballot, out, version);
    ColumnFamily.serializer.serialize(response.inProgressCommit.update, out, version);
    UUIDSerializer.serializer.serialize(response.mostRecentCommit.ballot, out, version);
    ColumnFamily.serializer.serialize(response.mostRecentCommit.update, out, version);
}
 
Example 5
Source File: PagingState.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 6
Source File: SliceFromReadCommand.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public void serialize(ReadCommand rm, DataOutputPlus out, int version) throws IOException
{
    SliceFromReadCommand realRM = (SliceFromReadCommand)rm;
    out.writeBoolean(realRM.isDigestQuery());
    out.writeUTF(realRM.ksName);
    ByteBufferUtil.writeWithShortLength(realRM.key, out);
    out.writeUTF(realRM.cfName);
    out.writeLong(realRM.timestamp);
    CFMetaData metadata = Schema.instance.getCFMetaData(realRM.ksName, realRM.cfName);
    metadata.comparator.sliceQueryFilterSerializer().serialize(realRM.filter, out, version);
}
 
Example 7
Source File: RowPosition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public void serialize(RowPosition pos, DataOutputPlus out) throws IOException
{
    Kind kind = pos.kind();
    out.writeByte(kind.ordinal());
    if (kind == Kind.ROW_KEY)
        ByteBufferUtil.writeWithShortLength(((DecoratedKey)pos).getKey(), out);
    else
        Token.serializer.serialize(pos.getToken(), out);
}
 
Example 8
Source File: IndexExpression.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Write the serialized version of this <code>IndexExpression</code> to the specified output.
 *
 * @param output the output to write to
 * @throws IOException if an I/O problem occurs while writing to the specified output
 */
public void writeTo(DataOutputPlus output) throws IOException
{
    ByteBufferUtil.writeWithShortLength(column, output);
    operator.writeTo(output);
    ByteBufferUtil.writeWithShortLength(value, output);
}
 
Example 9
Source File: ColumnIndex.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private void maybeWriteRowHeader() throws IOException
{
    if (lastColumn == null)
    {
        ByteBufferUtil.writeWithShortLength(key, output);
        DeletionTime.serializer.serialize(deletionInfo.getTopLevelDeletion(), output);
    }
}
 
Example 10
Source File: SliceByNamesReadCommand.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public void serialize(ReadCommand cmd, DataOutputPlus out, int version) throws IOException
{
    SliceByNamesReadCommand command = (SliceByNamesReadCommand) cmd;
    out.writeBoolean(command.isDigestQuery());
    out.writeUTF(command.ksName);
    ByteBufferUtil.writeWithShortLength(command.key, out);
    out.writeUTF(command.cfName);
    out.writeLong(cmd.timestamp);

    CFMetaData metadata = Schema.instance.getCFMetaData(cmd.ksName, cmd.cfName);
    metadata.comparator.namesQueryFilterSerializer().serialize(command.filter, out, version);
}
 
Example 11
Source File: Commit.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public void serialize(Commit commit, DataOutputPlus out, int version) throws IOException
{
    ByteBufferUtil.writeWithShortLength(commit.key, out);
    UUIDSerializer.serializer.serialize(commit.ballot, out, version);
    ColumnFamily.serializer.serialize(commit.update, out, version);
}
 
Example 12
Source File: AbstractCType.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public void serialize(Composite c, DataOutputPlus out) throws IOException
{
    ByteBufferUtil.writeWithShortLength(c.toByteBuffer(), out);
}
 
Example 13
Source File: Row.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public void serialize(Row row, DataOutputPlus out, int version) throws IOException
{
    ByteBufferUtil.writeWithShortLength(row.key.getKey(), out);
    ColumnFamily.serializer.serialize(row.cf, out, version);
}