当前位置: 首页>>代码示例>>Java>>正文


Java GoraSerializerTypeInferer类代码示例

本文整理汇总了Java中org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer的典型用法代码示例。如果您正苦于以下问题:Java GoraSerializerTypeInferer类的具体用法?Java GoraSerializerTypeInferer怎么用?Java GoraSerializerTypeInferer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GoraSerializerTypeInferer类属于org.apache.gora.cassandra.serializers包,在下文中一共展示了GoraSerializerTypeInferer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromByteBuffer

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
protected Object fromByteBuffer(Schema schema, ByteBuffer byteBuffer) {
  Object value = null;
  Serializer<?> serializer = GoraSerializerTypeInferer.getSerializer(schema);
  if (serializer == null) {
    LOG.warn("Schema: " + schema.getName() + " is not supported. No serializer "
        + "could be found. Please report this to [email protected]");
  } else {
    value = serializer.fromByteBuffer(byteBuffer);
    if (schema.getType().equals(Type.RECORD) || schema.getType().equals(Type.MAP) ){
      try {
        value = AvroSerializerUtil.deserializer(value, schema);
      } catch (IOException e) {
        LOG.warn(field.name() + " named field could not be deserialized.");
      }
    }
  }
  return value;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:19,代码来源:CassandraColumn.java

示例2: toByteBuffer

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
/**
 * Serialize value to ByteBuffer using 
 * {@link org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer#getSerializer(Object)}.
 * @param value the member value {@link java.lang.Object}.
 * @return ByteBuffer object
 */
public ByteBuffer toByteBuffer(Object value) {
  ByteBuffer byteBuffer = null;
  Serializer<Object> serializer = GoraSerializerTypeInferer.getSerializer(value);
  if (serializer == null) {
    LOG.warn("Serializer not found for: " + value.toString());
  }
  else {
    LOG.debug(serializer.getClass() + " selected as appropriate Serializer.");
    byteBuffer = serializer.toByteBuffer(value);
  }
  if (byteBuffer == null) {
    LOG.warn("Serialization value for: " + value.getClass().getName() + " = null");
  }
  return byteBuffer;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:22,代码来源:CassandraClient.java

示例3: initialize

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
public void initialize(Class<K> keyClass, Class<T> persistentClass) throws Exception {
  this.keyClass = keyClass;

  // get cassandra mapping with persistent class
  this.persistentClass = persistentClass;
  this.cassandraMapping = CassandraMappingManager.getManager().get(persistentClass);
  // LOG.info("persistentClass=" + persistentClass.getName() + " -> cassandraMapping=" + cassandraMapping);

  this.cluster = HFactory.getOrCreateCluster(this.cassandraMapping.getClusterName(), new CassandraHostConfigurator(this.cassandraMapping.getHostName()));
  
  // add keyspace to cluster
  checkKeyspace();
  
  // Just create a Keyspace object on the client side, corresponding to an already existing keyspace with already created column families.
  this.keyspace = HFactory.createKeyspace(this.cassandraMapping.getKeyspaceName(), this.cluster);
  
  this.keySerializer = GoraSerializerTypeInferer.getSerializer(keyClass);
  this.mutator = HFactory.createMutator(this.keyspace, this.keySerializer);
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:20,代码来源:CassandraClient.java

示例4: toByteBuffer

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
/**
 * Serialize value to ByteBuffer.
 * @param value the member value
 * @return ByteBuffer object
 */
@SuppressWarnings("unchecked")
public ByteBuffer toByteBuffer(Object value) {
  ByteBuffer byteBuffer = null;
  Serializer serializer = GoraSerializerTypeInferer.getSerializer(value);
  if (serializer == null) {
    LOG.info("Serializer not found for: " + value.toString());
  }
  else {
    byteBuffer = serializer.toByteBuffer(value);
  }

  if (byteBuffer == null) {
    LOG.info("value class=" + value.getClass().getName() + " value=" + value + " -> null");
  }
  
  return byteBuffer;
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:23,代码来源:CassandraClient.java

示例5: initialize

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
/**
 * Given our key, persistentClass from 
 * {@link org.apache.gora.cassandra.store.CassandraStore#initialize(Class, Class, Properties)}
 * we make best efforts to dictate our data model. 
 * We make a quick check within {@link org.apache.gora.cassandra.store.CassandraClient#checkKeyspace(String)
 * to see if our keyspace has already been invented, this simple check prevents us from 
 * recreating the keyspace if it already exists. 
 * We then simple specify (based on the input keyclass) an appropriate serializer
 * via {@link org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer} before
 * defining a mutator from and by which we can mutate this object.
 * @param keyClass the Key by which we wish o assign a record object
 * @param persistentClass the generated {@link org.apache.org.gora.persistency.Peristent} bean representing the data.
 * @param properties key value pairs from gora.properties
 * @throws Exception
 */
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws Exception {
  this.keyClass = keyClass;

  // get cassandra mapping with persistent class
  this.persistentClass = persistentClass;
  this.cassandraMapping = CassandraMappingManager.getManager().get(persistentClass);
  Map<String, String> accessMap = null;
  if (properties != null) {
    String username = properties
        .getProperty("gora.cassandrastore.username");
    if (username != null) {
      accessMap = new HashMap<>();
      accessMap.put("username", username);
      String password = properties
          .getProperty("gora.cassandrastore.password");
      if (password != null) {
        accessMap.put("password", password);
      }
    }
  }

  this.cluster = HFactory.getOrCreateCluster(this.cassandraMapping.getClusterName(), 
      new CassandraHostConfigurator(this.cassandraMapping.getHostName()), accessMap);
  
  // add keyspace to cluster
  checkKeyspace();
  
  // Just create a Keyspace object on the client side, corresponding to an already 
  // existing keyspace with already created column families.
  this.keyspace = HFactory.createKeyspace(this.cassandraMapping.getKeyspaceName(), this.cluster);
  
  this.keySerializer = GoraSerializerTypeInferer.getSerializer(keyClass);
  if (this.keySerializer == null)
    LOG.error("Serializer for " + keyClass + " not found.");
  this.mutator = HFactory.createMutator(this.keyspace, this.keySerializer);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:52,代码来源:CassandraClient.java

示例6: fromByteBuffer

import org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer; //导入依赖的package包/类
protected Object fromByteBuffer(Schema schema, ByteBuffer byteBuffer) {
  Object value = null;
  Serializer<?> serializer = GoraSerializerTypeInferer.getSerializer(schema);
  if (serializer == null) {
    LOG.info("Schema is not supported: " + schema.toString());
  } else {
    value = serializer.fromByteBuffer(byteBuffer);
  }
  return value;
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:11,代码来源:CassandraColumn.java


注:本文中的org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。