本文整理汇总了Java中me.prettyprint.hector.api.beans.HSuperColumn类的典型用法代码示例。如果您正苦于以下问题:Java HSuperColumn类的具体用法?Java HSuperColumn怎么用?Java HSuperColumn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HSuperColumn类属于me.prettyprint.hector.api.beans包,在下文中一共展示了HSuperColumn类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addSuperColumns
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
/**
* When we add supercolumns, Gora keys are mapped to Cassandra partition keys only.
* This is because we follow the Cassandra logic where column family data is
* partitioned across nodes based on row Key.
*/
private void addSuperColumns(String family, CassandraQuery<K, T> cassandraQuery,
CassandraResultSet<K> cassandraResultSet) {
List<SuperRow<K, String, ByteBuffer, ByteBuffer>> superRows = this.cassandraClient.executeSuper(cassandraQuery, family);
for (SuperRow<K, String, ByteBuffer, ByteBuffer> superRow: superRows) {
K key = superRow.getKey();
CassandraRow<K> cassandraRow = cassandraResultSet.getRow(key);
if (cassandraRow == null) {
cassandraRow = new CassandraRow<>();
cassandraResultSet.putRow(key, cassandraRow);
cassandraRow.setKey(key);
}
SuperSlice<String, ByteBuffer, ByteBuffer> superSlice = superRow.getSuperSlice();
for (HSuperColumn<String, ByteBuffer, ByteBuffer> hSuperColumn: superSlice.getSuperColumns()) {
CassandraSuperColumn cassandraSuperColumn = new CassandraSuperColumn();
cassandraSuperColumn.setValue(hSuperColumn);
cassandraSuperColumn.setFamily(family);
cassandraRow.add(cassandraSuperColumn);
}
}
}
开发者ID:jianglibo,项目名称:gora-boot,代码行数:28,代码来源:CassandraStore.java
示例2: readRow
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
/**
* Read an entire row as a list of mapped supercolumns.
*
* @param key the row key
* @return a List of T as returned by the supercolumn mapper.
*
*/
@Override
public <T> List<T> readRow(K key, SuperColumnMapper<T,K,SN,N,V> superColumnMapper) {
SuperSliceQuery<K,SN,N,V> query = HFactory.createSuperSliceQuery(getKeyspace(),
getKeySerializer(),
getSuperColumnNameSerializer(),
getSubcolumnNameSerializer(),
getValueSerializer());
query.setKey(key).
setColumnFamily(getColumnFamily()).
setRange(null, null, false, ALL);
QueryResult<SuperSlice<SN,N,V>> queryResult = query.execute();
List<HSuperColumn<SN,N,V>> superColumns = queryResult.get().getSuperColumns();
List<T> results = new ArrayList<T>( superColumns.size());
for (HSuperColumn<SN,N,V> superColumn : superColumns) {
T mappedSuperColumn = superColumnMapper.mapSuperColumn(key, superColumn.getName(), superColumn.getColumns());
// don't include null
if (mappedSuperColumn != null) {
results.add(mappedSuperColumn);
}
}
return results;
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:32,代码来源:SuperColumnFamilyTemplate.java
示例3: basicWriteColumn
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
private void basicWriteColumn(K rowKey,
SN superColumnName,
N columnName,
V columnValue,
@Nullable BatchContext txnContext) {
// create the subcolumns for the super column
@SuppressWarnings({"unchecked"})
List<HColumn<N,V>> columns = Arrays.asList(
HFactory.createColumn(
columnName, columnValue, subSerializer, getValueSerializer()
)
);
HSuperColumn<SN,N,V> superColumn = HFactory.createSuperColumn(superColumnName,
columns,
getSuperColumnNameSerializer(),
getSubcolumnNameSerializer(),
getValueSerializer());
if (txnContext == null) {
insertSuperColumn(rowKey, superColumn);
} else {
insertSuperColumn(rowKey, superColumn, txnContext);
}
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:26,代码来源:SuperColumnFamilyTemplate.java
示例4: testWriteColumnsTranslateHectorException
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Test(groups={"unit"}, expectedExceptions = HectorTransportException.class)
public void testWriteColumnsTranslateHectorException() {
when(mutator.addInsertion(eq(rowKey),
eq(columnFamily),
any(HSuperColumn.class))).thenThrow(new HectorTransportException(
"test hector exception"));
Map<String,String> properties = new HashMap<String,String>();
Iterator<String> itr = columnValues.iterator();
for (String columnName : columnNames) {
properties.put(columnName, itr.next());
}
//=========================
superColumnFamilyTestDao.writeColumns(rowKey, superColumnName, properties, txnContext);
//=========================
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:18,代码来源:SuperColumnFamilyTemplateTest.java
示例5: testWriteColumn
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Test(groups={"unit"})
public void testWriteColumn() {
String propertyValue = columnValue;
//=========================
superColumnFamilyTestDao.writeColumn(rowKey, superColumnName, columnName, propertyValue, txnContext);
//=========================
HColumn<String,String> column = HFactory.createColumn(columnName,
columnValue,
StringSerializer.get(),
StringSerializer.get());
HSuperColumn<String,String,String> superColumn = HFactory.createSuperColumn(superColumnName,
Arrays.asList(column),
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
ArgumentCaptor<HSuperColumn> superColumnCaptor = ArgumentCaptor.forClass(HSuperColumn.class);
verify(mutator).addInsertion(eq(rowKey), eq(columnFamily), superColumnCaptor.capture());
HSuperColumn actualSuperColumn = superColumnCaptor.getValue();
assertTrue(areSuperColumnsEqual(actualSuperColumn, superColumn));
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:24,代码来源:SuperColumnFamilyTemplateTest.java
示例6: insertSuperColumnData
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
private void insertSuperColumnData() {
Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
mutator.insert("billing", COLUMN_FAMILY_SUPER_1, HFactory.createSuperColumn("jsmith",
Arrays.asList(HFactory.createStringColumn("first", "John")), stringSerializer, stringSerializer,
stringSerializer));
SuperColumnQuery<String, String, String, String> superColumnQuery = HFactory.createSuperColumnQuery(keyspace,
stringSerializer, stringSerializer, stringSerializer, stringSerializer);
superColumnQuery.setColumnFamily(COLUMN_FAMILY_SUPER_1).setKey("billing").setSuperName("jsmith");
QueryResult<HSuperColumn<String, String, String>> result = superColumnQuery.execute();
System.out.println("Read HSuperColumn from cassandra: " + result.get());
System.out.println("Verify on CLI with: get DynamicKeyspace1.ColumnFamilySuper1['billing']['jsmith'] ");
}
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:17,代码来源:HectorCassandraTest.java
示例7: multiGetAllSuperColumns
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Override
public <T> List<T> multiGetAllSuperColumns(Collection<K> rowKeys, SuperColumnFamilyRowMapper<T,K,SN,N,V>
superColumnFamilyRowMapper) {
List<T> result = new LinkedList<T>();
MultigetSuperSliceQuery<K,SN,N,V> query = HFactory.createMultigetSuperSliceQuery(getKeyspace(),
getKeySerializer(),
getTopSerializer(),
subSerializer,
getValueSerializer());
query.setKeys(rowKeys).
setColumnFamily(getColumnFamily()).
setRange(null, null, false, ALL);
QueryResult<SuperRows<K,SN,N,V>> queryResult = query.execute();
for (SuperRow<K,SN,N,V> row : queryResult.get()) {
K key = row.getKey();
SuperSlice<SN,N,V> slice = row.getSuperSlice();
List<HSuperColumn<SN,N,V>> columns = slice.getSuperColumns();
T t = superColumnFamilyRowMapper.mapRow(key, columns);
result.add(t);
}
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
return result;
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:29,代码来源:SuperColumnFamilyTemplate.java
示例8: readRowAsMap
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
/**
* Read an entire row as a map of maps.
*
* @param key the row key
* @return the row as a map of maps
* where the key is the super column name and the value is a map of column names to column values.
*/
@Override
public Map<SN,Map<N,V>> readRowAsMap(K key) {
SuperSliceQuery<K,SN,N,V> query = HFactory.createSuperSliceQuery(getKeyspace(),
getKeySerializer(),
getSuperColumnNameSerializer(),
getSubcolumnNameSerializer(),
getValueSerializer());
query.setKey(key).
setColumnFamily(getColumnFamily()).
setRange(null, null, false, ALL);
QueryResult<SuperSlice<SN,N,V>> queryResult = query.execute();
Map<SN,Map<N,V>> results = new HashMap<SN,Map<N,V>>();
for (HSuperColumn<SN,N,V> superColumn : queryResult.get().getSuperColumns()) {
List<HColumn<N,V>> allColumns = superColumn.getColumns();
Map<N,V> columnMap = new HashMap<N,V>(allColumns.size());
for (HColumn<N,V> column : allColumns) {
columnMap.put(column.getName(), column.getValue());
}
if (!columnMap.isEmpty()) {
results.put(superColumn.getName(), columnMap);
}
}
return results;
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:34,代码来源:SuperColumnFamilyTemplate.java
示例9: basicWriteColumns
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
/**
* Set subcolumn values for a specified super column as a batch operation.
*
* @param rowKey the row key of type K
* @param superColumnName the super column name of type SN
* @param columnMap a map of column names type N and column values type V.
* @param txnContext BatchContext for batch operations
*/
private void basicWriteColumns(K rowKey,
SN superColumnName,
Map<N,V> columnMap,
@Nullable BatchContext txnContext) {
// create the subcolumns for the super column
List<HColumn<N,V>> columns = new ArrayList<HColumn<N,V>>(columnMap.size());
for (Map.Entry<N,V> mapEntry : columnMap.entrySet()) {
columns.add(HFactory.createColumn(mapEntry.getKey(),
mapEntry.getValue(),
getSubcolumnNameSerializer(),
getValueSerializer()));
}
HSuperColumn<SN,N,V> superColumn = HFactory.createSuperColumn(superColumnName,
columns,
getSuperColumnNameSerializer(),
subSerializer,
getValueSerializer());
if (txnContext == null) {
insertSuperColumn(rowKey, superColumn);
} else {
insertSuperColumn(rowKey, superColumn, txnContext);
}
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:35,代码来源:SuperColumnFamilyTemplate.java
示例10: insertSuperColumn
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
private void insertSuperColumn(K rowKey,
HSuperColumn<SN,N,V> superColumn,
@Nonnull BatchContext txnContext) {
Validate.notNull(txnContext);
Mutator<K> mutator = validateAndGetMutator(txnContext);
mutator.addInsertion(rowKey, getColumnFamily(), superColumn);
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:10,代码来源:SuperColumnFamilyTemplate.java
示例11: shouldMultiGetAllSuperColumns
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Test(groups = "system")
public void shouldMultiGetAllSuperColumns() throws Exception {
Keyspace keyspace = getKeyspace();
SuperColumnFamilyTemplate<String,String,String,String> template = new
SuperColumnFamilyTemplate<String,String,String,String>(
keyspace,
SUPER_COLUMN_FAMILY,
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
template.multiGetAllSuperColumns(Arrays.asList(ALEX_ROW_KEY, MIKE_ROW_KEY),
new SuperColumnFamilyRowMapper<Object,String,String,String,String>() {
@Override
public Void mapRow(String rowKey, List<HSuperColumn<String,String,String>> hColumns) {
if (LOG.isDebugEnabled()) {
LOG.debug("Mapping SuperColumns: rowKey=" + rowKey +
";hColumns=" + hColumns);
}
if (rowKey.equals(ALEX_ROW_KEY)) {
assertEquals(hColumns.size(), 2);
assertEquals(hColumns.get(0).getName(), "alex");
assertEquals(hColumns.get(1).getName(), "tom");
}
if (rowKey.equals(MIKE_ROW_KEY)) {
assertEquals(hColumns.size(), 1);
assertEquals(hColumns.get(0).getName(), "mike");
}
return null;
}
});
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:39,代码来源:SuperColumnFamilyTemplateSystemTest.java
示例12: testReadRowAsMap
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Test(groups={"unit"})
public void testReadRowAsMap() {
Map<String,Map<String,String>> expectedResult = new HashMap<String,Map<String,String>>();
for (String superColumnName : superColumnNames) {
Map<String,String> properties = new HashMap<String,String>();
Iterator<String> itr = columnValues.iterator();
for (String columnName : columnNames) {
properties.put(columnName, itr.next());
}
expectedResult.put(superColumnName, properties);
}
SuperSlice superSlice = mock(SuperSlice.class);
when(executionResult.get()).thenReturn(superSlice);
HSuperColumn superColumn = mock(HSuperColumn.class);
when(superSlice.getSuperColumns()).thenReturn(Arrays.asList(superColumn, superColumn));
when(superColumn.getName()).thenReturn(superColumnNames.get(0)).thenReturn(superColumnNames.get(1));
HColumn column = mock(HColumn.class);
when(superColumn.getColumns()).thenReturn(Arrays.asList(column,column));
when(column.getName()).thenReturn(columnNames.get(0)).
thenReturn(columnNames.get(1)).
thenReturn(columnNames.get(0)).
thenReturn(columnNames.get(1));
when(column.getValue()).
thenReturn(columnValues.get(0)).
thenReturn(columnValues.get(1)).
thenReturn(columnValues.get(0)).
thenReturn(columnValues.get(1));
//=========================
Map<String,Map<String,String>> result = superColumnFamilyTestDao.readRowAsMap(rowKey);
//=========================
assertEquals(result, expectedResult);
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:37,代码来源:SuperColumnFamilyTemplateTest.java
示例13: testWriteColumnTranslateHectorException
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Test(groups={"unit"}, expectedExceptions = HectorTransportException.class)
public void testWriteColumnTranslateHectorException() {
when(mutator.addInsertion(eq(rowKey),
eq(columnFamily),
any(HSuperColumn.class))).
thenThrow(new HectorTransportException("test hector exception"));
String propertyValue = columnValue;
//=========================
superColumnFamilyTestDao.writeColumn(rowKey, superColumnName, columnName, propertyValue, txnContext);
//=========================
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:15,代码来源:SuperColumnFamilyTemplateTest.java
示例14: areSuperColumnsEqual
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@SuppressWarnings({"ControlFlowStatementWithoutBraces"})
private boolean areSuperColumnsEqual(HSuperColumn superColumn1, HSuperColumn superColumn2) {
if (superColumn1 == superColumn2) return true;
if (superColumn2 == null) return false;
if (superColumn1 == null) return false;
if (superColumn1.getClass() != superColumn2.getClass()) return false;
if (!ObjectUtils.equals(superColumn1.getName(), superColumn2.getName())) return false;
if (superColumn1.getColumns().size() != superColumn2.getColumns().size()) return false;
Iterator<HColumn> itr1 = superColumn1.getColumns().iterator();
Iterator<HColumn> itr2 = superColumn2.getColumns().iterator();
while(itr1.hasNext()) {
if (!areColumnsEqual(itr1.next(), itr2.next())) return false;
}
return true;
}
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:16,代码来源:SuperColumnFamilyTemplateTest.java
示例15: addSubDelete
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Override
public <SN, N, V> Mutator<K> addSubDelete( final K key, final String cf, final HSuperColumn<SN, N, V> sc,
final long clock ) {
target.addSubDelete( key, cf, sc, clock );
checkAndFlush();
return this;
}
开发者ID:apache,项目名称:usergrid,代码行数:8,代码来源:CountingMutator.java
示例16: getChart
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
/**
* Gets the chart.
*
* @param key the key
* @return the chart
*/
public Chart getChart(String key) {
Chart chart = new Chart();
chart.setKey(key);
List<HSuperColumn<String, String, String>> superColumns = perfDataAccessor.getChart(key);
// create maps for ds,rra,cdp (aggregator will use the zoneMap)
Map<String, Series> seriesMap = new HashMap<>();
chart.setSeriesMap(seriesMap);
for (int i = 0; i < superColumns.size(); i++) {
List<HColumn<String, String>> columns = superColumns.get(i).getColumns();
// SC to Map<String,String>
String scName = superColumns.get(i).getName();
Map<String, String> sc = new HashMap<>();
for (int j = 0; j < columns.size(); j++) {
sc.put(columns.get(j).getName(), columns.get(j).getValue());
}
// chart attributes
if (scName.equalsIgnoreCase(CHART)) {
chart.setCreated(sc.get("created"));
chart.setCreator(sc.get("creator"));
chart.setName(sc.get(NAME));
chart.setType(sc.get(TYPE));
chart.setTitle(sc.get("title"));
chart.setDescription(sc.get("description"));
chart.setStart(sc.get("start"));
chart.setEnd(sc.get("end"));
chart.setYmax(sc.get("ymax"));
chart.setYmin(sc.get("ymin"));
chart.setTheme(sc.get("theme"));
chart.setStep(sc.get(STEP));
chart.setUpdated(sc.get(UPDATED));
// series attributes
} else if (scName.indexOf(SERIES) == 0) {
Series series = new Series();
String seriesName = sc.get(NAME);
series.setName(seriesName);
series.setType(sc.get(TYPE));
series.setDatasource(sc.get("datasource"));
series.setxAxisId(sc.get("xAxisId"));
series.setyAxisId(sc.get("yAxisId"));
series.setStackGroup(sc.get("stackGroup"));
series.setColor(sc.get("color"));
series.setWeight(sc.get("weight"));
series.setRenderer(sc.get("renderer"));
series.setOffset(Integer.parseInt(sc.get("yAxisId")));
seriesMap.put(seriesName, series);
} else {
Util.logMapString("couldnt map: " + scName, sc, logger);
}
}
return chart;
}
开发者ID:oneops,项目名称:oneops,代码行数:69,代码来源:PerfDao.java
示例17: setValue
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
public void setValue(HSuperColumn<String, ByteBuffer, ByteBuffer> hSuperColumn) {
this.hSuperColumn = hSuperColumn;
}
开发者ID:jianglibo,项目名称:gora-boot,代码行数:4,代码来源:CassandraSuperColumn.java
示例18: createSuperColumn
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
public static<K> HSuperColumn<String,ByteBuffer,ByteBuffer> createSuperColumn(String superColumnName, ByteBuffer columnName, ByteBuffer columnValue, String ttlAttr) {
return HFactory.createSuperColumn(superColumnName, Arrays.asList(createColumn(columnName, columnValue, ttlAttr)), StringSerializer.get(), ByteBufferSerializer.get(), ByteBufferSerializer.get());
}
开发者ID:jianglibo,项目名称:gora-boot,代码行数:4,代码来源:HectorUtils.java
示例19: insert
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Override
public <SN, N, V> MutationResult insert( final K key, final String cf, final HSuperColumn<SN, N, V> superColumn ) {
return target.insert( key, cf, superColumn );
}
开发者ID:apache,项目名称:usergrid,代码行数:5,代码来源:CountingMutator.java
示例20: addInsertion
import me.prettyprint.hector.api.beans.HSuperColumn; //导入依赖的package包/类
@Override
public <SN, N, V> Mutator<K> addInsertion( final K key, final String cf, final HSuperColumn<SN, N, V> sc ) {
target.addInsertion( key, cf, sc );
checkAndFlush();
return this;
}
开发者ID:apache,项目名称:usergrid,代码行数:7,代码来源:CountingMutator.java
注:本文中的me.prettyprint.hector.api.beans.HSuperColumn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论