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

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

The newest version!
package com.netflix.astyanax.thrift;

import java.nio.ByteBuffer;
import java.util.Map.Entry;

import org.apache.cassandra.thrift.CqlMetadata;

import com.netflix.astyanax.Serializer;
import com.netflix.astyanax.cql.CqlSchema;
import com.netflix.astyanax.serializers.ComparatorType;
import com.netflix.astyanax.serializers.StringSerializer;

public class ThriftCqlSchema implements CqlSchema {
    private final CqlMetadata schema;
    
    public ThriftCqlSchema(CqlMetadata schema) {
        this.schema = schema;
        
        System.out.println("Name:  " + schema.getDefault_name_type());
        System.out.println("Value: " + schema.getDefault_value_type());
        
        for (Entry type : schema.getName_types().entrySet()) {
            Serializer serializer = ComparatorType.valueOf(type.getValue().toUpperCase()).getSerializer();
            System.out.println("Name: " + type.getValue() + " = " + serializer.getString(type.getKey()));
        }
        
        for (Entry value : schema.getValue_types().entrySet()) {
            Serializer serializer = StringSerializer.get(); // ComparatorType.valueOf(value.getValue().toUpperCase()).getSerializer();
            System.out.println("Type: " + value.getValue() + " = " + ((value.getKey() == null) ? "null" : serializer.getString(value.getKey())));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy