Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.Row


        commands.add(readCommand);
        List<Row> rows;
        try
        {
            rows = StorageProxy.read(commands, rConsistecy);
            Row row = rows.get(0);
            ColumnFamily cf = row.cf;

            int bytes = 0;
            StringBuffer response = new StringBuffer();
            if (cf != null)
View Full Code Here


       
        List<String> list = new ArrayList<String>();
        list.add("SuperColumn-0");
        list.add("SuperColumn-189");
        list.add("SuperColumn-23");
        Row row = table.getRow("0", "MailboxMailData0", list);
        try
        {
            ColumnFamily cf = row.getColumnFamily("MailboxMailData0");
            Collection<IColumn> columns = cf.getAllColumns();           
            for ( IColumn column : columns )
            {               
                System.out.println(column.name());               
                Collection<IColumn> subColumns = column.getSubColumns();
View Full Code Here

        else
        {
            columnFamily_column = cfMetaData_.cfName;
        }

        Row row = null;
        try
        {
            String key = (String)(rowKey_.get());
            ReadCommand readCommand = new ReadCommand(cfMetaData_.tableName, key, columnFamily_column, offset_, limit_);
            row = StorageProxy.readProtocol(readCommand, StorageService.ConsistencyLevel.WEAK);
        }
        catch (Exception e)
        {
            logger_.error(LogUtil.throwableToString(e));
            throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg());
        }

        List<Map<String, String>> rows = new LinkedList<Map<String, String>>();
        if (row != null)
        {
            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
            if (cfMap != null && cfMap.size() > 0)
            {
                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
                if (cfamily != null)
                {
View Full Code Here

        limit_          = limit;
    }

    public List<Map<String,String>> getRows()
    {
        Row row = null;
        try
        {
            String key = (String)(rowKey_.get());
            ReadCommand readCommand = new ReadCommand(cfMetaData_.tableName, key, cfMetaData_.cfName, offset_, limit_);
            row = StorageProxy.readProtocol(readCommand, StorageService.ConsistencyLevel.WEAK);
        }
        catch (Exception e)
        {
            logger_.error(LogUtil.throwableToString(e));
            throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg());
        }

        List<Map<String, String>> rows = new LinkedList<Map<String, String>>();
        if (row != null)
        {
            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
            if (cfMap != null && cfMap.size() > 0)
            {
                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
                if (cfamily != null)
                {
View Full Code Here

        else
        {
            columnFamily_column = cfMetaData_.cfName + ":" + columnKey;
        }

        Row row = null;
        try
        {
            String key = (String)(rowKey_.get());
            ReadCommand readCommand = new ReadCommand(cfMetaData_.tableName, key, columnFamily_column, -1, Integer.MAX_VALUE);
            row = StorageProxy.readProtocol(readCommand, StorageService.ConsistencyLevel.WEAK);
        }
        catch (Exception e)
        {
            logger_.error(LogUtil.throwableToString(e));
            throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg());
        }

        if (row != null)
        {
            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
            if (cfMap != null && cfMap.size() > 0)
            {
                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
                if (cfamily != null)
                {
View Full Code Here

          new Object[] {readCommand});
      IAsyncResult iar = MessagingService.getMessagingInstance().sendRR(
          message, to_);
      Object[] result = iar.get();
      ReadResponse readResponse = (ReadResponse) result[0];
      Row row = readResponse.row();
      if (row == null) {
        logger_.debug("ERROR No row for this key .....: " + line);
                Thread.sleep(1000/requestsPerSecond_, 1000%requestsPerSecond_);
        errorCount_++;
      } else {
        Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
        if (cfMap == null || cfMap.size() == 0) {
          logger_
              .debug("ERROR ColumnFamil map is missing.....: "
                  + threadId + "   key:" + key
                  + "    record:" + line);
View Full Code Here

        if (!table.getColumnFamilies().contains(values[0]))
        {
            throw new CassandraException("Column Family " + values[0] + " is invalid.");
        }

        Row row = StorageProxy.readProtocol(command, StorageService.ConsistencyLevel.WEAK);
        if (row == null)
        {
            return null;
        }
        return row.getColumnFamily(values[0]);
  }
View Full Code Here

   *
   */
  public Row resolve(List<Message> responses) throws DigestMismatchException, IOException
    {
        long startTime = System.currentTimeMillis();
    Row retRow = null;
    List<Row> rowList = new ArrayList<Row>();
    List<InetAddress> endPoints = new ArrayList<InetAddress>();
    String key = null;
    String table = null;
    byte[] digest = new byte[0];
    boolean isDigestQuery = false;
       
        /*
     * Populate the list of rows from each of the messages
     * Check to see if there is a digest query. If a digest
         * query exists then we need to compare the digest with
         * the digest of the data that is received.
        */
        DataInputBuffer bufIn = new DataInputBuffer();
    for (Message response : responses)
    {                     
            byte[] body = response.getMessageBody();
            bufIn.reset(body, body.length);
            ReadResponse result = ReadResponse.serializer().deserialize(bufIn);
            if (result.isDigestQuery())
            {
                digest = result.digest();
                isDigestQuery = true;
            }
            else
            {
                rowList.add(result.row());
                endPoints.add(response.getFrom());
                key = result.row().key();
                table = result.row().getTable();
            }
        }
    // If there was a digest query compare it with all the data digests
    // If there is a mismatch then throw an exception so that read repair can happen.
        if (isDigestQuery)
        {
            for (Row row : rowList)
            {
                if (!Arrays.equals(row.digest(), digest))
                {
                    /* Wrap the key as the context in this exception */
                    String s = String.format("Mismatch for key %s (%s vs %s)", row.key(), FBUtilities.bytesToHex(row.digest()), FBUtilities.bytesToHex(digest));
                    throw new DigestMismatchException(s);
                }
            }
        }

        /* If the rowList is empty then we had some exception above. */
        if (rowList.size() == 0)
        {
            return retRow;
        }

        /* Now calculate the resolved row */
        retRow = new Row(table, key);
        for (int i = 0; i < rowList.size(); i++)
        {
            retRow.repair(rowList.get(i));
        }

        // At  this point  we have the return row .
        // Now we need to calculate the difference
        // so that we can schedule read repairs
        for (int i = 0; i < rowList.size(); i++)
        {
            // since retRow is the resolved row it can be used as the super set
            Row diffRow = rowList.get(i).diff(retRow);
            if (diffRow == null) // no repair needs to happen
                continue;
            // create the row mutation message based on the diff and schedule a read repair
            RowMutation rowMutation = new RowMutation(table, key);
            for (ColumnFamily cf : diffRow.getColumnFamilies())
            {
                rowMutation.add(cf);
            }
            RowMutationMessage rowMutationMessage = new RowMutationMessage(rowMutation);
            ReadRepairManager.instance().schedule(endPoints.get(i), rowMutationMessage);
View Full Code Here

           
            key = key.trim();
            if ( StorageService.instance().isPrimary(key) )
            {
                System.out.println("Processing key " + key);
                Row row = Table.open("Mailbox").getRow(key, "MailboxMailList0");
                if ( row.isEmpty() )
                {
                    System.out.println("MISSING KEY : " + key);
                    raf.write(key.getBytes());
                    raf.write(System.getProperty("line.separator").getBytes());
                }
View Full Code Here

            if (rows != null && !rows.isEmpty())
            {
                assert rows.size() == 1;

                Row row = rows.get(0);

                if (row.cf != null && !row.cf.isMarkedForDelete())
                {

                    assert row.cf.getSortedColumns() != null;
View Full Code Here

TOP

Related Classes of org.apache.cassandra.db.Row

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.