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

com.netflix.astyanax.thrift.ThriftCqlFactoryResolver Maven / Gradle / Ivy

There is a newer version: 3.10.2
Show newest version
package com.netflix.astyanax.thrift;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.netflix.astyanax.AstyanaxConfiguration;

public class ThriftCqlFactoryResolver {
    private static final Pattern VERSION_REGEX = Pattern.compile("^([0-9])+\\.([0-9])+(.*)");
    
    public static ThriftCqlFactory createFactory(AstyanaxConfiguration config) {
        if (config.getTargetCassandraVersion() != null) {
            Matcher m = VERSION_REGEX.matcher(config.getTargetCassandraVersion());
            if (m.matches()) {
                int major = Integer.parseInt(m.group(1));
                int minor = Integer.parseInt(m.group(2));
                if (major > 1 || (major == 1 && minor >= 2)) {
                    return new ThriftCql3Factory();
                }
            }
        }
        return new ThriftCql2Factory();
    }    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy