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

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

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

RegularStatement.getValues介绍

[英]The values to use for this statement.

Note: Values for a RegularStatement (i.e. if this method does not return null) are not supported with the native protocol version 1: you will get an UnsupportedProtocolVersionException when submitting one if version 1 of the protocol is in use (i.e. if you've force version 1 through Cluster.Builder#withProtocolVersion or you use Cassandra 1.2).
[中]用于此语句的值。
注意:本机协议版本1不支持正则语句的值(即,如果此方法不返回null):如果协议版本1正在使用(即,如果您通过Cluster.Builder#with ProtocolVersion或您使用Cassandra 1.2)提交一个正则语句,您将得到一个不受支持的ProtocolVersionException。

代码示例

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

@Override
public ByteBuffer[] getValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
 // If there is some non-BuiltStatement inside the batch with values, we shouldn't
 // use super.getValues() since it will ignore the values of said non-BuiltStatement.
 // If that's the case, we just collects all those values (and we know
 // super.getValues() == null in that case since we've explicitely set this.hasBindMarker
 // to true). Otherwise, we simply call super.getValues().
 if (nonBuiltStatementValues == 0) return super.getValues(protocolVersion, codecRegistry);
 ByteBuffer[] values = new ByteBuffer[nonBuiltStatementValues];
 int i = 0;
 for (RegularStatement statement : statements) {
  if (statement instanceof BuiltStatement) continue;
  ByteBuffer[] statementValues = statement.getValues(protocolVersion, codecRegistry);
  System.arraycopy(statementValues, 0, values, i, statementValues.length);
  i += statementValues.length;
 }
 return values;
}

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

IdAndValues getIdAndValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
 IdAndValues idAndVals = new IdAndValues(statements.size());
 for (Statement statement : statements) {
  if (statement instanceof StatementWrapper)
   statement = ((StatementWrapper) statement).getWrappedStatement();
  if (statement instanceof RegularStatement) {
   RegularStatement st = (RegularStatement) statement;
   ByteBuffer[] vals = st.getValues(protocolVersion, codecRegistry);
   String query = st.getQueryString(codecRegistry);
   idAndVals.ids.add(query);
   idAndVals.values.add(
     vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
  } else {
   // We handle BatchStatement in add() so ...
   assert statement instanceof BoundStatement;
   BoundStatement st = (BoundStatement) statement;
   idAndVals.ids.add(st.statement.getPreparedId().boundValuesMetadata.id);
   idAndVals.values.add(Arrays.asList(st.wrapper.values));
  }
 }
 return idAndVals;
}

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

values = rs.getValues(protocolVersion, codecRegistry);

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

@Test(groups = "unit")
public void should_not_serialize_raw_query_values() {
 RegularStatement select = select().from("test").where(gt("i", raw("1")));
 assertThat(select.getQueryString()).doesNotContain("?");
 assertThat(select.getValues(ProtocolVersion.NEWEST_SUPPORTED, CodecRegistry.DEFAULT_INSTANCE))
   .isNull();
}

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

@Override
public ByteBuffer[] getValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  // If there is some non-BuiltStatement inside the batch with values, we shouldn't
  // use super.getValues() since it will ignore the values of said non-BuiltStatement.
  // If that's the case, we just collects all those values (and we know
  // super.getValues() == null in that case since we've explicitely set this.hasBindMarker
  // to true). Otherwise, we simply call super.getValues().
  if (nonBuiltStatementValues == 0)
    return super.getValues(protocolVersion, codecRegistry);
  ByteBuffer[] values = new ByteBuffer[nonBuiltStatementValues];
  int i = 0;
  for (RegularStatement statement : statements) {
    if (statement instanceof BuiltStatement)
      continue;
    ByteBuffer[] statementValues = statement.getValues(protocolVersion, codecRegistry);
    System.arraycopy(statementValues, 0, values, i, statementValues.length);
    i += statementValues.length;
  }
  return values;
}

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

@Override
public ByteBuffer[] getValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  // If there is some non-BuiltStatement inside the batch with values, we shouldn't
  // use super.getValues() since it will ignore the values of said non-BuiltStatement.
  // If that's the case, we just collects all those values (and we know
  // super.getValues() == null in that case since we've explicitely set this.hasBindMarker
  // to true). Otherwise, we simply call super.getValues().
  if (nonBuiltStatementValues == 0)
    return super.getValues(protocolVersion, codecRegistry);
  ByteBuffer[] values = new ByteBuffer[nonBuiltStatementValues];
  int i = 0;
  for (RegularStatement statement : statements) {
    if (statement instanceof BuiltStatement)
      continue;
    ByteBuffer[] statementValues = statement.getValues(protocolVersion, codecRegistry);
    System.arraycopy(statementValues, 0, values, i, statementValues.length);
    i += statementValues.length;
  }
  return values;
}

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

