org.gcube.couchbase.helpers
Class CouchBaseHelper

java.lang.Object
  extended by org.gcube.couchbase.helpers.CouchBaseHelper

public class CouchBaseHelper
extends Object

Author:
Alex Antoniadis

Constructor Summary
CouchBaseHelper()
           
 
Method Summary
static List<String> collectionDocIDs(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Map<String,CouchBaseDataTypesHelper.DataType> keys, String collID)
          Returns the document IDs of the collection with the given ID
static void commit(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Map<String,CouchBaseDataTypesHelper.DataType> keys)
          Executes a dummyQuery on each index to "warm" it.
static void createIndexes(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Map<String,CouchBaseDataTypesHelper.DataType> keys)
          Creates one view-index for each key.
static void delete(String key, CouchBaseDataTypesHelper.DataType dataType, com.couchbase.client.CouchbaseClient client)
          Deletes the record with the given key
static Boolean deleteCollectionCouchBase(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocName, Map<String,CouchBaseDataTypesHelper.DataType> keys, MetaIndex meta, String collID)
          Deletes all the documents of the given collection
static void deleteDocsCouchBase(com.couchbase.client.CouchbaseClient client, List<String> keys)
          Deletes all the documents with key in the given keys list
static boolean feedLocator(com.couchbase.client.CouchbaseClient client, String resultSetLocation, MetaIndex meta)
          Inserts all the records that are read from the resultSetLocation gRS2 endpoint in the record, updates the meta-index and saves it
static gr.uoa.di.madgik.grs.writer.RecordWriter<gr.uoa.di.madgik.grs.record.GenericRecord> initRSWriterForSearchHits(List<String> presentables, List<String> projections, org.gcube.indexmanagement.resourceregistry.RRadaptor adaptor)
          Creates the gRS2 writer for the given projections and presentables.
static void insertSimple(com.couchbase.client.CouchbaseClient client, ForwardIndexDocument doc)
          Inserts a ForwardIndexDocument document
static void insertSimple(com.couchbase.client.CouchbaseClient client, String key, String value, CouchBaseDataTypesHelper.DataType dataType)
          Insert a key-value pair
static String query(com.couchbase.client.CouchbaseClient client, MetaIndex meta, String bucketName, String designDocName, Map<String,CouchBaseDataTypesHelper.DataType> keys, org.gcube.indexmanagement.resourceregistry.RRadaptor rradaptor, String queryString)
          Executes the queryString and returns a gRS2 endpoint locator were the results will written.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CouchBaseHelper

public CouchBaseHelper()
Method Detail

createIndexes

public static void createIndexes(com.couchbase.client.CouchbaseClient client,
                                 String bucketName,
                                 String designDocumentName,
                                 Map<String,CouchBaseDataTypesHelper.DataType> keys)
Creates one view-index for each key. The view-index will have the name bucketName_fieldName_datatype

Parameters:
client -
bucketName -
designDocumentName -
keys -

insertSimple

public static void insertSimple(com.couchbase.client.CouchbaseClient client,
                                String key,
                                String value,
                                CouchBaseDataTypesHelper.DataType dataType)
Insert a key-value pair

Parameters:
client -
key -
value -
dataType -

insertSimple

public static void insertSimple(com.couchbase.client.CouchbaseClient client,
                                ForwardIndexDocument doc)
Inserts a ForwardIndexDocument document

Parameters:
client -
doc -

delete

public static void delete(String key,
                          CouchBaseDataTypesHelper.DataType dataType,
                          com.couchbase.client.CouchbaseClient client)
Deletes the record with the given key

Parameters:
key -
dataType -
client -

deleteDocsCouchBase

public static void deleteDocsCouchBase(com.couchbase.client.CouchbaseClient client,
                                       List<String> keys)
Deletes all the documents with key in the given keys list

Parameters:
client -
keys -

deleteCollectionCouchBase

public static Boolean deleteCollectionCouchBase(com.couchbase.client.CouchbaseClient client,
                                                String bucketName,
                                                String designDocName,
                                                Map<String,CouchBaseDataTypesHelper.DataType> keys,
                                                MetaIndex meta,
                                                String collID)
Deletes all the documents of the given collection

Parameters:
client -
keys -

collectionDocIDs

public static List<String> collectionDocIDs(com.couchbase.client.CouchbaseClient client,
                                            String bucketName,
                                            String designDocumentName,
                                            Map<String,CouchBaseDataTypesHelper.DataType> keys,
                                            String collID)
Returns the document IDs of the collection with the given ID

Parameters:
client -
bucketName -
designDocumentName -
keys -
collID -
Returns:
list of the doc IDs of the collection

commit

public static void commit(com.couchbase.client.CouchbaseClient client,
                          String bucketName,
                          String designDocumentName,
                          Map<String,CouchBaseDataTypesHelper.DataType> keys)
Executes a dummyQuery on each index to "warm" it. This warming will update the indexes so any update in the database will be reflected to the indexes and the queries will be consistent.

Parameters:
client -
bucketName -
designDocumentName -
keys -

query

public static String query(com.couchbase.client.CouchbaseClient client,
                           MetaIndex meta,
                           String bucketName,
                           String designDocName,
                           Map<String,CouchBaseDataTypesHelper.DataType> keys,
                           org.gcube.indexmanagement.resourceregistry.RRadaptor rradaptor,
                           String queryString)
Executes the queryString and returns a gRS2 endpoint locator were the results will written. The meta index is needed in order to get the presentables and the searchables fields that are known The rradaptor is used for the query parsing from BDBGcqlProcessor

Parameters:
client -
meta -
bucketName -
designDocName -
keys -
rradaptor -
queryString -
Returns:
gRS2 locator of the response

feedLocator

public static boolean feedLocator(com.couchbase.client.CouchbaseClient client,
                                  String resultSetLocation,
                                  MetaIndex meta)
                           throws gr.uoa.di.madgik.grs.reader.GRS2ReaderException,
                                  URISyntaxException
Inserts all the records that are read from the resultSetLocation gRS2 endpoint in the record, updates the meta-index and saves it

Parameters:
client -
resultSetLocation -
meta -
Returns:
true on success, false otherwise
Throws:
gr.uoa.di.madgik.grs.reader.GRS2ReaderException
URISyntaxException

initRSWriterForSearchHits

public static gr.uoa.di.madgik.grs.writer.RecordWriter<gr.uoa.di.madgik.grs.record.GenericRecord> initRSWriterForSearchHits(List<String> presentables,
                                                                                                                            List<String> projections,
                                                                                                                            org.gcube.indexmanagement.resourceregistry.RRadaptor adaptor)
                                                                                                                     throws org.gcube.indexmanagement.common.IndexException,
                                                                                                                            gr.uoa.di.madgik.grs.writer.GRS2WriterException
Creates the gRS2 writer for the given projections and presentables. It will create the definitions that are needed to write the records.

Parameters:
presentables -
projections -
adaptor -
Returns:
an initialized RecordWriter
Throws:
org.gcube.indexmanagement.common.IndexException
gr.uoa.di.madgik.grs.writer.GRS2WriterException


Copyright © 2014. All Rights Reserved.