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


Java Serializer.toByteBuffer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: insert

import me.prettyprint.hector.api.Serializer; //导入方法依赖的package包/类
@Override
public <R, T> void insert(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, R rowKey, T topKey, Object value, int ttl) {
    Serializer<R> rowKeySerializer = rowSerializer.getRowKeySerializer();

    ByteBuffer serializedRowKey = rowKeySerializer.toByteBuffer(rowKey);
    if (serializedRowKey == null) {
        return;
    }

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

    StopWatch monitor = monitoring.start(HerculesMonitoringGroup.HERCULES_DD, "Insert " + columnFamily);

    int serializedDataSize = 0;
    try {
        if (value == null) {
            mutator.delete(serializedRowKey, columnFamily, topKey, rowSerializer.getTopKeySerializer());
        } else {
            Serializer serializer = rowSerializer.hasValueSerializer(topKey) ? rowSerializer.getValueSerializer(topKey) : getSerializerForObject(value);
            ByteBuffer serializedValue = serializer.toByteBuffer(value);
            serializedDataSize += serializedValue.remaining();

            HColumn<T, ByteBuffer> column;
            if (ttl > 0) {
                column = HFactory.createColumn(topKey, serializedValue, ttl, rowSerializer.getTopKeySerializer(), ByteBufferSerializer.get());
            } else {
                column = HFactory.createColumn(topKey, serializedValue, rowSerializer.getTopKeySerializer(), ByteBufferSerializer.get());
            }
            mutator.insert(serializedRowKey, columnFamily, column);
        }
    } finally {
        long time = monitor.stop();
        if (dataOperationsProfile != null) {
            dataOperationsProfile.ms += time;
            dataOperationsProfile.bytes += serializedDataSize;
            dataOperationsProfile.dbQueries++;
        }
    }
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:40,代码来源:ThriftDataDriver.java


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