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


Java TypeCodec类代码示例

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


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

示例1: buildColumn

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
private TableColumn<ConnectionData, String> buildColumn(String name, int columnWidth, Function<ConnectionData,
        String> extractor) {
    TableColumn<ConnectionData, String> column = new TableColumn<>();
    Label columnLabel = new Label(name);
    column.setCellFactory(cellFactory(TypeCodec.varchar()));

    column.setCellValueFactory(param -> {
        String field = extractor.apply(param.getValue());
        return new SimpleObjectProperty<>(field);
    });

    column.setOnEditCommit(event -> log.info("edit"));
    column.setGraphic(columnLabel);
    column.setMinWidth(columnWidth);
    return column;
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:17,代码来源:ConnectionManager.java

示例2: initializeUDTs

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
private static void initializeUDTs(Session session) {
  Schema.ensureExists(DEFAULT_KEYSPACE + "_udts", session);
  MappingManager mapping = new MappingManager(session);

  // The UDTs are hardcoded against the zipkin keyspace.
  // If a different keyspace is being used the codecs must be re-applied to this different keyspace
  TypeCodec<TraceIdUDT> traceIdCodec = mapping.udtCodec(TraceIdUDT.class);
  TypeCodec<EndpointUDT> endpointCodec = mapping.udtCodec(EndpointUDT.class);
  TypeCodec<AnnotationUDT> annoCodec = mapping.udtCodec(AnnotationUDT.class);
  TypeCodec<BinaryAnnotationUDT> bAnnoCodec = mapping.udtCodec(BinaryAnnotationUDT.class);

  KeyspaceMetadata keyspace =
      session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());

  session.getCluster().getConfiguration().getCodecRegistry()
      .register(
          new TypeCodecImpl(keyspace.getUserType("trace_id"), TraceIdUDT.class, traceIdCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("endpoint"), EndpointUDT.class, endpointCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("annotation"), AnnotationUDT.class, annoCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("binary_annotation"), BinaryAnnotationUDT.class,
              bAnnoCodec));
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:26,代码来源:DefaultSessionFactory.java

示例3: verifyNextRow

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
private String verifyNextRow(ResultSet rs) {
    String rowid = null;
    for (int col=0; col < 137; col++) {
        Row row = rs.one();
        assertNotNull(row);

        if (rowid == null) {
            rowid = row.get("rowid", TypeCodec.varchar());
        } else {
            assertEquals(row.get("rowid", TypeCodec.varchar()), rowid);
        }

        assertEquals((long) row.get("col", TypeCodec.bigint()), col);
        assertEquals( row.get("data", TypeCodec.blob()).asIntBuffer().get(), col);
    }

    return rowid;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:19,代码来源:AdaptiveResultSetTest.java

示例4: registerCodecs

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
private void registerCodecs()
{
  complexTypeCodecs = getCodecsForUserDefinedTypes();
  if (complexTypeCodecs != null) {
    CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();
    if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion().toInt() < 4) {
      LOG.error("Custom codecs are not supported for protocol version < 4");
      throw new RuntimeException("Custom codecs are not supported for protocol version < 4");
    }
    for (String typeCodecStr : complexTypeCodecs.keySet()) {
      TypeCodec codec = complexTypeCodecs.get(typeCodecStr);
      registry.register(codec);
      userDefinedTypesClass.put(typeCodecStr, codec.getJavaType().getRawType());
    }
  } else {
    complexTypeCodecs = new HashMap<>();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:AbstractUpsertOutputOperator.java

示例5: getCodecsForUserDefinedTypes

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public Map<String, TypeCodec> getCodecsForUserDefinedTypes()
{
  Map<String, TypeCodec> allCodecs = new HashMap<>();
  CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();

  UserType addressType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName())
      .getUserType("address");
  TypeCodec<UDTValue> addressTypeCodec = codecRegistry.codecFor(addressType);
  AddressCodec addressCodec = new AddressCodec(addressTypeCodec, Address.class);
  allCodecs.put("currentaddress", addressCodec);

  UserType userFullNameType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName())
      .getUserType("fullname");
  TypeCodec<UDTValue> userFullNameTypeCodec = codecRegistry.codecFor(userFullNameType);
  FullNameCodec fullNameCodec = new FullNameCodec(userFullNameTypeCodec, FullName.class);
  allCodecs.put("username", fullNameCodec);

  return allCodecs;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:UserUpsertOperator.java

示例6: cellFactory

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
public static <S, T> Callback<TableColumn<S, T>, TableCell<S, T>> cellFactory(
        TypeCodec<T> codec) {
    return TextFieldTableCell.forTableColumn(new StringConverter<T>() {
        @Override
        public String toString(T object) {
            return codec.format(object);
        }

        @Override
        public T fromString(String string) {
            return codec.parse(string);
        }
    });
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:15,代码来源:UIUtil.java

示例7: test

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public boolean test(DataObject data) {
    TypeCodec<?> typeCodec = getColumnCodec(data.get(getField()));

    Object expected = typeCodec.parse(getValue());
    Object actual = data.get(getField());
    if (expected instanceof Comparable && actual instanceof Comparable) {
        //noinspection unchecked
        return Comparable.class.cast(actual).compareTo(expected) != 0;
    } else {
        return expected != actual;
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:14,代码来源:NePredicate.java

示例8: test

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public boolean test(DataObject data) {
    TypeCodec<?> typeCodec = getColumnCodec(data.get(getField()));

    Object expected = typeCodec.parse(getValue());
    Object actual = data.get(getField());
    if (expected instanceof Comparable && actual instanceof Comparable) {
        //noinspection unchecked
        return Comparable.class.cast(actual).compareTo(expected) < 0;
    } else {
        return false;
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:14,代码来源:LtPredicate.java

示例9: test

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public boolean test(DataObject data) {
    TypeCodec<?> typeCodec = getColumnCodec(data.get(getField()));

    Object expected = typeCodec.parse(getValue());
    Object actual = data.get(getField());
    if (expected instanceof Comparable && actual instanceof Comparable) {
        //noinspection unchecked
        return Comparable.class.cast(actual).compareTo(expected) <= 0;
    } else {
        return false;
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:14,代码来源:LePredicate.java

示例10: test

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public boolean test(DataObject data) {
    TypeCodec<?> typeCodec = getColumnCodec(data.get(getField()));

    Object expected = typeCodec.parse(getValue());
    Object actual = data.get(getField());
    if (expected instanceof Comparable && actual instanceof Comparable) {
        //noinspection unchecked
        return Comparable.class.cast(actual).compareTo(expected) >= 0;
    } else {
        return false;
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:14,代码来源:GePredicate.java

示例11: test

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
@Override
public boolean test(DataObject data) {
    TypeCodec<?> typeCodec = getColumnCodec(data.get(getField()));

    Object expected = typeCodec.parse(getValue());
    Object actual = data.get(getField());
    if (expected instanceof Comparable && actual instanceof Comparable) {
        //noinspection unchecked
        return Comparable.class.cast(actual).compareTo(expected) > 0;
    } else {
        return false;
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:14,代码来源:GtPredicate.java

示例12: registerCodecIfNotFound

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
private void registerCodecIfNotFound(CodecRegistry registry, TypeCodec<?> codec) {
    try {
        registry.codecFor(codec.getCqlType(), codec.getJavaType());
    } catch (CodecNotFoundException e) {
        registry.register(codec);
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:8,代码来源:CassandraAbstractDao.java

示例13: codecsFor

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
static TypeCodec<Object>[] codecsFor(DataType[] dataType)
{
    TypeCodec<Object>[] codecs = new TypeCodec[dataType.length];
    for (int i = 0; i < dataType.length; i++)
        codecs[i] = codecFor(dataType[i]);
    return codecs;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:UDHelper.java

示例14: javaTypes

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
/**
 * Construct an array containing the Java classes for the given Java Driver {@link com.datastax.driver.core.DataType}s.
 *
 * @param dataTypes  array with UDF argument types
 * @param calledOnNullInput whether to allow {@code null} as an argument value
 * @return array of same size with UDF arguments
 */
public static Class<?>[] javaTypes(TypeCodec<Object>[] dataTypes, boolean calledOnNullInput)
{
    Class<?>[] paramTypes = new Class[dataTypes.length];
    for (int i = 0; i < paramTypes.length; i++)
    {
        Class<?> clazz = asJavaClass(dataTypes[i]);
        if (!calledOnNullInput)
        {
            // only care about classes that can be used in a data type
            if (clazz == Integer.class)
                clazz = int.class;
            else if (clazz == Long.class)
                clazz = long.class;
            else if (clazz == Byte.class)
                clazz = byte.class;
            else if (clazz == Short.class)
                clazz = short.class;
            else if (clazz == Float.class)
                clazz = float.class;
            else if (clazz == Double.class)
                clazz = double.class;
            else if (clazz == Boolean.class)
                clazz = boolean.class;
        }
        paramTypes[i] = clazz;
    }
    return paramTypes;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:36,代码来源:UDHelper.java

示例15: serialize

import com.datastax.driver.core.TypeCodec; //导入依赖的package包/类
public static ByteBuffer serialize(TypeCodec<?> codec, int protocolVersion, Object value)
{
    if (!codec.getJavaType().getRawType().isAssignableFrom(value.getClass()))
        throw new InvalidTypeException("Invalid value for CQL type " + codec.getCqlType().getName().toString());

    return ((TypeCodec)codec).serialize(value, ProtocolVersion.fromInt(protocolVersion));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:UDHelper.java


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