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


Java Serializer类代码示例

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


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

示例1: fromByteBuffer

import me.prettyprint.hector.api.Serializer; //导入依赖的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: getSerializer

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Serializer<T> getSerializer(Class<?> valueClass) {
  Serializer serializer = null;
  if (valueClass.equals(Utf8.class) || valueClass.equals(CharSequence.class)) {
    serializer = CharSequenceSerializer.get();
  } else if (valueClass.equals(Boolean.class) || valueClass.equals(boolean.class)) {
    serializer = BooleanSerializer.get();
  } else if (valueClass.equals(ByteBuffer.class)) {
    serializer = ByteBufferSerializer.get();
  } else if (valueClass.equals(Double.class) || valueClass.equals(double.class)) {
    serializer = DoubleSerializer.get();
  } else if (valueClass.equals(Float.class) || valueClass.equals(float.class)) {
    serializer = FloatSerializer.get();
  } else if (valueClass.equals(Integer.class) || valueClass.equals(int.class)) {
    serializer = IntegerSerializer.get();
  } else if (valueClass.equals(Long.class) || valueClass.equals(long.class)) {
    serializer = LongSerializer.get();
  } else if (valueClass.equals(String.class)) {
    serializer = StringSerializer.get();
  } else {
    serializer = SerializerTypeInferer.getSerializer(valueClass);
  }
  return serializer;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:25,代码来源:GoraSerializerTypeInferer.java

示例3: toByteBuffer

import me.prettyprint.hector.api.Serializer; //导入依赖的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

示例4: flush

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
/**
 * Flushes the buffer.
 * 
 * @param mutator The mutator to fill with deletions.
 * @param columnFamilyName The column family (name) to delete from.
 * @param column The column to delete from.
 * @param serializer The serializer to use for the column.
 * @param dao the rdf index data access object.
 * @param <T> The type of the column key.
 * @return True if the buffer was flushed and at least one element was checked for deletion, false otherwise.
 * @throws DataAccessLayerException in case of data access failure.
 */
<T> boolean flush(
		final Mutator<byte[]> mutator, 
		final String columnFamilyName, 
		final T column, 
		final Serializer<T> serializer,
		final TripleIndexDAO dao) throws DataAccessLayerException {
	if (_candidates.size() == 0) {
		return false;
	}
	
	for (SecondaryIndexDeletionCandidate candidate : _candidates) {
		if (!dao.query(candidate.getQuery(), 1).hasNext()) {
			mutator.addDeletion(candidate.getRow(), columnFamilyName, column, serializer);
		}
	}
	
	return true;
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:31,代码来源:SecondaryIndexDeletionBuffer.java

示例5: setUp

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
@Override
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    super.setUp();
    Serializer<String> keySerializer = StringSerializer.get();
    Serializer<String> supercolumnSerializer = StringSerializer.get();
    Serializer<String> columnNameSerializer = StringSerializer.get();
    Serializer<Object> valueSerializer = StructureSerializer.get();
    SuperColumnFamilyOperations<String,String,String,Object> operations = new SuperColumnFamilyTemplate<String,String,String,Object>(
            keyspace,
            columnFamily,
            keySerializer,
            supercolumnSerializer,
            columnNameSerializer,
            valueSerializer);

    dao = new ThriftSuperStructuredDataSupport<String>(operations);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:19,代码来源:ThriftSuperStructuredDataSupportSystemTest.java

示例6: setUp

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
@Override
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    super.setUp();
    Serializer<String> keySerializer = StringSerializer.get();
    Serializer<String> columnNameSerializer = StringSerializer.get();
    Serializer<Object> valueSerializer = StructureSerializer.get();
    ColumnFamilyOperations<String,String,Object> operations = new ColumnFamilyTemplate<String,String,Object>(
            keyspace,
            columnFamily,
            keySerializer,
            columnNameSerializer,
            valueSerializer);

    dao = new ThriftStructuredDataSupport<String>(operations);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:17,代码来源:ThriftStructuredDataSupportSystemTest.java

示例7: getRowSerializerForEntity

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
private <K> RowSerializer<K, String> getRowSerializerForEntity(EntityMetadata metadata) {
    Map<String, Serializer> columnSerializers = new HashMap<String, Serializer>();

    if (metadata.getEntitySerializer() != null) {
        AbstractHerculesSerializer entitySerializer = serializerProvider.getSerializer(metadata.getEntitySerializer(), metadata.getEntityClass());
        columnSerializers.put(SERIALIZED_ENTITY_TOP_KEY, entitySerializer);
    } else {
        for (Map.Entry<String, Class> entry : metadata.getColumnClasses().entrySet()) {
            Serializer fieldSerializer = getFieldSerializer(entry.getKey(), metadata);
            columnSerializers.put(entry.getKey(), fieldSerializer);
        }
    }

    columnSerializers.put(METADATA_COLUMN_NAME, BytesArraySerializer.get());

    return new ColumnRowSerializer<K, String>(this.<K>getPrimaryKeySerializer(metadata), StringSerializer.get(), columnSerializers);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:18,代码来源:EntityManager.java

示例8: insertCollectionIndex

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
private <K, T> void insertCollectionIndex(String columnFamily, Set<K> indexRowKeys, Serializer<K> indexRowKeySerializer, T indexValue, Serializer<T> indexValueSerializer, DataOperationsProfile dataOperationsProfile) {
    Map<K, Map<T, Object>> multirowInsert = new HashMap<K, Map<T, Object>>();
    Map<T, Object> columns = new HashMap<T, Object>();
    columns.put(indexValue, new byte[0]);

    Map<K, Map<T, Integer>> ttls = new HashMap<K, Map<T, Integer>>();
    Map<T, Integer> emptyTTL = new HashMap<T, Integer>();
    emptyTTL.put(indexValue, DataDriver.EMPTY_TTL);

    for (K key : indexRowKeys) {
        multirowInsert.put(key, new HashMap<T, Object>(columns));
        ttls.put(key, new HashMap<T, Integer>(emptyTTL));
    }

    dataDriver.insert(hercules.getKeyspace(), columnFamily, dataOperationsProfile,
            new ByteArrayRowSerializer<K, T>(indexRowKeySerializer, indexValueSerializer), multirowInsert, ttls);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:18,代码来源:IndexManager.java

示例9: delete

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
@Override
public <R, T> void delete(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, Map<R, Iterable<T>> values) {
    Serializer<R> rowKeySerializer = rowSerializer.getRowKeySerializer();

    Mutator<ByteBuffer> mutator = HFactory.createMutator(keyspace, ByteBufferSerializer.get());

    for (R rowKey : values.keySet()) {
        ByteBuffer serializedRowKey = rowKeySerializer.toByteBuffer(rowKey);
        if (serializedRowKey == null) {
            continue;
        }

        for (T topKey : values.get(rowKey)) {
            mutator.addDeletion(serializedRowKey, columnFamily, topKey, rowSerializer.getTopKeySerializer());
        }
    }

    executeDeletionMutator(columnFamily, dataOperationsProfile, mutator);
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:20,代码来源:ThriftDataDriver.java

示例10: getSerializer

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Serializer<T> getSerializer(Class<?> valueClass) {
  Serializer serializer = null;
  if (valueClass.equals(Utf8.class)) {
    serializer = Utf8Serializer.get();
  } else if (valueClass.equals(Boolean.class) || valueClass.equals(boolean.class)) {
    serializer = BooleanSerializer.get();
  } else if (valueClass.equals(ByteBuffer.class)) {
    serializer = ByteBufferSerializer.get();
  } else if (valueClass.equals(Double.class) || valueClass.equals(double.class)) {
    serializer = DoubleSerializer.get();
  } else if (valueClass.equals(Float.class) || valueClass.equals(float.class)) {
    serializer = FloatSerializer.get();
  } else if (valueClass.equals(Integer.class) || valueClass.equals(int.class)) {
    serializer = IntegerSerializer.get();
  } else if (valueClass.equals(Long.class) || valueClass.equals(long.class)) {
    serializer = LongSerializer.get();
  } else if (valueClass.equals(String.class)) {
    serializer = StringSerializer.get();
  } else {
    serializer = SerializerTypeInferer.getSerializer(valueClass);
  }
  return serializer;
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:25,代码来源:GoraSerializerTypeInferer.java

示例11: toByteBuffer

import me.prettyprint.hector.api.Serializer; //导入依赖的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

示例12: WriteBuffer

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
public WriteBuffer(Keyspace keyspace, String cfName,
		int writeDelay, int maxWriteSize, Serializer<RowKeyType> keySerializer,
		Serializer<ColumnKeyType> columnKeySerializer,
		Serializer<ValueType> valueSerializer,
		WriteBufferStats stats,
		ReentrantLock mutatorLock,
		int threadCount,
		int jobQueueSize)
{
	m_executorService = new ThreadPoolExecutor(threadCount, threadCount,
			0L, TimeUnit.MILLISECONDS,
			new LinkedBlockingQueue<Runnable>(jobQueueSize),
			new ThreadFactoryBuilder().setNameFormat("WriteBuffer-"+cfName+"-%d").build());

	m_keyspace = keyspace;
	m_cfName = cfName;
	m_writeDelay = writeDelay;
	m_initialMaxBufferSize = m_maxBufferSize = maxWriteSize;
	m_rowKeySerializer = keySerializer;
	m_columnKeySerializer = columnKeySerializer;
	m_valueSerializer = valueSerializer;
	m_writeStats = stats;
	m_mutatorLock = mutatorLock;

	m_buffer = new ArrayList<>();
	m_mutator = new MutatorImpl<>(keyspace, keySerializer);
	m_writeThread = new Thread(this, "WriteBuffer Scheduler for "+cfName);
	m_writeThread.start();
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:30,代码来源:WriteBuffer.java

示例13: column

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
public static <A, B> HColumn<A, B> column( final A name, final B value )
{

    return HFactory.createColumn( name, //
                                  value, //
                                  (Serializer<A>) SerializerTypeInferer.getSerializer( name ), //
                                  (Serializer<B>) SerializerTypeInferer.getSerializer( value ) );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:9,代码来源:CassandraUtils.java

示例14: flushIfFull

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
/**
 * Flushes the buffer if it is full.
 * 
 * @param mutator The mutator to fill with deletions.
 * @param columnFamilyName The column (name) family to delete from.
 * @param column The column to delete from.
 * @param serializer The serializer to use for the column.
 * @param dao the rdf index data access object.
 * @param <T> The type of the column key.
 * @return True if the buffer was flushed and at least one element was checked for deletion, false otherwise.
 * @throws DataAccessLayerException in case of data access failure.
 */
<T> boolean flushIfFull(
		final Mutator<byte[]> mutator, 
		final String columnFamilyName, 
		final T column, 
		final Serializer<T> serializer,
		final TripleIndexDAO dao) throws DataAccessLayerException {
	if (_candidates.size() >= _capacity) {
		return flush(mutator, columnFamilyName, column, serializer, dao);
	} else {
		return false;
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:25,代码来源:SecondaryIndexDeletionBuffer.java

示例15: init

import me.prettyprint.hector.api.Serializer; //导入依赖的package包/类
private void init(Serializer<K> keySerializer) {
	this.keySerializer = keySerializer;
	consistencyLevel = new HectorConsistencyPolicy(columnFamily);

	configureHectorSpecificProperties();
	reConfigureParameters();
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:8,代码来源:HectorBasedHecubaClientManager.java


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