Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.Row


        List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily),
                Arrays.asList(keyCol), ConsistencyLevel.QUORUM);

        if (rows.size() == 1)
        {
            Row row = rows.get(0);

            if (row.cf != null)
            {
                IColumn col = row.cf.getColumn(keyCol);
View Full Code Here


        {
            byte[] body = (byte[])result[0];
            DataInputBuffer bufIn = new DataInputBuffer();
            bufIn.reset(body, body.length);
            ReadResponse response = ReadResponse.serializer().deserialize(bufIn);
            Row row = response.row();
            rows.put(row.key(), row);
        }       
        return rows;
    }
View Full Code Here

    public static Row readProtocol(ReadCommand command, StorageService.ConsistencyLevel consistencyLevel)
    throws IOException, ColumnFamilyNotDefinedException, TimeoutException
    {
        assert command.key != null;
        long startTime = System.currentTimeMillis();
        Row row = null;
        EndPoint[] endpoints = StorageService.instance().getNStorageEndPoint(command.key);

        if (consistencyLevel == StorageService.ConsistencyLevel.WEAK)
        {
            boolean foundLocal = Arrays.asList(endpoints).contains(StorageService.getLocalStorageEndPoint());
View Full Code Here

        // TODO: throw a thrift exception if we do not have N nodes

        ReadCommand readMessageDigestOnly = command.copy();
        readMessageDigestOnly.setDigestQuery(true);

        Row row = null;
        Message message = command.makeReadMessage();
        Message messageDigestOnly = readMessageDigestOnly.makeReadMessage();

        IResponseResolver<Row> readResponseResolver = new ReadResponseResolver();
        QuorumResponseHandler<Row> quorumResponseHandler = new QuorumResponseHandler<Row>(
View Full Code Here

     * @return a mapping of key --> Row
     * @throws Exception
     */
    public static Map<String, Row> weakReadProtocol(String tablename, String[] keys, String columnFamily, List<String> columns) throws Exception
    {
        Row row = null;
        long startTime = System.currentTimeMillis();
        Map<String, ReadCommand> readMessages = new HashMap<String, ReadCommand>();
        for ( String key : keys )
        {
            ReadCommand readCommand = new ReadCommand(tablename, key, columnFamily, columns);
View Full Code Here

        /* Remove the local storage endpoint from the list. */
        endpoints.remove(StorageService.getLocalStorageEndPoint());
        // TODO: throw a thrift exception if we do not have N nodes

        Table table = Table.open(DatabaseDescriptor.getTables().get(0));
        Row row = command.getRow(table);

        /*
           * Do the consistency checks in the background and return the
           * non NULL row.
           */
 
View Full Code Here

     * @return a mapping of key --> Row
     * @throws Exception
     */
    public static Map<String, Row> weakReadProtocol(String tablename, String[] keys, String columnFamily, int start, int count) throws Exception
    {
        Row row = null;
        long startTime = System.currentTimeMillis();
        Map<String, ReadCommand> readMessages = new HashMap<String, ReadCommand>();
        for ( String key : keys )
        {
            ReadCommand readCommand = new ReadCommand(tablename, key, columnFamily, start, count);
View Full Code Here

     * @return a mapping of key --> Row
     * @throws Exception
     */
    public static Map<String, Row> weakReadProtocol(String tablename, String[] keys, String columnFamily, long sinceTimestamp) throws Exception
    {
        Row row = null;
        long startTime = System.currentTimeMillis();
        Map<String, ReadCommand> readMessages = new HashMap<String, ReadCommand>();
        for ( String key : keys )
        {
            ReadCommand readCommand = new ReadCommand(tablename, key, columnFamily, sinceTimestamp);
View Full Code Here

   *
   */
  public Row resolve(List<Message> responses) throws DigestMismatchException
  {
        long startTime = System.currentTimeMillis();
    Row retRow = null;
    List<Row> rowList = new ArrayList<Row>();
    List<EndPoint> endPoints = new ArrayList<EndPoint>();
    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 = (byte[])response.getMessageBody()[0];           
            bufIn.reset(body, body.length);
            try
            {
                long start = System.currentTimeMillis();
                ReadResponse result = ReadResponse.serializer().deserialize(bufIn);
                logger_.debug( "Response deserialization time : " + (System.currentTimeMillis() - start) + " ms.");
          if(!result.isDigestQuery())
          {
            rowList.add(result.row());
            endPoints.add(response.getFrom());
            key = result.row().key();
            table = result.table();
          }
          else
          {
            digest = result.digest();
            isDigestQuery = true;
          }
            }
            catch( IOException ex )
            {
                logger_.info(LogUtil.throwableToString(ex));
            }
    }
    // 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 */
          throw new DigestMismatchException(row.key());
        }
      }
    }
   
        /* 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(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 differnce
    // so that we can schedule read repairs
   
    for (int i = 0 ; i < rowList.size(); i++)
    {
      // calculate the difference , since retRow is the resolved
      // row it can be used as the super set , remember no deletes
      // will happen with diff its only for additions so far
      // TODO : handle deletes
      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);                 
        Map<String, ColumnFamily> columnFamilies = diffRow.getColumnFamilyMap();
          Set<String> cfNames = columnFamilies.keySet();
         
          for ( String cfName : cfNames )
          {
              ColumnFamily cf = columnFamilies.get(cfName);
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

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.