本文整理汇总了Java中org.apache.calcite.avatica.remote.TypedValue类的典型用法代码示例。如果您正苦于以下问题:Java TypedValue类的具体用法?Java TypedValue怎么用?Java TypedValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypedValue类属于org.apache.calcite.avatica.remote包,在下文中一共展示了TypedValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: executeBatchProtobuf
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
@Override public ExecuteBatchResult executeBatchProtobuf(StatementHandle h,
List<Requests.UpdateBatch> updateBatches) throws NoSuchStatementException {
try {
final StatementInfo info = statementCache.getIfPresent(h.id);
if (null == info) {
throw new NoSuchStatementException(h);
}
final PreparedStatement preparedStmt = (PreparedStatement) info.statement;
for (Requests.UpdateBatch update : updateBatches) {
int i = 1;
for (Common.TypedValue value : update.getParameterValuesList()) {
// Use the value and then increment
preparedStmt.setObject(i++, TypedValue.protoToJdbc(value, calendar));
}
preparedStmt.addBatch();
}
return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(preparedStmt));
} catch (SQLException e) {
throw propagate(e);
}
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:23,代码来源:JdbcMeta.java
示例2: parseColumn
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
static void parseColumn(Common.Row.Builder rowBuilder, Object column) {
final Common.ColumnValue.Builder columnBuilder = Common.ColumnValue.newBuilder();
if (column instanceof List) {
columnBuilder.setHasArrayValue(true);
List<?> list = (List<?>) column;
// Add each element in the list/array to the column's value
for (Object listItem : list) {
final Common.TypedValue scalarListItem = serializeScalar(listItem);
columnBuilder.addArrayValue(scalarListItem);
// Add the deprecated 'value' repeated attribute for backwards compat
columnBuilder.addValue(scalarListItem);
}
} else {
// The default value, but still explicit.
columnBuilder.setHasArrayValue(false);
// Only one value for this column, a scalar.
final Common.TypedValue scalarVal = serializeScalar(column);
columnBuilder.setScalarValue(scalarVal);
// Add the deprecated 'value' repeated attribute for backwards compat
columnBuilder.addValue(scalarVal);
}
// Add value to row
rowBuilder.addValue(columnBuilder.build());
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:27,代码来源:Meta.java
示例3: testExecuteRequestWithNumberParameter
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
@Test public void testExecuteRequestWithNumberParameter() {
final List<TypedValue> expectedParameterValues = new ArrayList<>();
final Service service = new ParameterValuesCheckingService(expectedParameterValues);
final JsonService jsonService = new LocalJsonService(service);
final JsonHandler jsonHandler = new JsonHandler(jsonService, NoopMetricsSystem.getInstance());
final List<TypedValue> parameterValues = Arrays.asList(
TypedValue.create("NUMBER", new BigDecimal("123")),
TypedValue.create("STRING", "calcite"));
jsonHandler.apply(
"{'request':'execute',"
+ "'parameterValues':[{'type':'NUMBER','value':123},"
+ "{'type':'STRING','value':'calcite'}]}");
assertThat(expectedParameterValues.size(), is(2));
assertThat(expectedParameterValues.get(0), is(parameterValues.get(0)));
assertThat(expectedParameterValues.get(1), is(parameterValues.get(1)));
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:19,代码来源:JsonHandlerTest.java
示例4: getParameterValues
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
@Override
protected List<TypedValue> getParameterValues() {
if (parameters.isEmpty()) {
return Collections.emptyList();
}
if (parameters.lastKey() != parameters.size()) {
throw new IndexOutOfBoundsException(
String.format("Number of specified parameters [%d] is lower than the last key [%d]",
parameters.size(), parameters.lastKey()));
}
final List<TypedValue> list = new ArrayList<>(parameters.values());
if (logger.isDebugEnabled()) {
for (TypedValue tv : list) {
logger.debug("[TypedValue] type: {} value: {}", tv.type, tv.value);
}
}
return list;
}
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:19,代码来源:AtsdPreparedStatement.java
示例5: substitutePlaceholders
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
private static String substitutePlaceholders(List<String> queryParts, List<TypedValue> parameterValues) {
final int parametersSize = parameterValues.size();
final int queryPartsSize = queryParts.size();
if (queryPartsSize - 1 != parametersSize) {
throw new AtsdRuntimeException(String.format("Number of specified values [%d] does not match the number of placeholder occurrences [%d]",
parametersSize, queryPartsSize - 1));
}
if (queryPartsSize == 1) {
return queryParts.get(0);
}
final StringBuilder buffer = new StringBuilder();
for (int i = 0; i < parametersSize; i++) {
buffer.append(queryParts.get(i));
appendTypedValue(parameterValues.get(i), buffer);
}
buffer.append(queryParts.get(parametersSize));
final String result = buffer.toString();
log.debug("[substitutePlaceholders] {}", result);
return result;
}
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:21,代码来源:AtsdMeta.java
示例6: appendTypedValue
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
private static void appendTypedValue(TypedValue parameterValue, StringBuilder buffer) {
Object value = parameterValue.value;
if (value == null) {
buffer.append("NULL");
return;
}
switch(parameterValue.type) {
case STRING:
buffer.append('\'').append(value).append('\'');
break;
case JAVA_SQL_TIMESTAMP:
case JAVA_UTIL_DATE:
buffer.append('\'').append(TIMESTAMP_PRINTER.format(value)).append('\'');
break;
case OBJECT:
appendObjectValue(value, buffer);
break;
default:
buffer.append(value);
}
}
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:22,代码来源:AtsdMeta.java
示例7: prepareValues
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
private static List<Object> prepareValues(List<TypedValue> parameterValues) {
if (parameterValues.isEmpty()) {
return Collections.emptyList();
}
List<Object> result = new ArrayList<>(parameterValues.size());
for (TypedValue parameterValue : parameterValues) {
Object value = parameterValue.value;
if (value instanceof Number || value instanceof String) {
result.add(value);
} else if (value instanceof Date) {
result.add(TIMESTAMP_PRINTER.format((Date) value));
} else {
result.add(value == null ? null : String.valueOf(value));
}
}
log.debug("[preparedValues] {}", result);
return result;
}
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:20,代码来源:AtsdMeta.java
示例8: enumerable
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
public <T> Enumerable<T> enumerable(Meta.StatementHandle handle,
CalcitePrepare.CalciteSignature<T> signature) throws SQLException {
Map<String, Object> map = Maps.newLinkedHashMap();
AvaticaStatement statement = lookupStatement(handle);
final List<TypedValue> parameterValues =
TROJAN.getParameterValues(statement);
if (MetaImpl.checkParameterValueHasNull(parameterValues)) {
throw new SQLException("exception while executing query: unbound parameter");
}
for (Ord<TypedValue> o : Ord.zip(parameterValues)) {
map.put("?" + o.i, o.e.toLocal());
}
map.putAll(signature.internalParameters);
final DataContext dataContext = createDataContext(map);
return signature.enumerable(dataContext);
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:CalciteConnectionImpl.java
示例9: execute
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
@Override public ExecuteResult execute(StatementHandle h,
List<TypedValue> parameterValues, int maxRowsInFirstFrame)
throws NoSuchStatementException {
final CalciteConnectionImpl calciteConnection = getConnection();
CalciteServerStatement stmt = calciteConnection.server.getStatement(h);
final Signature signature = stmt.getSignature();
MetaResultSet metaResultSet;
if (signature.statementType.canUpdate()) {
final Iterable<Object> iterable =
_createIterable(h, signature, parameterValues, null);
final Iterator<Object> iterator = iterable.iterator();
stmt.setResultSet(iterator);
metaResultSet = MetaResultSet.count(h.connectionId, h.id,
((Number) iterator.next()).intValue());
} else {
// Don't populate the first frame.
// It's not worth saving a round-trip, since we're local.
final Meta.Frame frame =
new Meta.Frame(0, false, Collections.emptyList());
metaResultSet =
MetaResultSet.create(h.connectionId, h.id, false, signature, frame);
}
return new ExecuteResult(ImmutableList.of(metaResultSet));
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:CalciteMetaImpl.java
示例10: getBoundParameterValues
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/** Returns a list of bound parameter values.
*
* <p>If any of the parameters have not been bound, throws.
* If parameters have been bound to null, the value in the list is null.
*/
protected List<TypedValue> getBoundParameterValues() throws SQLException {
final List<TypedValue> parameterValues = getParameterValues();
for (Object parameterValue : parameterValues) {
if (parameterValue == null) {
throw new SQLException("unbound parameter");
}
}
return parameterValues;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:15,代码来源:AvaticaStatement.java
示例11: createIterable
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
@Override public Iterable<Object> createIterable(StatementHandle handle, QueryState state,
Signature signature, List<TypedValue> parameterValues, Frame firstFrame) {
// `parameterValues` is intentionally unusued (in method signature for historic reasons)
// Left to preserve API compatibility with Calcite
if (firstFrame != null && firstFrame.done) {
return firstFrame.rows;
}
AvaticaStatement stmt;
try {
stmt = connection.lookupStatement(handle);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return new FetchIterable(stmt, state, firstFrame);
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:16,代码来源:MetaImpl.java
示例12: checkParameterValueHasNull
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/** Returns whether a list of parameter values has any null elements. */
public static boolean checkParameterValueHasNull(List<TypedValue> parameterValues) {
for (TypedValue x : parameterValues) {
if (x == null) {
return true;
}
}
return false;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:10,代码来源:MetaImpl.java
示例13: execute
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/**
* Executes this result set. (Not a JDBC method.)
*
* <p>Note that execute cannot occur in the constructor, because the
* constructor occurs while the statement is locked, to make sure that
* execute/cancel don't happen at the same time.</p>
*
* @see org.apache.calcite.avatica.AvaticaConnection.Trojan#execute(AvaticaResultSet)
*
* @throws SQLException if execute fails for some reason.
*/
protected AvaticaResultSet execute() throws SQLException {
final Iterable<Object> iterable1 =
statement.connection.meta.createIterable(statement.handle, state, signature,
Collections.<TypedValue>emptyList(), firstFrame);
this.cursor = MetaImpl.createCursor(signature.cursorFactory, iterable1);
this.accessorList =
cursor.createAccessors(columnMetaDataList, localCalendar, this);
this.row = -1;
this.afterLast = false;
return this;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:23,代码来源:AvaticaResultSet.java
示例14: serializeScalar
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
static Common.TypedValue serializeScalar(Object element) {
final Common.TypedValue.Builder valueBuilder = Common.TypedValue.newBuilder();
// Let TypedValue handle the serialization for us.
TypedValue.toProto(valueBuilder, element);
return valueBuilder.build();
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:9,代码来源:Meta.java
示例15: parseOldStyleColumn
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/**
* For Calcite 1.5, we made the mistake of using array length to determine when the value for a
* column is a scalar or an array. This method performs the old parsing for backwards
* compatibility.
*
* @param column The protobuf ColumnValue object
* @return The parsed value for this column
*/
static Object parseOldStyleColumn(Common.ColumnValue column) {
if (column.getValueCount() > 1) {
List<Object> array = new ArrayList<>(column.getValueCount());
for (Common.TypedValue columnValue : column.getValueList()) {
array.add(deserializeScalarValue(columnValue));
}
return array;
} else {
return deserializeScalarValue(column.getValue(0));
}
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:20,代码来源:Meta.java
示例16: parseArray
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/**
* Recursively parses a TypedValue while it is an array.
*/
static Object parseArray(Common.TypedValue array) {
List<Object> convertedArray = new ArrayList<>(array.getArrayValueCount());
for (Common.TypedValue arrayElement : array.getArrayValueList()) {
if (Common.Rep.ARRAY == arrayElement.getType()) {
// Recurse
convertedArray.add(parseArray(arrayElement));
} else {
// The component type of this array is a scalar.
convertedArray.add(deserializeScalarValue(arrayElement));
}
}
return convertedArray;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:17,代码来源:Meta.java
示例17: deserializeScalarValue
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
static Object deserializeScalarValue(Common.TypedValue protoElement) {
// ByteString is a single case where TypedValue is representing the data differently
// (in its "local" form) than Frame does. We need to unwrap the Base64 encoding.
if (Common.Rep.BYTE_STRING == protoElement.getType()) {
// Protobuf is sending native bytes (not b64) across the wire. B64 bytes is only for
// TypedValue's benefit
return protoElement.getBytesValue().toByteArray();
}
// Again, let TypedValue deserialize things for us.
return TypedValue.fromProto(protoElement).value;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:12,代码来源:Meta.java
示例18: AvaticaSite
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
public AvaticaSite(AvaticaParameter parameter, Calendar calendar, int index,
TypedValue[] slots) {
assert calendar != null;
assert parameter != null;
assert slots != null;
this.parameter = parameter;
this.calendar = calendar;
this.index = index;
this.slots = slots;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:11,代码来源:AvaticaSite.java
示例19: AvaticaPreparedStatement
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/**
* Creates an AvaticaPreparedStatement.
*
* @param connection Connection
* @param h Statement handle
* @param signature Result of preparing statement
* @param resultSetType Result set type
* @param resultSetConcurrency Result set concurrency
* @param resultSetHoldability Result set holdability
* @throws SQLException If fails due to underlying implementation reasons.
*/
protected AvaticaPreparedStatement(AvaticaConnection connection,
Meta.StatementHandle h,
Meta.Signature signature,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
super(connection, h, resultSetType, resultSetConcurrency,
resultSetHoldability, signature);
this.slots = new TypedValue[signature.parameters.size()];
this.resultSetMetaData =
connection.factory.newResultSetMetaData(this, signature);
this.parameterValueBatch = new ArrayList<>();
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:25,代码来源:AvaticaPreparedStatement.java
示例20: copyParameterValues
import org.apache.calcite.avatica.remote.TypedValue; //导入依赖的package包/类
/** Returns a copy of the current parameter values.
* @return A copied list of the parameter values
*/
protected List<TypedValue> copyParameterValues() {
// For implementing batch update, we need to make a copy of slots, not just a thin reference
// to it as as list. Otherwise, subsequent setFoo(..) calls will alter the underlying array
// and modify our cached TypedValue list.
List<TypedValue> copy = new ArrayList<>(slots.length);
for (TypedValue value : slots) {
copy.add(value);
}
return copy;
}
开发者ID:apache,项目名称:calcite-avatica,代码行数:14,代码来源:AvaticaPreparedStatement.java
注:本文中的org.apache.calcite.avatica.remote.TypedValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论