All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flipkart.hbaseobjectmapper.HBObjectMapperFactory Maven / Gradle / Ivy

Go to download

HBase ORM is a light-weight, thread-safe and performant library that enables: [1] object-oriented access of HBase rows (Data Access Object) with minimal code and good testability. [2] reading from and/or writing to HBase tables in Hadoop MapReduce jobs. This can also be used as an ORM for Bigtable.

The newest version!
package com.flipkart.hbaseobjectmapper;

import com.flipkart.hbaseobjectmapper.codec.Codec;

import java.util.HashMap;
import java.util.Map;

/**
 * Maintains one instance of {@link HBObjectMapper} class. For internal use only.
 */
class HBObjectMapperFactory {
    /**
     * Default instance of {@link HBObjectMapper}
     */
    private static HBObjectMapper defaultHBObjectMapper;

    private static final Map, HBObjectMapper> customHBObjectMappers = new HashMap<>();

    protected HBObjectMapperFactory() {
        throw new UnsupportedOperationException();
    }

    static synchronized HBObjectMapper construct() {
        if (defaultHBObjectMapper == null) {
            defaultHBObjectMapper = new HBObjectMapper();
        }
        return defaultHBObjectMapper;
    }

    static synchronized HBObjectMapper construct(Codec codec) {
        HBObjectMapper customHBObjectMapper = customHBObjectMappers.get(codec.getClass());
        if (customHBObjectMapper == null) {
            customHBObjectMapper = new HBObjectMapper(codec);
            customHBObjectMappers.put(codec.getClass(), customHBObjectMapper);
        }
        return customHBObjectMapper;
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy