• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RangeSlicesQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: removeArtifact

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public void removeArtifact( final String repositoryId, final String namespace, final String project,
                            final String version, final MetadataFacet metadataFacet )
    throws MetadataRepositoryException
{

    RangeSlicesQuery<String, String, String> query = HFactory //
        .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
        .setColumnNames( NAMESPACE_ID.toString() ); //

    query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) //
        .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) //
        .addEqualsExpression( PROJECT.toString(), project ) //
        .addEqualsExpression( VERSION.toString(), version );

    QueryResult<OrderedRows<String, String, String>> result = query.execute();

    for ( Row<String, String, String> row : result.get() )
    {
        this.artifactMetadataTemplate.deleteRow( row.getKey() );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:24,代码来源:CassandraMetadataRepository.java


示例2: getArtifacts

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifacts( final String repositoryId )
    throws MetadataRepositoryException
{

    RangeSlicesQuery<String, String, String> query = HFactory //
        .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
        .setColumnNames( ArtifactMetadataModel.COLUMNS ); //

    query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId );

    QueryResult<OrderedRows<String, String, String>> result = query.execute();

    List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() );

    for ( Row<String, String, String> row : result.get() )
    {
        ColumnSlice<String, String> columnSlice = row.getColumnSlice();

        artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( columnSlice ) );

    }

    return artifactMetadatas;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:27,代码来源:CassandraMetadataRepository.java


