/** * Performs an insert/update for a row in Cassandra. * * @param rowKey * @param attributes */ public void upsert(String rowKey, Map<String, Object> attributes) { new HystrixCassandraPut<String>(keyspace, COLUMN_FAMILY, rowKey, attributes).execute(); }
@SuppressWarnings("unchecked") public HystrixCassandraPut(Keyspace keyspace, String columnFamilyName, RowKeyType rowKey, Map<String, Object> attributes, int ttlSeconds) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, rowKey); this.rowKey = rowKey; this.attributes = attributes; if(ttlSeconds > 0){ this.ttlSeconds = ttlSeconds; } }
/** * Get rows specified by their row keys. * * @param keyspace * @param columnFamilyName * @param cql */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByQuery(Keyspace keyspace, String columnFamilyName, Class<?> columnFamilyKeyType, String cql) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, columnFamilyKeyType); this.cql = cql; }
/** * Performs a CQL query and returns result. * * @param cql * @return */ public Rows<String, String> select(String cql) { return new HystrixCassandraGetRowsByQuery<String>(keyspace, COLUMN_FAMILY, String.class, cql).execute(); }
@Override public Rows<String, String> getByFilterIds(List<String> filterIds) { String[] list = new String[filterIds.size()]; for (int i = 0; i < filterIds.size(); i++) { list[i] = filterIds.get(i); } return new HystrixCassandraGetRowsByKeys<String>(keyspace, COLUMN_FAMILY, list).execute(); } }
/** * Get rows specified by their row keys. * * @param keyspace * @param columnFamilyName * @param rowKeys */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByKeys(Keyspace keyspace, String columnFamilyName, RowKeyType... rowKeys) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, rowKeys[0]); this.rowKeys = rowKeys; this.startKey = null; this.endKey = null; this.startToken = null; this.endToken = null; this.maxRows = -1; }
/** * returns a ColumnFamily given a columnFamilyName * @param columnFamilyName * @param rowKey * @return */ @SuppressWarnings("rawtypes") protected ColumnFamily getColumnFamilyViaColumnName(String columnFamilyName, Object rowKey) { return getColumnFamilyViaColumnName(columnFamilyName, rowKey.getClass()); }
/** * Performs an insert/update for a row in Cassandra. * * @param rowKey * @param attributes */ @Override public void upsert(String rowKey, Map<String, Object> attributes) { new HystrixCassandraPut<String>(keyspace, COLUMN_FAMILY, rowKey, attributes).execute(); }
/** * Performs a CQL query and returns result. * * @param cql * @return */ @Override public Rows<String, String> select(String cql) { return new HystrixCassandraGetRowsByQuery<String>(keyspace, COLUMN_FAMILY, String.class, cql).execute(); }
public Rows<String, String> getByFilterIds(List<String> filterIds) { String[] list = new String[filterIds.size()]; for (int i = 0; i < filterIds.size(); i++) { list[i] = filterIds.get(i); } return new HystrixCassandraGetRowsByKeys<String>(keyspace, COLUMN_FAMILY, list).execute(); } }
/** * Get rows specified by their row keys. * * @param keyspace * @param columnFamilyName * @param rowKeys */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByKeys(Keyspace keyspace, String columnFamilyName, RowKeyType... rowKeys) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, rowKeys[0]); this.rowKeys = rowKeys; this.startKey = null; this.endKey = null; this.startToken = null; this.endToken = null; this.maxRows = -1; }
@SuppressWarnings("unchecked") public HystrixCassandraPut(Keyspace keyspace, String columnFamilyName, RowKeyType rowKey, Map<String, Object> attributes, int ttlSeconds) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, rowKey); this.rowKey = rowKey; this.attributes = attributes; if(ttlSeconds > 0){ this.ttlSeconds = ttlSeconds; } }
/** * Get rows specified by their row keys. * * @param keyspace * @param columnFamilyName * @param cql */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByQuery(Keyspace keyspace, String columnFamilyName, Class<?> columnFamilyKeyType, String cql) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, columnFamilyKeyType); this.cql = cql; }
/** * returns a ColumnFamily given a columnFamilyName * @param columnFamilyName * @param rowKey * @return */ @SuppressWarnings("rawtypes") protected ColumnFamily getColumnFamilyViaColumnName(String columnFamilyName, Object rowKey) { return getColumnFamilyViaColumnName(columnFamilyName, rowKey.getClass()); }
@Override public void updateFilterIndex(String rowKey, String filter_ids) { HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put("index_name", rowKey); attributes.put("filter_ids", filter_ids); new HystrixCassandraPut<String>(keyspace, "zuul_filter_indices", rowKey, attributes).execute(); }
/** * Get a range of rows. * * @param keyspace * @param columnFamilyName * @param startKey * @param endKey * @param startToken * @param endToken * @param maxRows */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByKeys(Keyspace keyspace, String columnFamilyName, RowKeyType startKey, RowKeyType endKey, String startToken, String endToken, int maxRows) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, startKey); this.rowKeys = null; this.startKey = startKey; this.endKey = endKey; this.startToken = startToken; this.endToken = endToken; this.maxRows = maxRows; }
public void updateFilterIndex(String rowKey, String filter_ids) { HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put("index_name", rowKey); attributes.put("filter_ids", filter_ids); new HystrixCassandraPut<String>(keyspace, "zuul_filter_indices", rowKey, attributes).execute(); }
/** * Get a range of rows. * * @param keyspace * @param columnFamilyName * @param startKey * @param endKey * @param startToken * @param endToken * @param maxRows */ @SuppressWarnings("unchecked") public HystrixCassandraGetRowsByKeys(Keyspace keyspace, String columnFamilyName, RowKeyType startKey, RowKeyType endKey, String startToken, String endToken, int maxRows) { this.keyspace = keyspace; this.columnFamily = getColumnFamilyViaColumnName(columnFamilyName, startKey); this.rowKeys = null; this.startKey = startKey; this.endKey = endKey; this.startToken = startToken; this.endToken = endToken; this.maxRows = maxRows; }