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 * 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 //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>(); 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; OperationResult<Rows<String, String>> result;
try { try {
result = conn.getKeyspace().prepareQuery(cf_Attachments) result = conn.getKeyspace().prepareQuery(cf_Attachments)

View File

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