Examples of MutationBatch


Examples of com.netflix.astyanax.MutationBatch

   * For saving batches of values grouped by row key
   * @param grouped
   * @throws ConnectionException
   */
  public void saveValues(Map<Ky, Collection<WideRowValue<Ky, Col, Val>>> grouped)throws ConnectionException {
    MutationBatch m = getKeyspace().prepareMutationBatch();
    for(Ky kee: grouped.keySet()) {
      Iterable<WideRowValue<Ky, Col, Val>> itb = grouped.get(kee);
      ColumnListMutation<Col> clm = m.withRow(getColumnFamily(), kee);
      Iterator<WideRowValue<Ky, Col, Val>> it = itb.iterator();
      while(it.hasNext()) {
        WideRowValue<Ky, Col, Val> value = it.next();
        putColumn(clm, value);
      }
    }
    m.execute();
  }
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

    clm.putColumn(value.getColumn(), value.getValue(), getValueSerializer(), null);
  }
 
 
  public void saveValuesWithUniqueKeys(Map<Ky, WideRowValue<Ky, Col, Val>> values)throws ConnectionException {
    MutationBatch m = getKeyspace().prepareMutationBatch();
    for(Ky kee: values.keySet()) {
      WideRowValue<Ky, Col, Val> value = values.get(kee);
      ColumnListMutation<Col> clm = m.withRow(getColumnFamily(), kee);
      putColumn(clm, value);
    }
    m.execute();
  }
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

   
    long ts1 = System.currentTimeMillis();     
    logger.debug("event=update column_family=" + columnFamily + " key=" + key + " column=" + column + " value=" + value);

    try {
      MutationBatch m =
          getKeyspace(keyspace).
          prepareMutationBatch();
      m.withRow((ColumnFamily)getColumnFamily(columnFamily), key).
        putColumn(getComposite(column), value, getSerializer(valueSerializer), ttl);
      m.execute();
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

   
    long ts1 = System.currentTimeMillis();     
    logger.debug("event=insert_row column_family=" + columnFamily + " key=" + rowKey);

    try {
      MutationBatch m = getKeyspace(keyspace).prepareMutationBatch();
      ColumnListMutation<N> clm = m.withRow((ColumnFamily<K, N>)getColumnFamily(columnFamily), rowKey);
      for (N columnName : columnValues.keySet()) {
        clm.putColumn((N)getComposite(columnName), columnValues.get(columnName), getSerializer(valueSerializer), ttl);
        CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
      }
      OperationResult<Void> result = m.execute();
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

    long ts1 = System.currentTimeMillis();     
    logger.debug("event=insert_rows column_family=" + columnFamily);

    try {
      MutationBatch m = getKeyspace(keyspace).prepareMutationBatch();
      for (K rowKey : rowColumnValues.keySet()) {
        ColumnListMutation<N> clm = m.withRow((ColumnFamily<K, N>)getColumnFamily(columnFamily), rowKey);
        for (N columnName : rowColumnValues.get(rowKey).keySet()) {
          clm.putColumn((N)getComposite(columnName), rowColumnValues.get(rowKey).get(columnName), getSerializer(valueSerializer), ttl);
          CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
        }
      }
      OperationResult<Void> result = m.execute();
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

    long ts1 = System.currentTimeMillis();     
    logger.debug("event=delete column_family=" + columnFamily + " key=" + key + " column=" + column);

    try {
      MutationBatch m = getKeyspace(keyspace).prepareMutationBatch();
      ColumnListMutation<N> clm = m.withRow((ColumnFamily<K, N>)getColumnFamily(columnFamily), key);
      if (column != null) {
        clm.deleteColumn((N)getComposite(column));
      } else {
        clm.delete();
      }
      OperationResult<Void> result = m.execute();
    } catch (NotFoundException ex){
      //ignore.
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

    long ts1 = System.currentTimeMillis();     
    logger.debug("event=delete_batch column_family=" + columnFamily);

    try {
      MutationBatch m = getKeyspace(keyspace).prepareMutationBatch();
      if (columnList == null || columnList.isEmpty()) {
        for (K k : keyList) {
          ColumnListMutation<N> clm = m.withRow((ColumnFamily<K, N>)getColumnFamily(columnFamily), k);
          clm.delete();
          CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
        }
      } else {
        // TODO: review this logic with jane
        for (int i=0; i< keyList.size();i++) {
          ColumnListMutation<N> clm = m.withRow((ColumnFamily<K, N>)getColumnFamily(columnFamily), keyList.get(i));
          clm.deleteColumn((N)getComposite(columnList.get(i)));
          CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
        }
      }
      OperationResult<Void> result = m.execute();
    } catch (NotFoundException ex){
      //ignore.
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

   * For saving batches of values grouped by row key
   * @param grouped
   * @throws ConnectionException
   */
  public void saveValues(Map<Ky, Collection<WideRowValue<Ky, Col, Val>>> grouped)throws ConnectionException {
    MutationBatch m = getKeyspace().prepareMutationBatch();
    for(Ky kee: grouped.keySet()) {
      Iterable<WideRowValue<Ky, Col, Val>> itb = grouped.get(kee);
      ColumnListMutation<Col> clm = m.withRow(getColumnFamily(), kee);
      Iterator<WideRowValue<Ky, Col, Val>> it = itb.iterator();
      while(it.hasNext()) {
        WideRowValue<Ky, Col, Val> value = it.next();
        putColumn(clm, value);
      }
    }
    m.execute();
  }
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

    clm.putColumn(value.getColumn(), value.getValue(), getValueSerializer(), null);
  }
 
 
  public void saveValuesWithUniqueKeys(Map<Ky, WideRowValue<Ky, Col, Val>> values)throws ConnectionException {
    MutationBatch m = getKeyspace().prepareMutationBatch();
    for(Ky kee: values.keySet()) {
      WideRowValue<Ky, Col, Val> value = values.get(kee);
      ColumnListMutation<Col> clm = m.withRow(getColumnFamily(), kee);
      putColumn(clm, value);
    }
    m.execute();
  }
View Full Code Here

Examples of com.netflix.astyanax.MutationBatch

            // 'B_Shard1':
            // 2:1 : null
            // 3:2 : null
            //

            MutationBatch m = keyspace.prepareMutationBatch();

            for (long row = 0; row < ROW_COUNT; row++) {
                long value = row * 100;
                m.withRow(CF_DATA, row).putColumn("A", "ABC", null)
                        .putColumn("B", "DEF", null);
                m.withRow(CF_INDEX, "B_" + (row % SHARD_COUNT)).putColumn(
                        new IndexEntry(value, row), row, null);
            }

            // System.out.println(m);
            m.execute();
        } catch (Exception e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.