object mapping and keyspace in @UDT and @Table
I am using the new object mapping API for the first time with a 2.1 cluster. Recently I hit a problem when using different keyspace names, i.e. the keyspace in our integration test environment was called differently from the keyspace we use in our staging environment. The problem is that the keyspace in the object mapping API is specified at compile time using the keyspace attribute in the @UDT or @Table annotation of the annotated bean. This sort of makes it less flexible as you cannot re-use the bean in different keyspaces, so I was wondering why the API has been designed like this - I guess there is a reason? Looking at MappingManager.getUDTMapper or MappingManager.getMapper, access to a session instance exists, which could have been used to fetch the keyspace name instead or as a fallback. Of course the session could not be connected to a keyspace, but the user can be told that with a nice Exception. How do you feel about adding a fallback like this: - keyspace defined in @UDT or @Table = use it (todays behaviour) - otherwise if keyspace is empty, use session.getLoggedKeyspace - if getLoggedKeyspace is empty = improved Exception Currently you get a NullpointerException in UDTMapper or Mapper if the keyspace doesn't exist. If you guys agree, I would like to write a patch. Cheers, Reik
Re: object mapping and keyspace in @UDT and @Table
Hi Reik, This is the mailing list for the Cassandra developers. The Java driver has a dedicated list, which is located at https://groups.google.com/a/lists.datastax.com/forum/#!forum/java-driver-user I'm going to answer your question there. -- Olivier Michallat Driver & tools engineer, DataStax On Mon, Nov 10, 2014 at 12:06 PM, Reik Schatz wrote: > I am using the new object mapping API for the first time with a 2.1 > cluster. Recently I hit a problem when using different keyspace names, > i.e. the keyspace in our integration test environment was called > differently from the keyspace we use in our staging environment. > > The problem is that the keyspace in the object mapping API is > specified at compile time using the keyspace attribute in the @UDT or > @Table annotation of the annotated bean. This sort of makes it less > flexible as you cannot re-use the bean in different keyspaces, so I > was wondering why the API has been designed like this - I guess there > is a reason? > > Looking at MappingManager.getUDTMapper or MappingManager.getMapper, > access to a session instance exists, which could have been used to > fetch the keyspace name instead or as a fallback. Of course the > session could not be connected to a keyspace, but the user can be told > that with a nice Exception. > > How do you feel about adding a fallback like this: > - keyspace defined in @UDT or @Table = use it (todays behaviour) > - otherwise if keyspace is empty, use session.getLoggedKeyspace > - if getLoggedKeyspace is empty = improved Exception > > Currently you get a NullpointerException in UDTMapper or Mapper if the > keyspace doesn't exist. If you guys agree, I would like to write a > patch. > > Cheers, > Reik >
[VOTE RESULT] Release Apache Cassandra 2.1.2
With 5 binding +1, 3 non-binding +1 and no -1 the vote passes. I'll release the artifacts
RE: Retrieving clustering columns values from cell names
I found the solution, here it is if someone needs it: CellNameType cellComparator = columnFamily.getComparator(); int clusteringPrefixSize = cellComparator.clusteringPrefixSize(); for (int prefixNb = 0; prefixNb < clusteringPrefixSize; prefixNb++) { AbstractType subtype = cellComparator.subtype(prefixNb); ByteBuffer clusteringKeyBytes = cell.name().get(prefixNb); String value = subtype.getString(clusteringKeyBytes); ... } -- Jacques-Henri Berthemet -Original Message- From: Jacques-Henri Berthemet [mailto:jacques-henri.berthe...@genesys.com] Sent: vendredi 7 novembre 2014 19:14 To: dev@cassandra.apache.org Subject: Retrieving clustering columns values from cell names Hi Cassandra developers, I'm implementing a custom PerRowSecondaryIndex and I managed to extract all data I need but clustering columns values from cell names. I know that they are part of the cell name itself and it's easy to extract the CQL column name: public static String cellNameToString(CFMetaData metadata, Cell cell) throws CharacterCodingException { if (metadata.isCQL3Table()) { return ByteBufferUtil.string(cell.name().cql3ColumnName(metadata).bytes); But I don't understand how to extract the clustering column values from cell's name. Could someone share some info about that? Thank you, -- Jacques-Henri Berthemet
[RELEASE] Apache Cassandra 2.1.2 released
The Cassandra team is pleased to announce the release of Apache Cassandra version 2.1.2. Apache Cassandra is a fully distributed database. It is the right choice when you need scalability and high availability without compromising performance. http://cassandra.apache.org/ Downloads of source and binary distributions are listed in our download section: http://cassandra.apache.org/download/ This version is a bug fix release[1] on the 2.1 series. As always, please pay attention to the release notes[2] and Let us know[3] if you were to encounter any problems. Enjoy! [1]: http://goo.gl/pi45XF (CHANGES.txt) [2]: http://goo.gl/vtSXzZ (NEWS.txt) [3]: https://issues.apache.org/jira/browse/CASSANDRA