Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.Row


    public static CFMetaData fromSchema(UntypedResultSet.Row result)
    {
        String ksName = result.getString("keyspace_name");
        String cfName = result.getString("columnfamily_name");

        Row serializedColumns = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNS_CF, ksName, cfName);
        CFMetaData cfm = fromSchemaNoTriggers(result, ColumnDefinition.resultify(serializedColumns));

        Row serializedTriggers = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_TRIGGERS_CF, ksName, cfName);
        addTriggerDefinitionsFromSchema(cfm, serializedTriggers);

        return cfm;
    }
View Full Code Here


        return m;
    }

    public void reload()
    {
        Row cfDefRow = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, ksName, cfName);

        if (cfDefRow.cf == null || !cfDefRow.cf.hasColumns())
            throw new RuntimeException(String.format("%s not found in the schema definitions keyspace.", ksName + ":" + cfName));

        try
View Full Code Here

    public static CFMetaData fromSchema(UntypedResultSet.Row result)
    {
        String ksName = result.getString("keyspace_name");
        String cfName = result.getString("columnfamily_name");

        Row serializedColumns = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNS_CF, ksName, cfName);
        CFMetaData cfm = fromSchemaNoTriggers(result, ColumnDefinition.resultify(serializedColumns));

        Row serializedTriggers = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_TRIGGERS_CF, ksName, cfName);
        addTriggerDefinitionsFromSchema(cfm, serializedTriggers);

        return cfm;
    }
View Full Code Here

            {
                ColumnFamily resolved = ReadResponseResolver.resolveSuperset(versions);
                ReadResponseResolver.maybeScheduleRepairs(resolved, table, key, versions, versionSources);
                versions.clear();
                versionSources.clear();
                return new Row(key, resolved);
            }
        };

        List<Row> resolvedRows = new ArrayList<Row>(n);
        while (iter.hasNext())
View Full Code Here

            {
                ColumnFamily resolved = ReadResponseResolver.resolveSuperset(versions);
                ReadResponseResolver.maybeScheduleRepairs(resolved, table, key, versions, versionSources);
                versions.clear();
                versionSources.clear();
                return new Row(key, resolved);
            }
        };

        List<Row> resolvedRows = new ArrayList<Row>(n);
        while (iter.hasNext())
View Full Code Here

            // resolved can be null even if versions doesn't have all nulls because of the call to removeDeleted in resolveSuperSet
            if (resolved != null)
                repairResults.addAll(RowRepairResolver.scheduleRepairs(resolved, table, key, versions, versionSources));
            versions.clear();
            versionSources.clear();
            return new Row(key, resolved);
        }
View Full Code Here

            {
                if (data == null)
                    return endOfData();

                assert key != null;
                return new Row(key, data);
            }

            protected Row computeNext()
            {
                /*
 
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 = response.getMessageBody();
            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++)
    {
      // 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

  protected ColumnFamily readColumnFamily(ReadCommand command) throws InvalidRequestException
    {
        String cfName = command.getColumnFamilyName();
        validateCommand(command.key, command.table, cfName);

        Row row;
        try
        {
            row = StorageProxy.readProtocol(command, StorageService.ConsistencyLevel.WEAK);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        catch (TimeoutException e)
        {
            throw new RuntimeException(e);
        }

        if (row == null)
        {
            return null;
        }
        return row.getColumnFamily(cfName);
  }
View Full Code Here

       
        private void onCompletion() throws IOException
        {
            try
            {
                Row row = responseResolver_.resolve(responses_);
                MultiQuorumResponseHandler.this.onCompleteResponse(row);
            }
            catch ( DigestMismatchException ex )
            {
                /*
 
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.