当前位置: 首页>>代码示例>>Java>>正文


Java Mutator.addDeletion方法代码示例

本文整理汇总了Java中me.prettyprint.hector.api.mutation.Mutator.addDeletion方法的典型用法代码示例。如果您正苦于以下问题:Java Mutator.addDeletion方法的具体用法?Java Mutator.addDeletion怎么用?Java Mutator.addDeletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在me.prettyprint.hector.api.mutation.Mutator的用法示例。


在下文中一共展示了Mutator.addDeletion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void delete(final K... keys) {

	if (keys == null || keys.length == 0) {
		return;
	}

	final Mutator<K> m = createMutator(_keyspace, _serializer_k);

	for (final K key : keys) {
		m.addDeletion(key, _cf_name, COLUMN_NAME, BYTE_SERIALIZER);
	}

	m.execute();
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:17,代码来源:Cassandra12xMapDAO.java

示例2: flush

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * Flushes the buffer.
 * 
 * @param mutator The mutator to fill with deletions.
 * @param columnFamilyName The column family (name) to delete from.
 * @param column The column to delete from.
 * @param serializer The serializer to use for the column.
 * @param dao the rdf index data access object.
 * @param <T> The type of the column key.
 * @return True if the buffer was flushed and at least one element was checked for deletion, false otherwise.
 * @throws DataAccessLayerException in case of data access failure.
 */
<T> boolean flush(
		final Mutator<byte[]> mutator, 
		final String columnFamilyName, 
		final T column, 
		final Serializer<T> serializer,
		final TripleIndexDAO dao) throws DataAccessLayerException {
	if (_candidates.size() == 0) {
		return false;
	}
	
	for (SecondaryIndexDeletionCandidate candidate : _candidates) {
		if (!dao.query(candidate.getQuery(), 1).hasNext()) {
			mutator.addDeletion(candidate.getRow(), columnFamilyName, column, serializer);
		}
	}
	
	return true;
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:31,代码来源:SecondaryIndexDeletionBuffer.java

示例3: doBatchRemove

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doBatchRemove(List<byte[]> keys) throws StorageException {
	try {
		Mutator<byte[]> mutator = template.createMutator();
		int index = 0;
		for (byte[] key : keys) {
			mutator.addDeletion(key,
					CassandraStorageSystem.COLUMN_FAMILY_NAME);
			index += 1;
			if (index % MAX_BATCH_ROWS == 0) {
				mutator.execute();
			}
		}
		mutator.execute();
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:20,代码来源:CassandraStore.java

示例4: prepareMutatorForSecondaryIndexUpdate

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
private void prepareMutatorForSecondaryIndexUpdate(K key, Map<String, Object> allColumnsToBeChanged,
		Mutator<String> secondaryIndexMutator, String secondaryIndexCF,
		String columnName, String oldValue, Map<String, Integer> ttls) {
	if (!StringUtils.isBlank(oldValue) && !"null".equalsIgnoreCase(oldValue)) {
		// delete those indexes first
		secondaryIndexMutator.addDeletion(getSecondaryIndexKey(columnName, oldValue), secondaryIndexCF, key,
				keySerializer);
	}

	int ttl = -1;
	if (ttls != null && ttls.get(columnName) != null) {
		ttl = ttls.get(columnName);
	}

	// add the new ones
	if (ttl > 0) {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, allColumnsToBeChanged.get(columnName)
				.toString()), secondaryIndexCF, HFactory.createColumn(key, key, keysp.createClock(), ttl, keySerializer, keySerializer));
	} else {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, allColumnsToBeChanged.get(columnName)
				.toString()), secondaryIndexCF, HFactory.createColumn(key, key, keysp.createClock(), keySerializer, keySerializer));
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:24,代码来源:HectorBasedHecubaClientManager.java

示例5: deleteColumns

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@Override
public void deleteColumns(K rowKey, N... columnNames) {
    if (columnNames.length == 0) {
        return;
    }

    Mutator<K> mutator = createMutator();
    if (columnNames.length == 1) {
        mutator.delete(rowKey, getColumnFamily(), columnNames[0], getColumnNameSerializer());
    } else {
        for (N columnName : columnNames) {
            mutator.addDeletion(rowKey, getColumnFamily(), columnName, getColumnNameSerializer());
        }
        mutator.execute();
    }
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:18,代码来源:ColumnFamilyTemplate.java

示例6: addMessageToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static Mutator<ByteBuffer> addMessageToMutator( Mutator<ByteBuffer> m, Message message, long timestamp ) {

        Map<ByteBuffer, ByteBuffer> columns = serializeMessage( message );

        if ( columns == null ) {
            return m;
        }

        for ( Map.Entry<ByteBuffer, ByteBuffer> column_entry : columns.entrySet() ) {
            if ( ( column_entry.getValue() != null ) && column_entry.getValue().hasRemaining() ) {
                HColumn<ByteBuffer, ByteBuffer> column =
                        createColumn( column_entry.getKey(), column_entry.getValue(), timestamp, be, be );
                m.addInsertion( bytebuffer( message.getUuid() ), QueuesCF.MESSAGE_PROPERTIES.toString(), column );
            }
            else {
                m.addDeletion( bytebuffer( message.getUuid() ), QueuesCF.MESSAGE_PROPERTIES.toString(),
                        column_entry.getKey(), be, timestamp );
            }
        }

        return m;
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:23,代码来源:CassandraMQUtils.java

示例7: addQueueToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static Mutator<ByteBuffer> addQueueToMutator( Mutator<ByteBuffer> m, Queue queue, long timestamp ) {

        Map<ByteBuffer, ByteBuffer> columns = serializeQueue( queue );

        if ( columns == null ) {
            return m;
        }

        for ( Map.Entry<ByteBuffer, ByteBuffer> column_entry : columns.entrySet() ) {
            if ( ( column_entry.getValue() != null ) && column_entry.getValue().hasRemaining() ) {
                HColumn<ByteBuffer, ByteBuffer> column =
                        createColumn( column_entry.getKey(), column_entry.getValue(), timestamp, be, be );
                m.addInsertion( bytebuffer( queue.getUuid() ), QueuesCF.QUEUE_PROPERTIES.toString(), column );
            }
            else {
                m.addDeletion( bytebuffer( queue.getUuid() ), QueuesCF.QUEUE_PROPERTIES.toString(),
                        column_entry.getKey(), be, timestamp );
            }
        }

        return m;
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:23,代码来源:CassandraMQUtils.java

示例8: delete

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@Override
public <R, T> void delete(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, Map<R, Iterable<T>> values) {
    Serializer<R> rowKeySerializer = rowSerializer.getRowKeySerializer();

    Mutator<ByteBuffer> mutator = HFactory.createMutator(keyspace, ByteBufferSerializer.get());

    for (R rowKey : values.keySet()) {
        ByteBuffer serializedRowKey = rowKeySerializer.toByteBuffer(rowKey);
        if (serializedRowKey == null) {
            continue;
        }

        for (T topKey : values.get(rowKey)) {
            mutator.addDeletion(serializedRowKey, columnFamily, topKey, rowSerializer.getTopKeySerializer());
        }
    }

    executeDeletionMutator(columnFamily, dataOperationsProfile, mutator);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:20,代码来源:ThriftDataDriver.java

示例9: doDeleteUser

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * Deletes a user by userName.
 */
@Override
public void doDeleteUser(String userName) throws UserStoreException {

    Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
    String[] roles = doGetExternalRoleListOfUser(userName, "");
    for (String role : roles) {
        Composite key = new Composite();
        key.addComponent(role, stringSerializer);
        key.addComponent(tenantIdString, stringSerializer);
        ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
                keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(), StringSerializer.get());
        try {
            userCFTemplate.deleteColumn(key, userName);
        } catch (HectorException e) {
            log.error("Error during deletion ", e);
        }
    }

    Composite userKey = new Composite();
    userKey.addComponent(userName, stringSerializer);
    userKey.addComponent(tenantIdString, stringSerializer);
    mutator.addDeletion(userKey, CFConstants.UM_USER_ROLE, null, CompositeSerializer.get());
    mutator.addDeletion(userKey, CFConstants.UM_USER, null, CompositeSerializer.get());
    mutator.execute();

    if (log.isDebugEnabled()) {
        log.debug("Deleted user " + userName + " successfully");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:CassandraUserStoreManager.java

示例10: updateSecondaryIndexColumnFamily

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * This will update the secondary index column family properly, also deleting the previous values if needed.
 *
 * @param key            : key from the original column family. This will be the column name of the secondary
 *                       index column family.
 * @param columnName     : name of the column to be indexed.
 * @param columnValue    : value of the column to be indexed. This can be null if we are indexing based on the
 *                       column names only.
 * @param timestamp      : timestamp for the new entry in the secondary index.
 * @param ttl            : time to live for the new entry.
 * @param oldColumnValue : old column related to this update so that we can retrieve the old value of the column
 *                       to
 *                       delete the previous secondary index.
 */
private void updateSecondaryIndexColumnFamily(K key, String columnName, String columnValue, long timestamp, int ttl,
		String oldColumnValue) {
	final Mutator<String> secondaryIndexMutator = HFactory.createMutator(keysp, StringSerializer.get());
	String secondaryIndexCF = secondaryIndexedColumnFamilyTemplate.getColumnFamily();

	// enqueue a deletion to the secondary index to remove the previous value of this column.
	if (!StringUtils.isBlank(oldColumnValue) && !"null".equalsIgnoreCase(oldColumnValue)) {
		secondaryIndexMutator.addDeletion(getSecondaryIndexKey(columnName, oldColumnValue), secondaryIndexCF, key,
				keySerializer);
	}

	// add the new value to the secondary index CF. Make sure to handle the TTLs properly.
	if (ttl > 0) {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, columnValue), secondaryIndexCF,
				HFactory.createColumn(key, key,
						timestamp > 0 ? timestamp : keysp.createClock(),
								ttl, keySerializer, keySerializer));
	} else {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, columnValue), secondaryIndexCF,
				HFactory.createColumn(key, key,
						timestamp > 0 ? timestamp : keysp.createClock(),
								keySerializer, keySerializer));
	}


	// execute everything (the deletion and the insertion) together
	MutationResult execute = secondaryIndexMutator.execute();
	log.debug("Secondary Index column " + columnName + " got updated for the key " + key.toString() +
			". Exec Time = " +
			execute.getExecutionTimeMicro() + ", Host used = " + execute.getHostUsed());
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:46,代码来源:HectorBasedHecubaClientManager.java

示例11: removeRow

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * Remove the entire row in the default column family.
 * @param rowKey the row key
 * @param batchContext optional BatchContext
 */
public final void removeRow(K rowKey,
                            @Nullable BatchContext batchContext) {
    Mutator<K> mutator = validateAndGetMutator(batchContext);

    if (mutator == null) {
        createMutator().delete(rowKey, columnFamily, null, null);
    } else {
        mutator.addDeletion(rowKey, columnFamily);
    }
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:17,代码来源:AbstractColumnFamilyTemplate.java

示例12: batchUnsubscribeFromQueue

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public void batchUnsubscribeFromQueue( Mutator<ByteBuffer> batch, String publisherQueuePath, UUID publisherQueueId,
                                       String subscriberQueuePath, UUID subscriberQueueId, long timestamp ) {

    batch.addDeletion( bytebuffer( publisherQueueId ), QUEUE_SUBSCRIBERS.getColumnFamily(), subscriberQueuePath, se,
            timestamp );

    batch.addDeletion( bytebuffer( subscriberQueueId ), QUEUE_SUBSCRIPTIONS.getColumnFamily(), publisherQueuePath,
            se, timestamp );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:10,代码来源:QueueManagerImpl.java

示例13: deleteTransaction

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/** Delete the specified transaction */
private void deleteTransaction( UUID queueId, UUID consumerId, UUID transactionId )
{

    Mutator<ByteBuffer> mutator = CountingMutator.createFlushingMutator( ko, be );
    ByteBuffer key = getQueueClientTransactionKey( queueId, consumerId );

    mutator.addDeletion( key, CONSUMER_QUEUE_TIMEOUTS.getColumnFamily(), transactionId, ue,
            cass.createTimestamp() );

    mutator.execute();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:13,代码来源:ConsumerTransaction.java

示例14: deleteTransactionPointers

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * Delete all re-read transaction pointers
 *
 * @param pointers The list of transaction pointers
 * @param maxIndex The index to stop at (exclusive)
 * @param queueId The queue id
 * @param consumerId The consumer id
 */
protected void deleteTransactionPointers( List<TransactionPointer> pointers, int maxIndex, UUID queueId,
                                          UUID consumerId )
{

    if ( maxIndex == 0 || pointers.size() == 0 )
    {
        return;
    }

    Mutator<ByteBuffer> mutator = CountingMutator.createFlushingMutator( ko, be );
    ByteBuffer key = getQueueClientTransactionKey( queueId, consumerId );

    for ( int i = 0; i < maxIndex && i < pointers.size(); i++ )
    {
        UUID pointer = pointers.get( i ).expiration;

        if ( logger.isTraceEnabled() )
        {
            logger.trace( "Removing transaction pointer '{}' for queue '{}' and consumer '{}'",
                    pointer, queueId, consumerId
            );
        }

        mutator.addDeletion( key, CONSUMER_QUEUE_TIMEOUTS.getColumnFamily(), pointer, ue, cass.createTimestamp() );
    }

    mutator.execute();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:37,代码来源:ConsumerTransaction.java

示例15: addDeleteToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static void addDeleteToMutator( Mutator<ByteBuffer> m, Object columnFamily, Object key, Object columnName,
                                       long timestamp ) throws Exception {

    logBatchOperation( "Delete", columnFamily, key, columnName, null, timestamp );

    if ( columnName instanceof List<?> ) {
        columnName = DynamicComposite.toByteBuffer( ( List<?> ) columnName );
    }

    m.addDeletion( bytebuffer( key ), columnFamily.toString(), bytebuffer( columnName ), be, timestamp );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:12,代码来源:CassandraPersistenceUtils.java


注:本文中的me.prettyprint.hector.api.mutation.Mutator.addDeletion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。