Merge branch 'develop' of https://github.com/noorq/casser into develop

This commit is contained in:
Alex Shvid 2015-04-28 15:36:10 -07:00
commit ca6f4f498b
4 changed files with 15 additions and 143 deletions

View file

@ -8,24 +8,35 @@ Current status: First application is using in production!
* Leverages Java 8 language capabilities to build CQL queries * Leverages Java 8 language capabilities to build CQL queries
* Simple function-style stream API * Simple function-style stream API
* Reactive asynchronous and synchronous API * Reactive asynchronous and synchronous API
* Provides Java mapping for Tables, Tuples, User Defined Types, Collections, UDT Collections, Tuple Collections * Provides Java mapping for Tables, Tuples, UDFs (User Defined Types), Collections, UDT Collections, Tuple Collections
### Requirements ### Requirements
* Only JVM 8 * Only JVM 8
* Latest Datastax Driver 2.1.5 * Latest Datastax Driver 2.1.5
* Latest Cassandra * Latest Cassandra 2.1.4
* Maven * Maven
### Maven ### Maven
Latest release dependency:
```
<dependencies>
<dependency>
<groupId>com.noorq.casser</groupId>
<artifactId>casser-core</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
```
Active development dependency: Active development dependency:
``` ```
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.noorq.casser</groupId> <groupId>com.noorq.casser</groupId>
<artifactId>casser-core</artifactId> <artifactId>casser-core</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.noorq.casser</groupId> <groupId>com.noorq.casser</groupId>
<artifactId>casser-core</artifactId> <artifactId>casser-core</artifactId>
<version>1.0.0</version> <version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>casser</name> <name>casser</name>

View file

@ -1,110 +0,0 @@
/*
* Copyright (C) 2015 Noorq, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.noorq.casser;
import static com.noorq.casser.core.Query.eq;
import com.datastax.driver.core.Cluster;
import com.noorq.casser.core.Casser;
import com.noorq.casser.core.CasserSession;
import com.noorq.casser.core.Operator;
import com.noorq.casser.core.operation.PreparedStreamOperation;
import com.noorq.casser.support.Fun;
import com.noorq.casser.support.Fun.Tuple1;
public class Example {
static final User user = Casser.dsl(User.class);
Cluster cluster = new Cluster.Builder().addContactPoint("localhost").build();
CasserSession session = Casser.connect(cluster).use("test").add(user).autoUpdate().get();
public static User mapUser(final Fun.Tuple2<String, Integer> t) {
return new User() {
@Override
public Long id() {
return null;
}
@Override
public String name() {
return t._1;
}
@Override
public Integer age() {
return t._2;
}
};
}
public static class UserImpl implements User {
Long id;
String name;
Integer age;
@Override
public Long id() {
return id;
}
@Override
public String name() {
return name;
}
@Override
public Integer age() {
return age;
}
}
public void test() {
UserImpl newUser = new UserImpl();
newUser.id = 100L;
newUser.name = "alex";
newUser.age = 34;
session.upsert(newUser);
String nameAndAge = session.select(user::name, user::age).where(user::id, eq(100L)).sync().findFirst().map(t -> {
return t._1 + ":" + t._2;
}).get();
User userTmp = session.select(user::name, user::age).where(user::id, eq(100L)).map(Example::mapUser).sync().findFirst().get();
session.update(user::age, 10).where(user::id, eq(100L)).async();
session.delete(User.class).where(user::id, eq(100L)).async();
PreparedStreamOperation<Tuple1<String>> ps = session.select(user::name).where(user::id, Operator.EQ, null).prepare();
long cnt = ps.bind(100L).sync().count();
cnt = session.select(user::name).where(user::id, eq(100L)).count().sync();
cnt = session.select(user::name).where(user::id, eq(100L)).count().sync();
}
}

View file

@ -1,29 +0,0 @@
/*
* Copyright (C) 2015 Noorq, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.noorq.casser;
import com.noorq.casser.mapping.annotation.Table;
@Table("user")
public interface User {
Long id();
String name();
Integer age();
}