示例3: doScan

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doScan(byte[] beginKey, byte[] endKey,
		IKeyValueCallback callback, boolean includeValue)
		throws StorageException {
	try {
		RangeSlicesQuery<byte[], String, byte[]> query = prepareRangeQuery(
				beginKey, endKey, includeValue);
		byte[] lastKey = null;
		while (true) {
			if (lastKey != null) {
				query.setKeys(lastKey, endKey);
			}

			OrderedRows<byte[], String, byte[]> rows = query.execute()
					.get();
			lastKey = reportScanData(rows, callback, endKey, includeValue);

			if (rows.getCount() < MAX_SCAN_ROWS) {
				break;
			}
		}
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:27,代码来源:CassandraStore.java


示例4: fillRangeSliceQuery

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
public <K, V> void fillRangeSliceQuery(RangeSlicesQuery<K, N, V> sliceQuery) {
    if (type == SliceDataSpecificatorType.COLUMNS) {
        if (columnsArray != null) {
            sliceQuery.setColumnNames(columnsArray);
        }  else {
            ((ThriftRangeSlicesQuery) sliceQuery).setColumnNames(columnsCollection);
        }
    } else if (type == SliceDataSpecificatorType.RANGE) {
        if (orderDesc) { // Cassandra's WTF requirement
            sliceQuery.setRange(highEnd, lowEnd, orderDesc, limit);
        } else {
            sliceQuery.setRange(lowEnd, highEnd, orderDesc, limit);
        }

    } else {
        throw new IllegalStateException("Invalid type: " + type);
    }
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:19,代码来源:SliceDataSpecificator.java


示例5: testGetRangeSlices

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的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


示例6: getArtifactsByDateRange

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByDateRange( final String repositoryId, final Date startTime,
                                                       final Date endTime )
    throws MetadataRepositoryException
{

    LongSerializer ls = LongSerializer.get();
    RangeSlicesQuery<String, String, Long> query = HFactory //
        .createRangeSlicesQuery( keyspace, ss, ss, ls ) //
        .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
        .setColumnNames( ArtifactMetadataModel.COLUMNS ); //

    if ( startTime != null )
    {
        query = query.addGteExpression( WHEN_GATHERED.toString(), startTime.getTime() );
    }
    if ( endTime != null )
    {
        query = query.addLteExpression( WHEN_GATHERED.toString(), endTime.getTime() );
    }
    QueryResult<OrderedRows<String, String, Long>> result = query.execute();

    List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() );

    for ( Row<String, String, Long> row : result.get() )
    {
        ColumnSlice<String, Long> columnSlice = row.getColumnSlice();
        String repositoryName = getAsStringValue( columnSlice, REPOSITORY_NAME.toString() );
        if ( StringUtils.equals( repositoryName, repositoryId ) )
        {

            artifactMetadatas.add( mapArtifactMetadataLongColumnSlice( columnSlice ) );
        }
    }

    return artifactMetadatas;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:38,代码来源:CassandraMetadataRepository.java


示例7: execute

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/**
 * Select a family column in the keyspace.
 * @param cassandraQuery a wrapper of the query
 * @param family the family name to be queried
 * @return a list of family rows
 */
public List<Row<K, ByteBuffer, ByteBuffer>> execute(CassandraQuery<K, T> cassandraQuery, String family) {
  
  String[] columnNames = cassandraQuery.getColumns(family);
  ByteBuffer[] columnNameByteBuffers = new ByteBuffer[columnNames.length];
  for (int i = 0; i < columnNames.length; i++) {
    columnNameByteBuffers[i] = StringSerializer.get().toByteBuffer(columnNames[i]);
  }
  Query<K, T> query = cassandraQuery.getQuery();
  int limit = (int) query.getLimit();
  if (limit < 1) {
    limit = Integer.MAX_VALUE;
  }
  K startKey = query.getStartKey();
  K endKey = query.getEndKey();
  
  RangeSlicesQuery<K, ByteBuffer, ByteBuffer> rangeSlicesQuery = HFactory.createRangeSlicesQuery
      (this.keyspace, this.keySerializer, ByteBufferSerializer.get(), ByteBufferSerializer.get());
  rangeSlicesQuery.setColumnFamily(family);
  rangeSlicesQuery.setKeys(startKey, endKey);
  rangeSlicesQuery.setRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, GoraRecordReader.BUFFER_LIMIT_READ_VALUE);
  rangeSlicesQuery.setRowCount(limit);
  rangeSlicesQuery.setColumnNames(columnNameByteBuffers);
  
  QueryResult<OrderedRows<K, ByteBuffer, ByteBuffer>> queryResult = rangeSlicesQuery.execute();
  OrderedRows<K, ByteBuffer, ByteBuffer> orderedRows = queryResult.get();
  
  return orderedRows.getList();
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:35,代码来源:CassandraClient.java


示例8: CAndPCSlicesQueryIterator

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/**
 * Creates a new iterator iterating over the results of the given query.
 * 
 * @param query The query.
 * @param limit The maximum amount of results to return.
 * @param cf The column family to query.
 * @param keyspace The keyspace to use.
 * @param dictionary the CumulusRDF dictionary.
 * @param isPC True, if this is a PC query, false, if this is a C query.
 */
CAndPCSlicesQueryIterator(
		final RangeSlicesQuery<byte[], Composite, byte[]> query,
		final int limit, 
		final String cf, 
		final Keyspace keyspace, 
		final ITopLevelDictionary dictionary,
		final boolean isPC) {
	_rows = new RangeSlicesIterator<byte[], Composite, byte[]>(query, new byte[0], new byte[0]);
	_limit = limit;
	_cf = cf;
	_keyspace = keyspace;
	_dictionary = dictionary;
	_isPC = isPC;
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:25,代码来源:CAndPCSlicesQueryIterator.java


示例9: getKey

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public K getKey(final V value) throws DataAccessLayerException { 
	RangeSlicesQuery<K, byte[], V> rq = HFactory.createRangeSlicesQuery(
			_keyspace, 
			_serializer_k, 
			BYTE_SERIALIZER, 
			_serializer_v);
	rq.addEqualsExpression(COLUMN_NAME, value).setReturnKeysOnly()
			.setColumnFamily(_cf_name)
			.setColumnNames(COLUMN_NAME).setRowCount(1);
	final List<Row<K, byte[], V>> rows = rq.execute().get().getList();

	return rows.isEmpty() ? null : _serializer_k.fromBytes((byte[])rows.get(0).getKey());
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:15,代码来源:Cassandra12xMapDAO.java


示例10: prepareRangeQuery

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/** Creates and initializes a range query. */
private RangeSlicesQuery<byte[], String, byte[]> prepareRangeQuery(
		byte[] beginKey, byte[] endKey, boolean includeValue) {
	RangeSlicesQuery<byte[], String, byte[]> query = HFactory
			.createRangeSlicesQuery(keyspace, BytesArraySerializer.get(),
					StringSerializer.get(), BytesArraySerializer.get());
	query.setColumnFamily(CassandraStorageSystem.COLUMN_FAMILY_NAME);
	query.setColumnNames(CassandraStorageSystem.COLUMN_NAME);
	if (!includeValue) {
		query.setReturnKeysOnly();
	}
	query.setRowCount(MAX_SCAN_ROWS);
	query.setKeys(beginKey, endKey);
	return query;
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:16,代码来源:CassandraStore.java


示例11: getCFData

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
public CassandraCFData getCFData(String columnFamily, String start, int limit) {
	int columnLimit = 100;
	CassandraCFData data = new CassandraCFData();
	String lastEnd = null;
	
	Map<String, Map<String, String>> cfData = new HashMap<String, Map<String, String>>();
	RangeSlicesQuery<String, String, String> query = HFactory.createRangeSlicesQuery(keyspace, STR, STR, STR);
	query.setColumnFamily(columnFamily);
	query.setKeys(start, "");
	query.setRange("", "", false, columnLimit);
	query.setRowCount(limit);
	OrderedRows<String, String, String> rows = query.execute().get();
	if (rows.getCount() != 1) {
		lastEnd = rows.peekLast().getKey();
		data.start = lastEnd;
	} else {
		data.start = null;
		return data;
	}
	
	for(Row<String,String,String> row  : rows.getList()){
		Map<String, String> columnMap = new HashMap<String, String>();
		ColumnSlice<String, String> columnData = row.getColumnSlice();
		for (HColumn<String, String> column : columnData.getColumns()){
			columnMap.put(column.getName(), column.getValue());
		}
		
		cfData.put(row.getKey(), columnMap);
	}
	
	data.rowColumnMap = cfData;
	return data;
}
 
开发者ID:eBay,项目名称:cassandra-river,代码行数:34,代码来源:CassandraDB.java


示例12: readRowsAsMap

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public Map<K,Map<N,V>> readRowsAsMap() {
    Map<K,Map<N,V>> resultMap = new HashMap<K,Map<N,V>>();
    RangeSlicesQuery<K, N, V> rangeSlicesQuery = HFactory.createRangeSlicesQuery(getKeyspace(),
                                                                                 getKeySerializer(),
                                                                                 getColumnNameSerializer(),
                                                                                 getValueSerializer());
    rangeSlicesQuery.setColumnFamily(getColumnFamily());
    rangeSlicesQuery.setRange(null, null, false, ALL);
    rangeSlicesQuery.setRowCount(ALL);
    QueryResult<OrderedRows<K, N, V>> result = rangeSlicesQuery.execute();
    for (Row<K,N,V> row : result.get()) {
        K key = row.getKey();
        ColumnSlice<N,V> slice = row.getColumnSlice();
        Map<N,V> columns = new HashMap<N,V>();
        for (HColumn<N,V> column : slice.getColumns()) {
            V value = column.getValue();
            columns.put(column.getName(), value);
        }
        resultMap.put(key, columns);
    }

    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed

    if (LOG.isDebugEnabled()) {
        LOG.debug("Returning result from multiGetColumnsAsMap: " + resultMap);
    }
    return resultMap;
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:30,代码来源:ColumnFamilyTemplate.java


示例13: getRowCount

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public <R, T> int getRowCount(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, R from, R to, Integer count) {

    RangeSlicesQuery<R, T, ByteBuffer> rangeSlicesQuery = HFactory.createRangeSlicesQuery(
            keyspace,
            rowSerializer.getRowKeySerializer(),
            rowSerializer.getTopKeySerializer(),
            ByteBufferSerializer.get());
    rangeSlicesQuery.setColumnFamily(columnFamily);

    rangeSlicesQuery.setKeys(from, to);
    rangeSlicesQuery.setRange(null, null, false, 1);
    rangeSlicesQuery.setRowCount(getBoundedRowCount(count));
    rangeSlicesQuery.setReturnKeysOnly();

    QueryResult<OrderedRows<R, T, ByteBuffer>> result;
    StopWatch monitor = monitoring.start(HerculesMonitoringGroup.HERCULES_DD, "Get row count " + columnFamily);

    try {
        result = rangeSlicesQuery.execute();
    } finally {
        long time = monitor.stop();
        if (dataOperationsProfile != null) {
            dataOperationsProfile.ms += time;
            dataOperationsProfile.dbQueries++;
        }
    }

    return result.get().getCount();
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:31,代码来源:ThriftDataDriver.java


示例14: getRangeSlice

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public <R, T> HerculesMultiQueryResult<R, T> getRangeSlice(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer,
                                                           R rowFrom, R rowTo, Integer rowCount, SliceDataSpecificator<T> sliceDataSpecificator) {

    RangeSlicesQuery<R, T, ByteBuffer> rangeSlicesQuery = HFactory.createRangeSlicesQuery(
            keyspace,
            rowSerializer.getRowKeySerializer(),
            rowSerializer.getTopKeySerializer(),
            ByteBufferSerializer.get());
    rangeSlicesQuery.setColumnFamily(columnFamily);
    rangeSlicesQuery.setRowCount(getBoundedRowCount(rowCount));
    rangeSlicesQuery.setKeys(rowFrom, rowTo);

    sliceDataSpecificator.fillRangeSliceQuery(rangeSlicesQuery);

    QueryResult<OrderedRows<R, T, ByteBuffer>> result;
    StopWatch monitor = monitoring.start(HerculesMonitoringGroup.HERCULES_DD, "Get range slice " + columnFamily);

    try {
        result = rangeSlicesQuery.execute();
    } finally {
        long time = monitor.stop();
        if (dataOperationsProfile != null) {
            dataOperationsProfile.ms += time;
            dataOperationsProfile.dbQueries++;
        }
    }

    return buildQueryResult(dataOperationsProfile, rowSerializer, result.get());
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:31,代码来源:ThriftDataDriver.java


示例15: getKeyRange

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public <R, T> List<R> getKeyRange(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer,
                                  R from, R to, Integer count) {
    RangeSlicesQuery<R, T, ByteBuffer> query = HFactory.createRangeSlicesQuery(keyspace,
            rowSerializer.getRowKeySerializer(),
            rowSerializer.getTopKeySerializer(),
            ByteBufferSerializer.get());

    query.setColumnFamily(columnFamily);
    query.setKeys(from, to);
    query.setRowCount(getBoundedRowCount(count));
    query.setReturnKeysOnly();

    QueryResult<OrderedRows<R, T, ByteBuffer>> result;
    StopWatch monitor = monitoring.start(HerculesMonitoringGroup.HERCULES_DD, "Get key range " + columnFamily);

    try {
        result = query.execute();
    } finally {
        long time = monitor.stop();
        if (dataOperationsProfile != null) {
            dataOperationsProfile.ms += time;
            dataOperationsProfile.dbQueries++;
        }
    }
    OrderedRows<R, T, ByteBuffer> rows = (result != null) ? result.get() : null;

    List<R> keys = new ArrayList<R>(rows == null ? 0 : rows.getCount());

    if (rows != null) {
        for (Row<R, T, ByteBuffer> row : rows) {
            keys.add(row.getKey());
        }
    }

    return keys;
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:38,代码来源:ThriftDataDriver.java


示例16: execute

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/**
 * Select a family column in the keyspace.
 * @param cassandraQuery a wrapper of the query
 * @param family the family name to be queried
 * @return a list of family rows
 */
public List<Row<K, ByteBuffer, ByteBuffer>> execute(CassandraQuery<K, T> cassandraQuery, String family) {
  
  String[] columnNames = cassandraQuery.getColumns(family);
  ByteBuffer[] columnNameByteBuffers = new ByteBuffer[columnNames.length];
  for (int i = 0; i < columnNames.length; i++) {
    columnNameByteBuffers[i] = StringSerializer.get().toByteBuffer(columnNames[i]);
  }
  Query<K, T> query = cassandraQuery.getQuery();
  int limit = (int) query.getLimit();
  if (limit < 1) {
    limit = Integer.MAX_VALUE;
  }
  K startKey = query.getStartKey();
  K endKey = query.getEndKey();
  
  RangeSlicesQuery<K, ByteBuffer, ByteBuffer> rangeSlicesQuery = HFactory.createRangeSlicesQuery(this.keyspace, this.keySerializer, ByteBufferSerializer.get(), ByteBufferSerializer.get());
  rangeSlicesQuery.setColumnFamily(family);
  rangeSlicesQuery.setKeys(startKey, endKey);
  rangeSlicesQuery.setRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, GoraRecordReader.BUFFER_LIMIT_READ_VALUE);
  rangeSlicesQuery.setRowCount(limit);
  rangeSlicesQuery.setColumnNames(columnNameByteBuffers);
  
  QueryResult<OrderedRows<K, ByteBuffer, ByteBuffer>> queryResult = rangeSlicesQuery.execute();
  OrderedRows<K, ByteBuffer, ByteBuffer> orderedRows = queryResult.get();
  
  
  return orderedRows.getList();
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:35,代码来源:CassandraClient.java


示例17: testGetRangeSlicesKeysOnly

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
private void testGetRangeSlicesKeysOnly() {

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

        for (int i = 0; i < 5; i++) {
            mutator.addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                    HFactory.createStringColumn("fake_column_0", "fake_value_0_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_1", "fake_value_1_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_2", "fake_value_2_" + i));
        }
        mutator.execute();

        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();
        rangeSlicesQuery.setRowCount(5);

        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,代码行数:34,代码来源:HectorCassandraTest.java


示例18: testResultDetail

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
private void testResultDetail() {

        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
        // add 10 rows
        for (int i = 0; i < 10; i++) {
            mutator.addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                    HFactory.createStringColumn("fake_column_0", "fake_value_0_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_1", "fake_value_1_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_2", "fake_value_2_" + i));
        }
        MutationResult me = mutator.execute();
        System.out.println("MutationResult from 10 row insertion: " + me);

        RangeSlicesQuery<String, String, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(keyspace,
                stringSerializer, stringSerializer, stringSerializer);
        rangeSlicesQuery.setColumnFamily(COLUMN_FAMILY_NAME_1);
        rangeSlicesQuery.setKeys("", "");
        rangeSlicesQuery.setRange("", "", false, 3);

        rangeSlicesQuery.setRowCount(10);
        QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();
        System.out.println("Result from rangeSlices query: " + result.toString());

        ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily(COLUMN_FAMILY_NAME_1).setKey("fake_key_0").setName("fake_column_0");
        QueryResult<HColumn<String, String>> colResult = columnQuery.execute();
        System.out.println("Execution time: " + colResult.getExecutionTimeMicro());
        System.out.println("CassandraHost used: " + colResult.getHostUsed());
        System.out.println("Query Execute: " + colResult.getQuery());

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


示例19: getArtifactsByMetadata

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
    throws MetadataRepositoryException
{
    RangeSlicesQuery<String, String, String> query =
        HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) //
        .setColumnNames( MetadataFacetModel.COLUMNS ) //
        .addEqualsExpression( VALUE.toString(), value );

    if ( key != null )
    {
        query.addEqualsExpression( KEY.toString(), key ); //
    }
    if ( repositoryId != null )
    {
        query.addEqualsExpression( "repositoryName", repositoryId );
    }

    QueryResult<OrderedRows<String, String, String>> metadataFacetResult = query.execute();
    if ( metadataFacetResult.get() == null || metadataFacetResult.get().getCount() < 1 )
    {
        return Collections.emptyList();
    }

    List<ArtifactMetadata> artifactMetadatas = new LinkedList<ArtifactMetadata>();

    // TODO doing multiple queries, there should be a way to get all the artifactMetadatas for any number of
    // projects
    for ( Row<String, String, String> row : metadataFacetResult.get() )
    {
        QueryResult<OrderedRows<String, String, String>> artifactMetadataResult =
            HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
            .setColumnNames( ArtifactMetadataModel.COLUMNS ) //
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( REPOSITORY_NAME.toString(),
                                  getStringValue( row.getColumnSlice(), REPOSITORY_NAME ) ) //
            .addEqualsExpression( NAMESPACE_ID.toString(), getStringValue( row.getColumnSlice(), NAMESPACE_ID ) ) //
            .addEqualsExpression( PROJECT.toString(), getStringValue( row.getColumnSlice(), PROJECT_ID ) ) //
            .addEqualsExpression( PROJECT_VERSION.toString(),
                                  getStringValue( row.getColumnSlice(), PROJECT_VERSION ) ) //
            .execute();

        if ( artifactMetadataResult.get() == null || artifactMetadataResult.get().getCount() < 1 )
        {
            return Collections.emptyList();
        }

        for ( Row<String, String, String> artifactMetadataRow : artifactMetadataResult.get() )
        {
            artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( artifactMetadataRow.getColumnSlice() ) );
        }
    }

    return mapArtifactMetadataToArtifact( metadataFacetResult, artifactMetadatas );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:58,代码来源:CassandraMetadataRepository.java


示例20: doListUsers

import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入依赖的package包/类
/**
 * Lists the users in the user store.
 */
@Override
protected String[] doListUsers(String filter, int maxItemLimit) throws UserStoreException {

    List<String> users = new ArrayList<String>();
    int arrayLength = 0;

    if (maxItemLimit == 0) {
        return new String[0];
    }

    int givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;

    try {
        givenMax = Integer.parseInt(realmConfig
                .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST));
    } catch (Exception e) {
        givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;

        if (log.isDebugEnabled()) {
            log.debug("Realm configuration maximum not set : Using User Core Constant value instead!", e);
        }
    }

    if (maxItemLimit < 0 || maxItemLimit > givenMax) {
        maxItemLimit = givenMax;
    }

    RangeSlicesQuery<String, String, String> rangeSliceQuery = HFactory.createRangeSlicesQuery(keyspace,
            stringSerializer, stringSerializer, stringSerializer);

    rangeSliceQuery.setColumnFamily(CFConstants.UM_USER);
    rangeSliceQuery.setRange(filter, null, false, Integer.MAX_VALUE);
    rangeSliceQuery.addEqualsExpression(CFConstants.UM_TENANT_ID, tenantIdString);

    // TODO - Need to check how to use the filter for range
    rangeSliceQuery.setKeys("", "");
    rangeSliceQuery.setRowCount(maxItemLimit);
    QueryResult<OrderedRows<String, String, String>> result = rangeSliceQuery.execute();
    if (result != null) {
        OrderedRows<String, String, String> rows = result.get();
        if (rows.getCount() <= 0) {
            // reformatted to avoid nesting too many blocks
            return users.toArray(new String[arrayLength]);

        }
        arrayLength = rows.getCount();

        Iterator<Row<String, String, String>> rowsIterator = rows.iterator();

        while (rowsIterator.hasNext()) {
            Row<String, String, String> row = rowsIterator.next();
            if (row.getColumnSlice().getColumnByName(CFConstants.UM_USER_ID).getValue() != null) {
                String name = row.getColumnSlice().getColumnByName(CFConstants.UM_USER_NAME).getValue();
                // append the domain if exist
                name = UserCoreUtil.addDomainToName(name, domain);
                users.add(name);
            }
        }

    }
    return users.toArray(new String[arrayLength]);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AclEntryScope类代码示例发布时间:2022-05-22
下一篇:
Java SpigotTimings类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap