zznate / hector-examples Goto Github PK
View Code? Open in Web Editor NEWVarious examples of using the Hector API to access Apache Cassandra
License: MIT License
Various examples of using the Hector API to access Apache Cassandra
License: MIT License
After running SchemaManipulation this is the output from cassandra-cli (show keyspaces)
Keyspace: DynamicKeyspace:
Replication Strategy: org.apache.cassandra.locator.SimpleStrategy
Durable Writes: true
Options: [replication_factor:1]
Column Families:
ColumnFamily: DynamicCf
Key Validation Class: org.apache.cassandra.db.marshal.BytesType
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Columns sorted by: org.apache.cassandra.db.marshal.BytesType
Row cache size / save period in seconds: 0.0/0
Key cache size / save period in seconds: 0.0/0
Memtable thresholds: 0.26718749999999997/1440/57 (millions of ops/minutes/MB)
GC grace seconds: 0
Compaction min/max thresholds: 4/32
Read repair chance: 0.0
Replicate on write: false
Built indexes: []
Column Metadata:
Column Name: birthdate (626972746864617465)
Validation Class: org.apache.cassandra.db.marshal.LongType
ColumnFamily: SuperCf (Super)
Key Validation Class: org.apache.cassandra.db.marshal.BytesType
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Columns sorted by: org.apache.cassandra.db.marshal.BytesType/org.apache.cassandra.db.marshal.BytesType
Row cache size / save period in seconds: 0.0/0
Key cache size / save period in seconds: 0.0/0
Memtable thresholds: 0.26718749999999997/1440/57 (millions of ops/minutes/MB)
GC grace seconds: 0
Compaction min/max thresholds: 4/32
Read repair chance: 0.0
Replicate on write: false
Built indexes: []
Compared with the Keyspace created by the Riptano documentation example
Keyspace: demo:
Replication Strategy: org.apache.cassandra.locator.NetworkTopologyStrategy
Durable Writes: true
Options: [datacenter1:1]
Column Families:
ColumnFamily: users
Key Validation Class: org.apache.cassandra.db.marshal.BytesType
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
Row cache size / save period in seconds: 0.0/0
Key cache size / save period in seconds: 200000.0/14400
Memtable thresholds: 0.5484375/1440/117 (millions of ops/minutes/MB)
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 1.0
Replicate on write: true
Built indexes: [users.users_birth_date_idx]
Column Metadata:
Column Name: birth_date
Validation Class: org.apache.cassandra.db.marshal.LongType
Index Name: users_birth_date_idx
Index Type: KEYS
Column Name: full_name
Validation Class: org.apache.cassandra.db.marshal.UTF8Type
Keyspace: system:
Hi am new to cassandra 0.7. could u able to clear my doubt???
public class Read1Column
{
private static StringSerializer stringSerializer = StringSerializer.get();
private static DoubleSerializer doubtSerializer = DoubleSerializer.get();
public static void main(String[] args) throws Exception {
String keyspaceName = "User";
String columnFamilyName ="User_Details";
String serverAddress = "localhost:9160";
//String username="stu1";
String Uid="0001";
// String FirstName="ss";
// String LastName="kk";
// String EMail="sksk";
String password="ssss";
// Create a cluster
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", serverAddress);
Keyspace keyspaceOperator = HFactory.createKeyspace(keyspaceName, cluster);
try{
Iterator<SuperRow<String, String, String, Double>> rowIter =
HFactory.createRangeSuperSlicesQuery(keyspaceOperator,
stringSerializer, stringSerializer, stringSerializer,
doubtSerializer)
.setColumnFamily(columnFamilyName)
.setKeys(Uid,password)
.setRange(Uid, password, false, 40)
.execute()
.get()
.iterator();
while (rowIter.hasNext()) {
SuperRow<String, String, String, Double> row =
rowIter.next();
List<HSuperColumn<String, String, Double>> scList =
row.getSuperSlice().getSuperColumns();
for (int i=0; i<scList.size(); i++) {
HSuperColumn<String, String, Double> sc =
scList.get(i);
// Double val = sc.get(2).getValue();
// gets the value of column 2 within the supercolumn
System.out.println(sc.get(2).getValue());
}
}
} catch (HectorException e) {
e.printStackTrace();
}
// client.getConnectionManager().shutdown();
}
}
log4j:WARN No appenders could be found for logger (me.prettyprint.cassandra.connection.CassandraHostRetryService).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NullPointerException: Null not allowed, number 1
at me.prettyprint.cassandra.utils.Assert.noneNull(Assert.java:25)
at me.prettyprint.cassandra.model.HSuperColumnImpl.(HSuperColumnImpl.java:58)
at me.prettyprint.cassandra.model.SuperSliceImpl.(SuperSliceImpl.java:35)
at me.prettyprint.cassandra.model.SuperRowImpl.(SuperRowImpl.java:34)
at me.prettyprint.cassandra.model.SuperRowsImpl.(SuperRowsImpl.java:35)
at me.prettyprint.cassandra.model.OrderedSuperRowsImpl.(OrderedSuperRowsImpl.java:28)
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery$1.doInKeyspace(ThriftRangeSuperSlicesQuery.java:73)
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery$1.doInKeyspace(ThriftRangeSuperSlicesQuery.java:67)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:65)
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery.execute(ThriftRangeSuperSlicesQuery.java:66)
at Read1Column.main(Read1Column.java:40)
Hi,
How to paginate back from a 'n' the row key using RangeSlicesQuery ?
The data is based on RP and the reverse option on the setRange function seems to be applicable only for the columns not on the rows. (http://tinyurl.com/73tncn3)
Could you please provide your comments on this ?
Thanks,
Sribalaji
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.