com.datastax.driver.core.RegularStatement.hasValues()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中com.datastax.driver.core.RegularStatement.hasValues方法的一些代码示例,展示了RegularStatement.hasValues的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RegularStatement.hasValues方法的具体详情如下:
包路径:com.datastax.driver.core.RegularStatement
类名称:RegularStatement
方法名:hasValues

RegularStatement.hasValues介绍

[英]Whether or not this statement has values, that is if getValues will return nullor not.

This method calls #hasValues(CodecRegistry) with ProtocolVersion#NEWEST_SUPPORTED. Whether you should use this or the other variant depends on the type of statement this is called on:

  • for a SimpleStatement or SchemaStatement, the codec registry isn't actually needed, so it's always safe to use this method;
  • for a BuiltStatement you can use this method if you use no custom codecs, or if your custom codecs are registered with the default registry. Otherwise, use the other method and provide the registry that contains your codecs (see BuiltStatement for more explanations on why this is so);
  • for a BatchStatement, use the first rule if it contains no built statements, or the second rule otherwise.
    [中]该语句是否有值,即getValues是否返回Null。
    此方法调用支持ProtocolVersion#最新#U的#hasValues(CodecRegistry)。是否应使用此变量或其他变量取决于调用此变量的语句类型:
    *对于SimpleStatement或SchemaStatement,实际上并不需要编解码器注册表,因此使用这种方法总是安全的;
    *对于BuiltStatement,如果不使用自定义编解码器,或者自定义编解码器已在默认注册表中注册,则可以使用此方法。否则,请使用另一种方法,并提供包含编解码器的注册表(请参阅BuiltStatement以了解更多关于为什么会这样的解释);
    *对于BatchStatement,如果不包含内置语句,则使用第一条规则,否则使用第二条规则。

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Whether or not this statement has values, that is if {@code getValues} will return {@code null}
 * or not.
 *
 * <p>This method calls {@link #hasValues(CodecRegistry)} with {@link
 * ProtocolVersion#NEWEST_SUPPORTED}. Whether you should use this or the other variant depends on
 * the type of statement this is called on:
 *
 * <ul>
 *   <li>for a {@link SimpleStatement} or {@link SchemaStatement}, the codec registry isn't
 *       actually needed, so it's always safe to use this method;
 *   <li>for a {@link BuiltStatement} you can use this method if you use no custom codecs, or if
 *       your custom codecs are registered with the default registry. Otherwise, use the other
 *       method and provide the registry that contains your codecs (see {@link BuiltStatement} for
 *       more explanations on why this is so);
 *   <li>for a {@link BatchStatement}, use the first rule if it contains no built statements, or
 *       the second rule otherwise.
 * </ul>
 *
 * @return {@code false} if {@link #getValues} returns {@code null}, {@code true} otherwise.
 */
public boolean hasValues() {
 return hasValues(CodecRegistry.DEFAULT_INSTANCE);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/** {@inheritDoc} */
@Override
public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement statement) {
 if (statement.hasValues())
  throw new IllegalArgumentException("A statement to prepare should not have values");
 final CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
 ListenableFuture<PreparedStatement> prepared =
   prepareAsync(statement.getQueryString(codecRegistry), statement.getOutgoingPayload());
 return GuavaCompatibility.INSTANCE.transform(
   prepared,
   new Function<PreparedStatement, PreparedStatement>() {
    @Override
    public PreparedStatement apply(PreparedStatement prepared) {
     ProtocolVersion protocolVersion =
       getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
     ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
     if (routingKey != null) prepared.setRoutingKey(routingKey);
     if (statement.getConsistencyLevel() != null)
      prepared.setConsistencyLevel(statement.getConsistencyLevel());
     if (statement.getSerialConsistencyLevel() != null)
      prepared.setSerialConsistencyLevel(statement.getSerialConsistencyLevel());
     if (statement.isTracing()) prepared.enableTracing();
     prepared.setRetryPolicy(statement.getRetryPolicy());
     prepared.setOutgoingPayload(statement.getOutgoingPayload());
     prepared.setIdempotent(statement.isIdempotent());
     return prepared;
    }
   });
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

/**
 * Whether or not this statement has values, that is if {@code getValues}
 * will return {@code null} or not.
 * <p/>
 * This method calls {@link #hasValues(CodecRegistry)} with {@link ProtocolVersion#NEWEST_SUPPORTED}.
 * Whether you should use this or the other variant depends on the type of statement this is
 * called on:
 * <ul>
 * <li>for a {@link SimpleStatement} or {@link SchemaStatement}, the codec registry isn't
 * actually needed, so it's always safe to use this method;</li>
 * <li>for a {@link BuiltStatement} you can use this method if you use no custom codecs, or if
 * your custom codecs are registered with the default registry. Otherwise, use the other method and
 * provide the registry that contains your codecs (see {@link BuiltStatement} for more explanations
 * on why this is so);</li>
 * <li>for a {@link BatchStatement}, use the first rule if it contains no built statements,
 * or the second rule otherwise.</li>
 * </ul>
 *
 * @return {@code false} if {@link #getValues} returns {@code null}, {@code true}
 * otherwise.
 */
public boolean hasValues() {
  return hasValues(CodecRegistry.DEFAULT_INSTANCE);
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

/**
 * Whether or not this statement has values, that is if {@code getValues}
 * will return {@code null} or not.
 * <p/>
 * This method calls {@link #hasValues(CodecRegistry)} with {@link ProtocolVersion#NEWEST_SUPPORTED}.
 * Whether you should use this or the other variant depends on the type of statement this is
 * called on:
 * <ul>
 * <li>for a {@link SimpleStatement} or {@link SchemaStatement}, the codec registry isn't
 * actually needed, so it's always safe to use this method;</li>
 * <li>for a {@link BuiltStatement} you can use this method if you use no custom codecs, or if
 * your custom codecs are registered with the default registry. Otherwise, use the other method and
 * provide the registry that contains your codecs (see {@link BuiltStatement} for more explanations
 * on why this is so);</li>
 * <li>for a {@link BatchStatement}, use the first rule if it contains no built statements,
 * or the second rule otherwise.</li>
 * </ul>
 *
 * @return {@code false} if {@link #getValues} returns {@code null}, {@code true}
 * otherwise.
 */
public boolean hasValues() {
  return hasValues(CodecRegistry.DEFAULT_INSTANCE);
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

/**
 * Whether or not this statement has values, that is if {@code getValues}
 * will return {@code null} or not.
 * <p/>
 * This method calls {@link #hasValues(CodecRegistry)} with {@link ProtocolVersion#NEWEST_SUPPORTED}.
 * Whether you should use this or the other variant depends on the type of statement this is
 * called on:
 * <ul>
 * <li>for a {@link SimpleStatement} or {@link SchemaStatement}, the codec registry isn't
 * actually needed, so it's always safe to use this method;</li>
 * <li>for a {@link BuiltStatement} you can use this method if you use no custom codecs, or if
 * your custom codecs are registered with the default registry. Otherwise, use the other method and
 * provide the registry that contains your codecs (see {@link BuiltStatement} for more explanations
 * on why this is so);</li>
 * <li>for a {@link BatchStatement}, use the first rule if it contains no built statements,
 * or the second rule otherwise.</li>
 * </ul>
 *
 * @return {@code false} if {@link #getValues} returns {@code null}, {@code true}
 * otherwise.
 */
public boolean hasValues() {
  return hasValues(CodecRegistry.DEFAULT_INSTANCE);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

size += CBUtil.sizeOfConsistencyLevel(getConsistencyLevel());
size += QueryFlag.serializedSize(protocolVersion);
if (hasValues()) {
 if (usesNamedValues()) {
  size += CBUtil.sizeOfNamedValueList(getNamedValues(protocolVersion, codecRegistry));

代码示例来源:origin: com.yugabyte/cassandra-driver-core

/**
 * {@inheritDoc}
 */
@Override
public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement statement) {
  if (statement.hasValues())
    throw new IllegalArgumentException("A statement to prepare should not have values");
  final CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
  ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.getQueryString(codecRegistry), statement.getOutgoingPayload());
  return Futures.transform(prepared, new Function<PreparedStatement, PreparedStatement>() {
    @Override
    public PreparedStatement apply(PreparedStatement prepared) {
      ProtocolVersion protocolVersion = getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
      ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
      if (routingKey != null)
        prepared.setRoutingKey(routingKey);
      if (statement.getConsistencyLevel() != null)
        prepared.setConsistencyLevel(statement.getConsistencyLevel());
      if (statement.getSerialConsistencyLevel() != null)
        prepared.setSerialConsistencyLevel(statement.getSerialConsistencyLevel());
      if (statement.isTracing())
        prepared.enableTracing();
      prepared.setRetryPolicy(statement.getRetryPolicy());
      prepared.setOutgoingPayload(statement.getOutgoingPayload());
      prepared.setIdempotent(statement.isIdempotent());
      return prepared;
    }
  });
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

/**
 * {@inheritDoc}
 */
@Override
public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement statement) {
  if (statement.hasValues())
    throw new IllegalArgumentException("A statement to prepare should not have values");
  final CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
  ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.getQueryString(codecRegistry), statement.getOutgoingPayload());
  return Futures.transform(prepared, new Function<PreparedStatement, PreparedStatement>() {
    @Override
    public PreparedStatement apply(PreparedStatement prepared) {
      ProtocolVersion protocolVersion = getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
      ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
      if (routingKey != null)
        prepared.setRoutingKey(routingKey);
      if (statement.getConsistencyLevel() != null)
        prepared.setConsistencyLevel(statement.getConsistencyLevel());
      if (statement.getSerialConsistencyLevel() != null)
        prepared.setSerialConsistencyLevel(statement.getSerialConsistencyLevel());
      if (statement.isTracing())
        prepared.enableTracing();
      prepared.setRetryPolicy(statement.getRetryPolicy());
      prepared.setOutgoingPayload(statement.getOutgoingPayload());
      prepared.setIdempotent(statement.isIdempotent());
      return prepared;
    }
  });
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

/**
 * {@inheritDoc}
 */
@Override
public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement statement) {
  if (statement.hasValues())
    throw new IllegalArgumentException("A statement to prepare should not have values");
  final CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
  ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.getQueryString(codecRegistry), statement.getOutgoingPayload());
  return Futures.transform(prepared, new Function<PreparedStatement, PreparedStatement>() {
    @Override
    public PreparedStatement apply(PreparedStatement prepared) {
      ProtocolVersion protocolVersion = getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
      ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
      if (routingKey != null)
        prepared.setRoutingKey(routingKey);
      if (statement.getConsistencyLevel() != null)
        prepared.setConsistencyLevel(statement.getConsistencyLevel());
      if (statement.getSerialConsistencyLevel() != null)
        prepared.setSerialConsistencyLevel(statement.getSerialConsistencyLevel());
      if (statement.isTracing())
        prepared.enableTracing();
      prepared.setRetryPolicy(statement.getRetryPolicy());
      prepared.setOutgoingPayload(statement.getOutgoingPayload());
      prepared.setIdempotent(statement.isIdempotent());
      return prepared;
    }
  });
}

相关文章