fixed creation of secondary index on ATTACHMENTS CF

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@133058 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-10-11 13:01:58 +00:00
parent 036880784d
commit 872dd71b75
3 changed files with 30 additions and 28 deletions

View File

@ -254,7 +254,7 @@ public class CassandraClusterConnection {
/**
* define Attachments CF with FeedId as secondary index
*/
ColumnFamilyDefinition cfDefAttachments = getStaticCFDef(DBCassandraAstyanaxImpl.ATTACHMENTS, "Feedid");
ColumnFamilyDefinition cfDefAttachments = getStaticCFDef(DBCassandraAstyanaxImpl.ATTACHMENTS, "feedId");
//get dynamic column families, act as auxiliary indexes

View File

@ -2167,7 +2167,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
List<Attachment> toReturn = new ArrayList<Attachment>();
PreparedIndexExpression<String, String> clause = cf_Attachments.newIndexClause().whereColumn("Feedid").equals().value(feedId);
PreparedIndexExpression<String, String> clause = cf_Attachments.newIndexClause().whereColumn("feedId").equals().value(feedId);
OperationResult<Rows<String, String>> result;
try {
result = conn.getKeyspace().prepareQuery(cf_Attachments)

View File

@ -1,4 +1,6 @@
package org.gcube.portal.databook.server;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -297,32 +299,32 @@ public class DatabookCassandraTest {
// }
// /**
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
// */
// @Test
// public void addAttachmentStaticColumnFamilies() {
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
//
// try {
// String colNameToIndex = "feedId";
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
// .put("column_metadata", ImmutableMap.<String, Object>builder()
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
// .put("validation_class", "UTF8Type")
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
// .put("index_type", "KEYS")
// .build())
// .build())
// .build());
//
//
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
// System.out.println("addStaticColumnFamily END");
// }
// /**
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
// */
// @Test
// public void addAttachmentStaticColumnFamilies() {
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
//
// try {
// String colNameToIndex = "feedId";
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
// .put("column_metadata", ImmutableMap.<String, Object>builder()
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
// .put("validation_class", "UTF8Type")
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
// .put("index_type", "KEYS")
// .build())
// .build())
// .build());
//
//
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
// System.out.println("addStaticColumnFamily END");
// }
//
// /**
// * use exclusively to add a new (Dynamic) CF to a keyspace