Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.druid.sql.avatica;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import org.apache.calcite.avatica.ColumnMetaData;
import org.apache.calcite.avatica.Meta;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.java.util.common.guava.Sequence;
import org.apache.druid.java.util.common.guava.Yielder;
import org.apache.druid.java.util.common.guava.Yielders;
import org.apache.druid.server.security.AuthenticationResult;
import org.apache.druid.server.security.ForbiddenException;
import org.apache.druid.sql.SqlLifecycle;
import org.apache.druid.sql.calcite.rel.QueryMaker;
import java.io.Closeable;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/**
* Statement handle for {@link DruidMeta}. Thread-safe.
*/
public class DruidStatement implements Closeable
{
public static final long START_OFFSET = 0;
private final String connectionId;
private final int statementId;
private final Map queryContext;
private final SqlLifecycle sqlLifecycle;
private final Runnable onClose;
private final Object lock = new Object();
/**
* Query metrics can only be used within a single thread. Because results can be paginated into multiple
* JDBC frames (each frame being processed by a potentially different thread), the thread that closes the yielder
* (resulting in a QueryMetrics emit() call) may not be the same thread that created the yielder (which initializes
* DefaultQueryMetrics with the current thread as the owner). Create and close the yielder with this
* single-thread executor to prevent this from happening.
*
* The thread owner check in DefaultQueryMetrics is more aggressive than needed for this specific JDBC case, since
* the JDBC frames are processed sequentially. If the thread owner check is changed/loosened to permit this use case,
* we would not need to use this executor.
*
* See discussion at:
* https://github.com/apache/druid/pull/4288
* https://github.com/apache/druid/pull/4415
*/
private final ExecutorService yielderOpenCloseExecutor;
private State state = State.NEW;
private String query;
private long maxRowCount;
private Meta.Signature signature;
private Yielder