Package com.impetus.kundera.cache

Examples of com.impetus.kundera.cache.ElementCollectionCacheManager


    private Document updateOrCreateIndexCollectionTypeEmbeddedObject(EntityMetadata metadata,
            final MetamodelImpl metaModel, Object entity, String parentId, Class<?> clazz, boolean isUpdate,
            Document document, Object embeddedObject, Object rowKey, String attributeName,
            EmbeddableType embeddableAttribute)
    {
        ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();
        // Check whether it's first time insert or updation
        if (ecCacheHandler.isCacheEmpty())
        { // First time
          // insert
            int count = 0;
            for (Object obj : (Collection<?>) embeddedObject)
            {
                String elementCollectionObjectName = attributeName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + count;

                document = prepareDocumentForSuperColumn(metadata, entity, elementCollectionObjectName, parentId, clazz);
                createSuperColumnDocument(metadata, entity, document, obj, embeddableAttribute, metaModel);
                if (isUpdate)
                {
                    updateDocument(parentId, document, null);

                }
                else
                {
                    indexDocument(metadata, document);
                }
                count++;
            }
        }
        else
        {
            // Updation, Check whether this object is already in
            // cache, which means we already have an embedded
            // column
            // Otherwise we need to generate a fresh embedded
            // column name
            int lastEmbeddedObjectCount = ecCacheHandler.getLastElementCollectionObjectCount(rowKey);
            for (Object obj : (Collection<?>) embeddedObject)
            {
                document = indexCollectionObject(metadata, entity, parentId, clazz, isUpdate, rowKey, attributeName,
                        embeddableAttribute, ecCacheHandler, lastEmbeddedObjectCount, obj, metaModel);
            }
View Full Code Here


                    Map<String, Object> columnNameToValue = new HashMap<String, Object>();
                    if (column.isCollection())
                    {
                        String dynamicCFName = null;

                        ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();
                        // Check whether it's first time insert or updation
                        if (ecCacheHandler.isCacheEmpty())
                        { // First time insert
                            int count = 0;
                            for (Object obj : (Collection) columnFamilyObject)
                            {
                                String embeddableColumFamilyName = columFamilyTableName;
                                Map<Map<String, Class<?>>, HBaseDataWrapper> embeDaableDataWrappers = new HashMap<Map<String, Class<?>>, HBaseDataWrapper>();
                                for (Attribute attribute : columns)
                                {
                                    embeddableColumFamilyName = ((AbstractAttribute) attribute).getTableName() != null ? ((AbstractAttribute) attribute)
                                            .getTableName() : columFamilyTableName;
                                    String columnName = columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER
                                            + ((AbstractAttribute) attribute).getJPAColumnName()
                                            + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + count;

                                    Map<String, Class<?>> embeddableMap = new HashMap<String, Class<?>>();
                                    embeddableMap.put(embeddableColumFamilyName, obj.getClass());

                                    embeDaableDataWrappers = getEmbeddableHBaseWrapperObj(rowId, obj,
                                            embeddableColumFamilyName, embeDaableDataWrappers, persistentData,
                                            embeddableMap);

                                    HBaseDataWrapper embeddableColumnWrapper = embeDaableDataWrappers
                                            .get(embeddableMap);
                                    embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);

                                    embeddableColumnWrapper.addColumn(columnName, attribute);
                                    embeddableColumnWrapper.addValue(columnName,
                                            PropertyAccessorHelper.getObject(obj, (Field) attribute.getJavaMember()));
                                }
                                count++;
                            }
                        }
                        else
                        {
                            // Updation
                            // Check whether this object is already in cache,
                            // which
                            // means we already have a column family with that
                            // name
                            // Otherwise we need to generate a fresh column
                            // family
                            // name
                            int lastEmbeddedObjectCount = ecCacheHandler.getLastElementCollectionObjectCount(rowId);
                            for (Object obj : (Collection) columnFamilyObject)
                            {
                                String embeddableColumFamilyName = columFamilyTableName;
                                dynamicCFName = ecCacheHandler.getElementCollectionObjectName(rowId, obj);
                                if (dynamicCFName == null)
                                { // Fresh row
                                    ++lastEmbeddedObjectCount;
                                    Map<Map<String, Class<?>>, HBaseDataWrapper> embeDaableDataWrappers = new HashMap<Map<String, Class<?>>, HBaseDataWrapper>();
                                    for (Attribute attribute : columns)
                                    {
                                        embeddableColumFamilyName = ((AbstractAttribute) attribute).getTableName() != null ? ((AbstractAttribute) attribute)
                                                .getTableName() : columFamilyTableName;
                                        String columnName = columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER
                                                + ((AbstractAttribute) attribute).getJPAColumnName()
                                                + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + (lastEmbeddedObjectCount);

                                        Map<String, Class<?>> embeddableMap = new HashMap<String, Class<?>>();
                                        embeddableMap.put(embeddableColumFamilyName, obj.getClass());

                                        embeDaableDataWrappers = getEmbeddableHBaseWrapperObj(rowId, obj,
                                                embeddableColumFamilyName, embeDaableDataWrappers, persistentData,
                                                embeddableMap);

                                        HBaseDataWrapper embeddableColumnWrapper = embeDaableDataWrappers
                                                .get(embeddableMap);
                                        embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);

                                        embeddableColumnWrapper.addColumn(columnName, attribute);
                                        embeddableColumnWrapper.addValue(columnName, PropertyAccessorHelper.getObject(
                                                obj, (Field) attribute.getJavaMember()));
                                    }
                                }
                            }
                            // Clear embedded collection cache for GC
                            ecCacheHandler.clearCache();
                        }
                    }
                    else
                    {
View Full Code Here

            {
                continue;
            }
            if (embeddedObject instanceof Collection)
            {
                ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();

                for (Object obj : (Collection) embeddedObject)
                {
                    for (Object column : embeddedColumn.getAttributes())
                    {

                        Attribute columnAttribute = (Attribute) column;
                        String columnName = columnAttribute.getName();
                        if (!MetadataUtils.isColumnInEmbeddableIndexable(embeddedField, columnName))
                        {
                            continue;
                        }
                        // Column Value
                        String id = (String) CassandraDataTranslator.decompose(
                                ((AbstractAttribute) m.getIdAttribute()).getBindableJavaType(), rowKey, false);
                        String superColumnName = ecCacheHandler.getElementCollectionObjectName(id, obj);

                        ThriftRow tr = constructIndexTableThriftRow(columnFamily, embeddedFieldName, obj,
                                columnAttribute, rowKey, superColumnName);
                        if (tr != null)
                        {
View Full Code Here

        // would simply be embedded as ONE super column.
        String superColumnName = null;
        if (superColumnObject != null && superColumnObject instanceof Collection)
        {

            ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();

            // Check whether it's first time insert or updation
            if (ecCacheHandler.isCacheEmpty())
            { // First time insert
                int count = 0;
                for (Object obj : (Collection) superColumnObject)
                {
                    superColumnName = ((AbstractAttribute) embeddableAttrib).getJPAColumnName()
                            + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + count;

                    if (m.isCounterColumnType())
                    {
                        CounterSuperColumn thriftSuperColumn = (CounterSuperColumn) buildThriftCounterSuperColumn(
                                m.getTableName(), superColumnName, superColumn, obj).get(m.getTableName());
                        tr.addCounterSuperColumn(thriftSuperColumn);
                    }
                    else
                    {
                        SuperColumn thriftSuperColumn = (SuperColumn) buildThriftSuperColumn(m.getTableName(),
                                superColumnName, timestamp2, superColumn, obj).get(m.getTableName());
                        tr.addSuperColumn(thriftSuperColumn);
                    }
                    ecCacheHandler.addElementCollectionCacheMapping(id, obj, superColumnName);
                    count++;
                }
            }
            else
            {
                // Updation, Check whether this object is already in cache,
                // which means we already have a super column
                // Otherwise we need to generate a fresh embedded column
                // name
                int lastEmbeddedObjectCount = ecCacheHandler.getLastElementCollectionObjectCount(id);
                for (Object obj : (Collection) superColumnObject)
                {
                    superColumnName = ecCacheHandler.getElementCollectionObjectName(id, obj);
                    if (superColumnName == null)
                    { // Fresh row
                        superColumnName = ((AbstractAttribute) embeddableAttrib).getJPAColumnName()
                                + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + (++lastEmbeddedObjectCount);
                    }
                    Map<String, Object> thriftSuperColumn = buildThriftSuperColumn(timestamp2, m, id, superColumn,
                            superColumnName, obj);
                    if (m.isCounterColumnType())
                    {
                        tr.addCounterSuperColumn((CounterSuperColumn) thriftSuperColumn.get(m.getTableName()));
                    }
                    else
                    {
                        tr.addSuperColumn((SuperColumn) thriftSuperColumn.get(m.getTableName()));
                    }
                    ecCacheHandler.addElementCollectionCacheMapping(id, obj, superColumnName);
                }
            }
        }
        else if (superColumnObject != null)
        {
View Full Code Here

TOP

Related Classes of com.impetus.kundera.cache.ElementCollectionCacheManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.