Package org.apache.cassandra.io

Examples of org.apache.cassandra.io.DataInputBuffer


    }

    private ColumnFamily fetchColumnFamily(String key, String cf, IFilter filter, String ssTableFile) throws IOException
    {
        SSTable ssTable = new SSTable(ssTableFile, StorageService.getPartitioner());
        DataInputBuffer bufIn;
        bufIn = filter.next(key, cf, ssTable);
        if (bufIn.getLength() == 0)
        {
            return null;
        }
        ColumnFamily columnFamily = ColumnFamily.serializer().deserialize(bufIn, cf, filter);
        if (columnFamily == null)
View Full Code Here


        private static Logger logger_ = Logger.getLogger( BootstrapInitiateDoneVerbHandler.class );

        public void doVerb(Message message)
        {
            byte[] body = message.getMessageBody();
            DataInputBuffer bufIn = new DataInputBuffer();
            bufIn.reset(body, body.length);

            try
            {
                StreamContextManager.StreamStatusMessage streamStatusMessage = StreamContextManager.StreamStatusMessage.serializer().deserialize(bufIn);
                StreamContextManager.StreamStatus streamStatus = streamStatusMessage.getStreamStatus();
View Full Code Here

    private void doRecovery(Stack<File> filesNeeded, byte[] header) throws IOException
    {
        Table table = Table.open(table_);

        DataInputBuffer bufIn = new DataInputBuffer();
        DataOutputBuffer bufOut = new DataOutputBuffer();       

        while ( !filesNeeded.isEmpty() )
        {
            File file = filesNeeded.pop();
            // IFileReader reader = SequenceFile.bufferedReader(file.getAbsolutePath(), DatabaseDescriptor.getLogFileSizeThreshold());
            IFileReader reader = SequenceFile.reader(file.getAbsolutePath());
            try
            {
                reader.readDirect(header);
                /* deserialize the commit log header */
                bufIn.reset(header, 0, header.length);
                CommitLogHeader clHeader = CommitLogHeader.serializer().deserialize(bufIn);
                /* seek to the lowest position */
                int lowPos = CommitLogHeader.getLowestPosition(clHeader);
                /*
                 * If lowPos == 0 then we need to skip the processing of this
                 * file.
                */
                if (lowPos == 0)
                    break;
                else
                    reader.seek(lowPos);

                /* read the logs populate RowMutation and apply */
                while ( !reader.isEOF() )
                {
                    bufOut.reset();
                    long bytesRead = reader.next(bufOut);
                    if ( bytesRead == -1 )
                        break;

                    bufIn.reset(bufOut.getData(), bufOut.getLength());
                    /* Skip over the commit log key portion */
                    bufIn.readUTF();
                    /* Skip over data size */
                    bufIn.readInt();
                   
                    /* read the commit log entry */
                    try
                    {                       
                        Row row = Row.serializer().deserialize(bufIn);
View Full Code Here

        byte[] bytes = new byte[CommitLogHeader.size(Integer.parseInt(args[0]))];
        for ( File file : files )
        {
            CommitLog clog = new CommitLog( file );
            clog.readCommitLogHeader(file.getAbsolutePath(), bytes);
            DataInputBuffer bufIn = new DataInputBuffer();
            bufIn.reset(bytes, 0, bytes.length);
            CommitLogHeader clHeader = CommitLogHeader.serializer().deserialize(bufIn);
            /*
            StringBuilder sb = new StringBuilder("");
            for ( byte b : bytes )
            {
View Full Code Here

     * to be memory efficient the result is in
     * the third parameter.
    */
    static byte[] and(byte[] bytes, byte[] bytes2) throws IOException
    {
        DataInputBuffer bufIn = new DataInputBuffer();
        bufIn.reset(bytes, 0, bytes.length);
        CommitLogHeader clHeader = CommitLogHeader.serializer().deserialize(bufIn);
        byte[] clh = clHeader.getBitSet();
       
        bufIn.reset(bytes2, 0, bytes2.length);
        CommitLogHeader clHeader2 = CommitLogHeader.serializer().deserialize(bufIn);
        byte[] clh2 = clHeader2.getBitSet();
       
        byte[] result = new byte[clh.length];
        for ( int i = 0; i < clh.length; ++i )
View Full Code Here

        return buffer.getData();
    }
   
    public Message deserialize(byte[] bytes) throws IOException
    {
        DataInputBuffer bufIn = new DataInputBuffer();
        bufIn.reset(bytes, bytes.length);
        return Message.serializer().deserialize(bufIn);
    }
View Full Code Here

    public void doVerb(Message message)
    {
        try
        {
          byte[] body = message.getMessageBody();
            DataInputBuffer buffer = new DataInputBuffer();
            buffer.reset(body, body.length);
          RowMutationMessage rmMsg = RowMutationMessage.serializer().deserialize(buffer);

            EndPoint[] endpoints = StorageService.instance().getNStorageEndPoint(rmMsg.getRowMutation().key());

      Message messageInternal = new Message(StorageService.getLocalStorageEndPoint(),
View Full Code Here

        List<String> ssTables = table.getAllSSTablesOnDisk();
        /* the following call can happen if BF is wrong. Should return an empty buffer. */
        IFilter filter = new IdentityFilter();
        SSTable ssTable = new SSTable(ssTables.get(0), StorageService.getPartitioner());
        DataInputBuffer bufIn = filter.next("key2", "Standard1:Column1", ssTable);
        assertEquals(bufIn.getLength(), 0);
    }
View Full Code Here

    private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm)
    {
        ReadCommand rm2 = null;
        ReadCommandSerializer rms = ReadCommand.serializer();
        DataOutputBuffer dos = new DataOutputBuffer();
        DataInputBuffer dis = new DataInputBuffer();

        try
        {
            rms.serialize(rm, dos);
            dis.reset(dos.getData(), dos.getLength());
            rm2 = rms.deserialize(dis);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
View Full Code Here

        cf = new ColumnFamily("Standard1", "Standard");
        cf.addColumn("C", bytes, 1);
        DataOutputBuffer bufOut = new DataOutputBuffer();
        ColumnFamily.serializer().serialize(cf, bufOut);

        DataInputBuffer bufIn = new DataInputBuffer();
        bufIn.reset(bufOut.getData(), bufOut.getLength());
        cf = ColumnFamily.serializer().deserialize(bufIn);
        assert cf != null;
        assert cf.name().equals("Standard1");
        assert cf.getAllColumns().size() == 1;
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.io.DataInputBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.