Permalink
Browse files

More generic HFactory.createColumn #329

  • Loading branch information...
patricioe committed Feb 18, 2012
1 parent 61e577a commit 39432e6567d7d8b3a6aacee1a1aa6c30e5bed27d
Showing with 17 additions and 0 deletions.
  1. +17 −0 core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java
@@ -37,6 +37,7 @@
import me.prettyprint.cassandra.model.thrift.ThriftSuperCountQuery;
import me.prettyprint.cassandra.model.thrift.ThriftSuperSliceCounterQuery;
import me.prettyprint.cassandra.model.thrift.ThriftSuperSliceQuery;
+import me.prettyprint.cassandra.serializers.SerializerTypeInferer;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.BatchSizeHint;
import me.prettyprint.cassandra.service.CassandraHostConfigurator;
@@ -571,6 +572,22 @@ public static ConsistencyLevelPolicy createDefaultConsistencyLevelPolicy() {
valueSerializer);
}
+ /**
+ * Creates a column without specifying serializers.
+ */
+ @SuppressWarnings("unchecked")
+ public static <N, V> HColumn<N, V> createColumn(N name, V value, long clock) {
+ return new HColumnImpl<N, V>(name, value, clock, (Serializer<N>) SerializerTypeInferer.getSerializer(name.getClass()),
+ (Serializer<V>) SerializerTypeInferer.getSerializer(value.getClass()));
+ }
+
+ /**
+ * Creates a column without specifying serializers.
+ */
+ public static <N, V> HColumn<N, V> createColumn(N name, V value) {
+ return createColumn(name, value, createClock());
+ }
+
/**
* Create a column with a user-defined clock and TTL (DEFINED IN SECONDS SINCE THE TIMESTAMP [aka "clock"]).
* You probably want to use {@link me.prettyprint.hector.api.Keyspace#createClock()} for the clock

0 comments on commit 39432e6

Please sign in to comment.