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


Java Mutator类代码示例

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


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

示例1: recordLicenses

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
protected void recordLicenses( String projectVersionMetadataKey, List<License> licenses )
{

    if ( licenses == null || licenses.isEmpty() )
    {
        return;
    }
    Mutator<String> licenseMutator = this.licenseTemplate.createMutator();

    for ( License license : licenses )
    {
        // we don't care about the key as the real used one with the projectVersionMetadata
        String keyLicense = UUID.randomUUID().toString();
        String cfLicense = cassandraArchivaManager.getLicenseFamilyName();

        addInsertion( licenseMutator, keyLicense, cfLicense, "projectVersionMetadataModel.key",
                      projectVersionMetadataKey );

        addInsertion( licenseMutator, keyLicense, cfLicense, NAME.toString(), license.getName() );

        addInsertion( licenseMutator, keyLicense, cfLicense, URL.toString(), license.getUrl() );

    }
    licenseMutator.execute();
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:26,代码来源:CassandraMetadataRepository.java

示例2: 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

示例3: 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

示例4: doAddRole

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
/**
 * Adds a role to the role store.
 */
@Override
public void doAddRole(String roleName, String[] userList, boolean shared) throws UserStoreException {

    Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
    Composite composite = new Composite();
    composite.addComponent(roleName, stringSerializer);
    composite.addComponent(tenantIdString, stringSerializer);

    mutator.addInsertion(composite, CFConstants.UM_ROLES,
            HFactory.createColumn(CFConstants.UM_ROLE_NAME, roleName, stringSerializer, stringSerializer));
    mutator.addInsertion(composite, CFConstants.UM_ROLES,
            HFactory.createColumn(CFConstants.UM_TENANT_ID, tenantIdString, stringSerializer, stringSerializer));

    if (userList != null && userList.length > 0) {
        addRoleToUsersList(userList, roleName, mutator);
    }

    mutator.execute();
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:23,代码来源:CassandraUserStoreManager.java

示例5: addUserToRoleList

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
/**
 * Maps the users to a role list. Adds the (username, tenantId) -> roleList
 * and (role, tenantId) -> userName
 *
 * @param userName The username of the user the roles need to be added to.
 * @param roleList The list of roles that needs to be mapped against the user.
 */
private void addUserToRoleList(String userName, String[] roleList) {

    Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());

    if (roleList != null) {
        for (String role : roleList) {
            Composite key = new Composite();
            key.addComponent(userName, stringSerializer);
            key.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(role, role));

            Composite keyRole = new Composite();
            keyRole.addComponent(role, stringSerializer);
            keyRole.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));

        }
        mutator.execute();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:CassandraUserStoreManager.java

示例6: addRoleToUsersList

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
/**
 * Maps the role to a user list. Adds the (username, tenantId) -> roleList
 * and (role, tenantId) -> userName
 *
 * @param userNames The username list of the user the role need to be added to.
 * @param roleName  The role that needs to be mapped against the user list.
 * @param mutator   Passes the mutator and returns it with the insert statements.
 */
private Mutator<Composite> addRoleToUsersList(String[] userNames, String roleName, Mutator<Composite> mutator) {
    if (userNames != null) {
        for (String userName : userNames) {

            Composite key = new Composite();
            key.addComponent(userName, stringSerializer);
            key.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(roleName, roleName));

            Composite keyRole = new Composite();
            keyRole.addComponent(roleName, stringSerializer);
            keyRole.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));

        }

    }
    return mutator;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:CassandraUserStoreManager.java