@Override
public ByteBuffer[] getValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  // If there is some non-BuiltStatement inside the batch with values, we shouldn't
  // use super.getValues() since it will ignore the values of said non-BuiltStatement.
  // If that's the case, we just collects all those values (and we know
  // super.getValues() == null in that case since we've explicitely set this.hasBindMarker
  // to true). Otherwise, we simply call super.getValues().
  if (nonBuiltStatementValues == 0)
    return super.getValues(protocolVersion, codecRegistry);
  ByteBuffer[] values = new ByteBuffer[nonBuiltStatementValues];
  int i = 0;
  for (RegularStatement statement : statements) {
    if (statement instanceof BuiltStatement)
      continue;
    ByteBuffer[] statementValues = statement.getValues(protocolVersion, codecRegistry);
    System.arraycopy(statementValues, 0, values, i, statementValues.length);
    i += statementValues.length;
  }
  return values;
}

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

} else {
 size +=
   CBUtil.sizeOfValueList(Arrays.asList(getValues(protocolVersion, codecRegistry)));

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

((com.datastax.driver.core.querybuilder.BuiltStatement) rs).setForceNoValues(true);
ByteBuffer[] rawPositionalValues = rs.getValues(protocolVersion, codecRegistry);
Map<String, ByteBuffer> rawNamedValues = rs.getNamedValues(protocolVersion, codecRegistry);

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

IdAndValues getIdAndValues() {
  IdAndValues idAndVals = new IdAndValues(statements.size());
  for (Statement statement : statements) {
    if (statement instanceof RegularStatement) {
      RegularStatement st = (RegularStatement)statement;
      ByteBuffer[] vals = st.getValues();
      idAndVals.ids.add(st.getQueryString());
      idAndVals.values.add(vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
    } else {
      // We handle BatchStatement in add() so ...
      assert statement instanceof BoundStatement;
      BoundStatement st = (BoundStatement)statement;
      idAndVals.ids.add(st.statement.getPreparedId().id);
      idAndVals.values.add(Arrays.asList(st.values));
    }
  }
  return idAndVals;
}

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

/**
 * {@inheritDoc}
 */
@Override
public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement statement) {
  if (statement.getValues() != null)
    throw new IllegalArgumentException("A statement to prepare should not have values");
  ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.toString());
  return Futures.transform(prepared, new Function<PreparedStatement, PreparedStatement>() {
    @Override
    public PreparedStatement apply(PreparedStatement prepared) {
      ByteBuffer routingKey = statement.getRoutingKey();
      if (routingKey != null)
        prepared.setRoutingKey(routingKey);
      prepared.setConsistencyLevel(statement.getConsistencyLevel());
      if (statement.isTracing())
        prepared.enableTracing();
      prepared.setRetryPolicy(statement.getRetryPolicy());
      return prepared;
    }
  });
}

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

IdAndValues getIdAndValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  IdAndValues idAndVals = new IdAndValues(statements.size());
  for (Statement statement : statements) {
    if (statement instanceof StatementWrapper)
      statement = ((StatementWrapper) statement).getWrappedStatement();
    if (statement instanceof RegularStatement) {
      RegularStatement st = (RegularStatement) statement;
      ByteBuffer[] vals = st.getValues(protocolVersion, codecRegistry);
      String query = st.getQueryString(codecRegistry);
      idAndVals.ids.add(query);
      idAndVals.values.add(vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
    } else {
      // We handle BatchStatement in add() so ...
      assert statement instanceof BoundStatement;
      BoundStatement st = (BoundStatement) statement;
      idAndVals.ids.add(st.statement.getPreparedId().id);
      idAndVals.values.add(Arrays.asList(st.wrapper.values));
    }
  }
  return idAndVals;
}

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

IdAndValues getIdAndValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  IdAndValues idAndVals = new IdAndValues(statements.size());
  for (Statement statement : statements) {
    if (statement instanceof StatementWrapper)
      statement = ((StatementWrapper) statement).getWrappedStatement();
    if (statement instanceof RegularStatement) {
      RegularStatement st = (RegularStatement) statement;
      ByteBuffer[] vals = st.getValues(protocolVersion, codecRegistry);
      String query = st.getQueryString(codecRegistry);
      idAndVals.ids.add(query);
      idAndVals.values.add(vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
    } else {
      // We handle BatchStatement in add() so ...
      assert statement instanceof BoundStatement;
      BoundStatement st = (BoundStatement) statement;
      idAndVals.ids.add(st.statement.getPreparedId().id);
      idAndVals.values.add(Arrays.asList(st.wrapper.values));
    }
  }
  return idAndVals;
}

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

IdAndValues getIdAndValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
  IdAndValues idAndVals = new IdAndValues(statements.size());
  for (Statement statement : statements) {
    if (statement instanceof StatementWrapper)
      statement = ((StatementWrapper) statement).getWrappedStatement();
    if (statement instanceof RegularStatement) {
      RegularStatement st = (RegularStatement) statement;
      ByteBuffer[] vals = st.getValues(protocolVersion, codecRegistry);
      String query = st.getQueryString(codecRegistry);
      idAndVals.ids.add(query);
      idAndVals.values.add(vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
    } else {
      // We handle BatchStatement in add() so ...
      assert statement instanceof BoundStatement;
      BoundStatement st = (BoundStatement) statement;
      idAndVals.ids.add(st.statement.getPreparedId().id);
      idAndVals.values.add(Arrays.asList(st.wrapper.values));
    }
  }
  return idAndVals;
}

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

ByteBuffer[] vars = stmt.getValues();
if (vars != null) {
  Collections.addAll(variables, vars);

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

values = rs.getValues(protocolVersion, codecRegistry);

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

values = rs.getValues(protocolVersion, codecRegistry);

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

values = rs.getValues(protocolVersion, codecRegistry);

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

@Test(groups = "unit")
public void should_not_serialize_raw_query_values() {
 RegularStatement select = select().from("test").where(gt("i", raw("1")));
 assertThat(select.getQueryString()).doesNotContain("?");
 assertThat(select.getValues(ProtocolVersion.NEWEST_SUPPORTED, CodecRegistry.DEFAULT_INSTANCE))
   .isNull();
}

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

((com.datastax.driver.core.querybuilder.BuiltStatement)rs).setForceNoValues(true);
ByteBuffer[] rawValues = rs.getValues();

相关文章