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

Java Rows类代码示例

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

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



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

示例1: HectorRowSliceResultSet

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
public HectorRowSliceResultSet(QueryResult<Rows<K, N, V>> result) {
	this.result = result;
	this.rowItems = result.get();
	iterator = rowItems.iterator();
	if (iterator == null) {
		return;
	}
	if (iterator.hasNext()) {
		row = iterator.next();
		if (row == null) {
			return;
		}
		this.slice = row.getColumnSlice();

	}

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


示例2: loadMessages

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/** Load the messages into an array list */
protected List<Message> loadMessages( Collection<UUID> messageIds, boolean reversed ) {

    Rows<UUID, String, ByteBuffer> messageResults =
            createMultigetSliceQuery( ko, ue, se, be ).setColumnFamily( MESSAGE_PROPERTIES.getColumnFamily() )
                                                      .setKeys( messageIds )
                                                      .setRange( null, null, false, ALL_COUNT ).execute().get();

    List<Message> messages = new ArrayList<Message>( messageIds.size() );

    for ( Row<UUID, String, ByteBuffer> row : messageResults ) {
        Message message = deserializeMessage( row.getColumnSlice().getColumns() );

        if ( message != null ) {
            messages.add( message );
        }
    }

    Collections.sort( messages, new RequestedOrderComparator( messageIds ) );

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


示例3: getMulti

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/**
 * Get multiple values
 * @param keys
 * @return
 */
public Map<String, String> getMulti(String columnName, String... keys) {
  MultigetSliceQuery<String, String,String> q = createMultigetSliceQuery(keyspace, serializer, serializer, serializer);
  q.setColumnFamily(columnFamilyName);
  q.setKeys(keys);
  q.setColumnNames(columnName);

  QueryResult<Rows<String,String,String>> r = q.execute();
  Rows<String,String,String> rows = r.get();
  Map<String, String> ret = new HashMap<String, String>(keys.length);
  for (String k: keys) {
    HColumn<String, String> c = rows.getByKey(k).getColumnSlice().getColumnByName(columnName);
    if (c != null && c.getValue() != null) {
      ret.put(k, c.getValue());
    }
  }
  return ret;
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:23,代码来源:HectorCassandraDao.java


示例4: basicMultiGetAsMap

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/**
 * Helper method to get multiple rows and return result in a Map.
 * @param rowKeys     The row keys to read.
 * @param columnNames if null then get all columns; otherwise, get only specified columns. If empty, then this
 *                    is a key-only query and only the keys are returned.
 * @return The column data
 */
private Map<K,Map<N,V>> basicMultiGetAsMap(Iterable <K> rowKeys, @Nullable N[] columnNames) {

    Map<K,Map<N,V>> resultMap = new HashMap<K,Map<N,V>>();
    MultigetSliceQuery<K,N,V> query = HFactory.createMultigetSliceQuery(getKeyspace(),
                                                                        getKeySerializer(),
                                                                        getColumnNameSerializer(),
                                                                        getValueSerializer());
    query.setKeys(rowKeys).
            setColumnFamily(getColumnFamily()).
            setRange(null, null, false, ALL);
    if (columnNames != null) {
        query.setColumnNames(columnNames);
    }
    QueryResult<Rows<K,N,V>> result = query.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,代码行数:39,代码来源:ColumnFamilyTemplate.java


示例5: basicMultiGet

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/**
 * Helper method to get multiple rows using a row mapper.
 * @param rowKeys     The row keys to read.
 * @param columnNames if null then get all columns; otherwise, get only specified columns. If empty, then this
 *                    is a key-only query and only the keys are returned.
 * @return The column data
 */
private <T> List<T> basicMultiGet(Iterable <K> rowKeys,
                                  ColumnFamilyRowMapper<T,K,N,V> rowMapper,
                                  @Nullable N[] columnNames) {

    List<T> resultList = new ArrayList<T>();

    MultigetSliceQuery<K,N,V> query = HFactory.createMultigetSliceQuery(getKeyspace(),
                                                                        getKeySerializer(),
                                                                        getColumnNameSerializer(),
                                                                        getValueSerializer());
    query.setKeys(rowKeys).
            setColumnFamily(getColumnFamily()).
            setRange(null, null, false, ALL);
    if (columnNames != null) {
        query.setColumnNames(columnNames);
    }
    QueryResult<Rows<K,N,V>> result = query.execute();

    for (Row<K,N,V> row : result.get()) {
        K key = row.getKey();
        ColumnSlice<N,V> slice = row.getColumnSlice();
        List<HColumn<N,V>> columns = new ArrayList<HColumn<N,V>>();
        for (HColumn<N,V> column : slice.getColumns()) {
            columns.add(column);
        }
        resultList.add(rowMapper.mapRow(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: " + resultList);
    }
    return resultList;
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:41,代码来源:ColumnFamilyTemplate.java


示例6: multiGetColumnRange

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
@Override
public <T> Map<K,List<T>> multiGetColumnRange(Iterable<K> rowKeys,
                                               SN supercolumnName,
                                               N start,
                                               N finish,
                                               int count,
                                               boolean reversed,
                                               ColumnMapper<T,N,V> columnMapper) {

    Map<K,List<T>> resultMap = new HashMap<K,List<T>>();
    MultigetSubSliceQuery<K,SN,N,V> query = HFactory.createMultigetSubSliceQuery(getKeyspace(),
                                                                                 getKeySerializer(),
                                                                                 getSuperColumnNameSerializer(),
                                                                                 getSubcolumnNameSerializer(),
                                                                                 getValueSerializer());
    query.setKeys(Lists.newArrayList(rowKeys)).
            setSuperColumn(supercolumnName).
            setColumnFamily(getColumnFamily()).
            setRange(start, finish, reversed, count);
    QueryResult<Rows<K,N,V>> result = query.execute();

    for (Row<K,N,V> row : result.get()) {
        List<T> resultList = new ArrayList<T>();
        K key = row.getKey();
        ColumnSlice<N,V> slice = row.getColumnSlice();
        for (HColumn<N,V> column : slice.getColumns()) {
            resultList.add(columnMapper.mapColumn(column.getName(), column.getValue()));
        }
        resultMap.put(key, resultList);
    }
    return resultMap;
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:33,代码来源:SuperColumnFamilyTemplate.java


示例7: basicMultiGetAsMap

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/**
 * Read a single super columns from multiple rows and return data as a map.
 *
 * @param columnNames if null then return all columns, otherwise return specific columns. If empty then
 *                    returns keys only (no supercolumns or columns).
 */
private Map<K,Map<N,V>> basicMultiGetAsMap(Collection<K> rowKeys,
                                           SN superColumnName,
                                           @Nullable N[] columnNames) {

    Map<K,Map<N,V>> superColumns = new HashMap<K,Map<N,V>>();

    MultigetSubSliceQuery<K,SN,N,V> query = HFactory.createMultigetSubSliceQuery(getKeyspace(),
                                                                                 getKeySerializer(),
                                                                                 getSuperColumnNameSerializer(),
                                                                                 getSubcolumnNameSerializer(),
                                                                                 getValueSerializer());
    query.setKeys(rowKeys).
            setColumnFamily(getColumnFamily()).
            setSuperColumn(superColumnName).
            setRange(null, null, false, ALL);
    if (columnNames != null) {
        query.setColumnNames(columnNames);
    }
    QueryResult<Rows<K,N,V>> result = query.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);
        }
        superColumns.put(key, columns);
    }
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
    return superColumns;
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:40,代码来源:SuperColumnFamilyTemplate.java


示例8: basicMultiGetSubSlice

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
/**
 * Read a single super column from multiple rows returns as a list of mapped super columns.
 *
 * @param columnNames if null then return all columns, otherwise return specific columns in each row. If empty then
 *                    returns keys only (no supercolumns or columns).
 * @return a list of row objects as provided by the row mapper
 */
private <T> List<T> basicMultiGetSubSlice(Collection<K> rowKeys,
                                          SN superColumnName,
                                          SuperColumnMapper<T,K,SN,N,V> superColumnMapper,
                                          @Nullable N[] columnNames) {

    List<T> superColumns = new LinkedList<T>();

    MultigetSubSliceQuery<K,SN,N,V> query = HFactory.createMultigetSubSliceQuery(getKeyspace(),
                                                                                 getKeySerializer(),
                                                                                 getSuperColumnNameSerializer(),
                                                                                 getSubcolumnNameSerializer(),
                                                                                 getValueSerializer());
    query.setKeys(rowKeys).
            setColumnFamily(getColumnFamily()).
            setSuperColumn(superColumnName).
            setRange(null, null, false, ALL);
    if (columnNames != null) {
        query.setColumnNames(columnNames);
    }
    QueryResult<Rows<K,N,V>> result = query.execute();

    for (Row<K,N,V> row : result.get()) {
        K key = row.getKey();
        ColumnSlice<N,V> slice = row.getColumnSlice();
        List<HColumn<N,V>> columns = slice.getColumns();
        T mappedSuperColumn = superColumnMapper.mapSuperColumn(key, superColumnName, columns);
        superColumns.add(mappedSuperColumn);
    }
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
    return superColumns;
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:39,代码来源:SuperColumnFamilyTemplate.java


示例9: getSlice

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
@Override
public <R, T> HerculesMultiQueryResult<R, T> getSlice(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer,
                                                      Iterable<R> rowKeys, SliceDataSpecificator<T> sliceDataSpecificator) {
    MultigetSliceQuery<R, T, ByteBuffer> multigetSliceQuery = HFactory.createMultigetSliceQuery(
            keyspace,
            rowSerializer.getRowKeySerializer(),
            rowSerializer.getTopKeySerializer(),
            ByteBufferSerializer.get());

    multigetSliceQuery.setColumnFamily(columnFamily);
    multigetSliceQuery.setKeys(rowKeys);

    sliceDataSpecificator.fillMultigetSliceQuery(multigetSliceQuery);

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

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

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


示例10: buildQueryResult

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
private <R, T> HerculesMultiQueryResult<R, T> buildQueryResult(DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, Rows<R, T, ByteBuffer> rows) {
    if (rows.getCount() == 0) {
        return new HerculesMultiQueryResult<R, T>();
    }

    LinkedHashMap<R, LinkedHashMap<T, Object>> result = new LinkedHashMap<R, LinkedHashMap<T, Object>>();

    R lastKey = null;
    for (Row<R, T, ByteBuffer> row : rows) {
        lastKey = row.getKey();

        List<HColumn<T, ByteBuffer>> columns = row.getColumnSlice().getColumns();

        if (columns.size() > 0) {
            LinkedHashMap<T, Object> valueMap = new LinkedHashMap<T, Object>();

            for (HColumn<T, ByteBuffer> column : columns) {
                if (!rowSerializer.hasValueSerializer(column.getName())) continue;

                Serializer serializer = new InformerSerializer(rowSerializer.getValueSerializer(column.getName()), dataOperationsProfile);
                valueMap.put(column.getName(), serializer.fromByteBuffer(column.getValue()));
            }

            result.put(row.getKey(), valueMap);
        }
    }

    return result.size() > 0 ? new HerculesMultiQueryResult<R, T>(result, lastKey) : new HerculesMultiQueryResult<R, T>(lastKey);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:30,代码来源:ThriftDataDriver.java


示例11: testMultiGetColumnsAsMapSpecifyingNoColumnName

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
@Test(groups={"unit"})
public void testMultiGetColumnsAsMapSpecifyingNoColumnName() {
    Map<String,Map<String,String>> expectedResult =  new HashMap<String,Map<String,String>>();

    Map<String,String> properties = new HashMap<String, String>();
    Iterator<String> itr = columnValues.iterator();
    for (String columnName : columnNames) {
        properties.put(columnName, itr.next());
    }

    for(String key : rowKeys) {
        expectedResult.put(key, properties);
    }

    Rows<String,String,String> rows  = mock(Rows.class);
    when(executionResult.get()).thenReturn(rows);

    ColumnSlice<String,String> columnSlice = mock(ColumnSlice.class);
    Row<String,String,String> mockRow = mock(Row.class);
    // hard codes number of row keys to be 2
    when(mockRow.getKey()).thenReturn(rowKeys.get(0)).thenReturn(rowKeys.get(1));
    when(mockRow.getColumnSlice()).thenReturn(columnSlice);
    HColumn<String,String> mockColumn = mock(HColumn.class);

    when(mockColumn.getName()).thenReturn(columnNames.get(0)).thenReturn(columnNames.get(1)).
            thenReturn(columnNames.get(0)).thenReturn(columnNames.get(1));
    when(mockColumn.getValue()).
            thenReturn(columnValues.get(0)).
            thenReturn(columnValues.get(1)).
            thenReturn(columnValues.get(0)).
            thenReturn(columnValues.get(1));

    List<HColumn<String,String>> columnList = Arrays.asList(mockColumn,mockColumn);
    when(columnSlice.getColumns()).thenReturn(columnList);

    Iterator<Row<String,String,String>> mockRowIterator = mock(Iterator.class);
    when(rows.iterator()).thenReturn(mockRowIterator);
    when(mockRowIterator.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false);
    when(mockRowIterator.next()).thenReturn(mockRow).thenReturn(mockRow);

    //=========================
    Map<String,Map<String,String>> result =
            superColumnFamilyTestDao.multiGetColumnsAsMap(rowKeys, superColumnName);
    //=========================

    assertEquals(result, expectedResult);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:48,代码来源:SuperColumnFamilyTemplateTest.java


示例12: testBasicMultiGetAsMap

import me.prettyprint.hector.api.beans.Rows; //导入依赖的package包/类
@Test(groups = {"unit"})
public void testBasicMultiGetAsMap() throws Exception {

    Rows<String,String,String> resultRows = mock(Rows.class);
    Row<String,String,String> row1 = mock(Row.class);
    Row<String,String,String> row2 = mock(Row.class);
    when(row1.getKey()).thenReturn("row1Key");
    when(row2.getKey()).thenReturn("row2Key");

    ColumnSlice columnSlice1 = mock(ColumnSlice.class);
    HColumn column1 = mock(HColumn.class);
    HColumn column2 = mock(HColumn.class);

    when(column1.getName()).thenReturn(columnNames.get(0));
    when(column1.getValue()).thenReturn(columnValues.get(0));
    when(column2.getName()).thenReturn(columnNames.get(1));
    when(column2.getValue()).thenReturn(columnValues.get(1));
    when(columnSlice1.getColumns()).thenReturn(Arrays.asList(column1, column2));

    when(row1.getColumnSlice()).thenReturn(columnSlice1);
    when(row2.getColumnSlice()).thenReturn(columnSlice1);
    Iterator<Row<String,String,String>> iterator = Arrays.asList(row1,row2).iterator();
    when(resultRows.iterator()).thenReturn(iterator);
    when(executionResult.get()).thenReturn(resultRows);

    Iterable<String> rowKeys = Arrays.asList("key1", "key2");

    Map<String,String> oneRowMap = new HashMap<String,String>();
    oneRowMap.put("columnName1", "columnValue1");
    oneRowMap.put("columnName2", "columnValue2");
    Map<String,Map<String,String>> expectedResultMap = new HashMap<String,Map<String,String>>();
    expectedResultMap.put("row1Key", oneRowMap);
    expectedResultMap.put("row2Key", oneRowMap);

    //=========================
    Map<String,Map<String,String>> resultMap = columnFamilyTestDao.multiGetAsMap(rowKeys);
    //=========================

    assertNotNull(resultMap);
    assertEquals(resultMap, expectedResultMap);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:42,代码来源:ColumnFamilyTemplateTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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