示例7: doBatchPut

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doBatchPut(PairList<byte[], byte[]> keysValues)
		throws StorageException {
	try {
		Mutator<byte[]> mutator = template.createMutator();
		for (int i = 0; i < keysValues.size(); ++i) {
			HColumn<String, byte[]> column = HFactory.createColumn(
					CassandraStorageSystem.COLUMN_NAME,
					keysValues.getSecond(i));
			mutator.addInsertion(keysValues.getFirst(i),
					CassandraStorageSystem.COLUMN_FAMILY_NAME, column);

			if ((i + 1) % MAX_BATCH_ROWS == 0) {
				mutator.execute();
			}
		}
		mutator.execute();
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:23,代码来源:CassandraStore.java

示例8: 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

示例9: updateColumnNameBasedSecondaryIndices

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
private void updateColumnNameBasedSecondaryIndices(K key, List<String> secondaryIndexByColumnNameChanges, Map<String, Integer> ttls) {

		final Mutator<String> secondaryIndexMutator = HFactory.createMutator(keysp, StringSerializer.get());
		String secondaryIndexCF = secondaryIndexedColumnFamilyTemplate.getColumnFamily();

		boolean ttlsDefined = MapUtils.isNotEmpty(ttls);

		for (String secondaryIndexByColumnName : secondaryIndexByColumnNameChanges) {
			int ttl = -1;
			if (ttlsDefined && ttls.get(secondaryIndexByColumnName) != null) {
				ttl = ttls.get(secondaryIndexByColumnName);
			}
			HColumn<K, K> hColumn;
			if (ttl > 0) {
				hColumn = HFactory.createColumn(key, key, keysp.createClock(), ttl, keySerializer, keySerializer);
			} else {
				hColumn = HFactory.createColumn(key, key, keysp.createClock(), keySerializer, keySerializer);
			}
			secondaryIndexMutator.addInsertion(getSecondaryIndexKey(secondaryIndexByColumnName, ""), secondaryIndexCF, hColumn);
		}
		MutationResult execute = secondaryIndexMutator.execute();
		log.debug(secondaryIndexByColumnNameChanges.size() + " secondary Indexes got updated for the key " + key.toString() +
				". Exec Time = " + execute.getExecutionTimeMicro() + ", Host used = " + execute.getHostUsed());

	}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:26,代码来源:HectorBasedHecubaClientManager.java

示例10: 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

示例11: 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

示例12: testGetRangeSlices

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
private void testGetRangeSlices() {

        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);

        RangeSlicesQuery<String, String, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(keyspace,
                stringSerializer, stringSerializer, stringSerializer);
        rangeSlicesQuery.setColumnFamily(COLUMN_FAMILY_NAME_1);
        rangeSlicesQuery.setKeys("fake_key_", "");
        rangeSlicesQuery.setColumnNames("birthdate");
        rangeSlicesQuery.setReturnKeysOnly();

        QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();
        OrderedRows<String, String, String> orderedRows = result.get();

        Row<String, String, String> lastRow = orderedRows.peekLast();

        System.out.println("Contents of rows: \n");
        for (Row<String, String, String> r : orderedRows) {
            System.out.println("   " + r);
        }

    }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:23,代码来源:HectorCassandraTest.java

示例13: deleteColumns

import me.prettyprint.hector.api.mutation.Mutator; //导入依赖的package包/类
/**
 * Remove subcolumns in a super column as a batch operation.
 *
 * @param rowKey          the row key
 * @param superColumnName the super column name
 * @param subcolumnNames  the names of the subcolumns
 * @param txnContext      BatchContext for batch operation
 */
@Override
public void deleteColumns(K rowKey,
                                SN superColumnName,
                                Iterable<N> subcolumnNames,
                                @Nonnull BatchContext txnContext) {
    Validate.notNull(txnContext);
    Mutator<K> mutator = validateAndGetMutator(txnContext);

    for (N subcolumn : subcolumnNames) {
        mutator.addSubDelete(rowKey,
                             getColumnFamily(),
                             superColumnName,
                             subcolumn,
                             getSuperColumnNameSerializer(),
                             getSubcolumnNameSerializer());
    }
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:27,代码来源:SuperColumnFamilyTemplate.java

示例14: 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

示例15: 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


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