blob: 97170bf25222f88005a1eb7eb5bf36f71e24af74 [file] [log] [blame]
/*
* 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.ignite.internal.processors.query.h2.twostep;
import java.util.ArrayList;
import java.util.UUID;
import org.apache.ignite.internal.GridKernalContext;
import org.h2.command.ddl.CreateTableData;
import org.h2.engine.Session;
import org.h2.index.Index;
import org.h2.index.IndexType;
import org.h2.message.DbException;
import org.h2.result.Row;
import org.h2.table.IndexColumn;
import org.h2.table.TableBase;
/**
* Merge table for distributed queries.
*/
public class GridMergeTable extends TableBase {
/** */
private final GridKernalContext ctx;
/** */
private final GridMergeIndex idx;
/**
* @param data Data.
* @param ctx Kernal context.
*/
public GridMergeTable(CreateTableData data, GridKernalContext ctx) {
super(data);
this.ctx = ctx;
idx = new GridMergeIndexUnsorted(this, "merge_scan");
}
/**
* Fails merge table if any source node is left.
*/
public void checkSourceNodesAlive() {
for (UUID nodeId : idx.sources()) {
if (!ctx.discovery().alive(nodeId)) {
idx.fail(nodeId);
return;
}
}
}
/** {@inheritDoc} */
@Override public boolean lock(Session session, boolean exclusive, boolean force) {
return false;
}
/** {@inheritDoc} */
@Override public void close(Session ses) {
idx.close(ses);
}
/** {@inheritDoc} */
@Override public void unlock(Session s) {
// No-op.
}
/** {@inheritDoc} */
@Override public Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols,
IndexType indexType, boolean create, String indexComment) {
throw DbException.getUnsupportedException("addIndex");
}
/** {@inheritDoc} */
@Override public void removeRow(Session session, Row row) {
throw DbException.getUnsupportedException("removeRow");
}
/** {@inheritDoc} */
@Override public void truncate(Session session) {
throw DbException.getUnsupportedException("truncate");
}
/** {@inheritDoc} */
@Override public void addRow(Session session, Row row) {
throw DbException.getUnsupportedException("addRow");
}
/** {@inheritDoc} */
@Override public void checkSupportAlter() {
throw DbException.getUnsupportedException("alter");
}
/** {@inheritDoc} */
@Override public String getTableType() {
return EXTERNAL_TABLE_ENGINE;
}
/** {@inheritDoc} */
@Override public GridMergeIndex getScanIndex(Session session) {
return idx;
}
/** {@inheritDoc} */
@Override public Index getUniqueIndex() {
return null; // We don't have a PK.
}
/** {@inheritDoc} */
@Override public ArrayList<Index> getIndexes() {
return null;
}
/** {@inheritDoc} */
@Override public boolean isLockedExclusively() {
return false;
}
/** {@inheritDoc} */
@Override public long getMaxDataModificationId() {
return 0;
}
/** {@inheritDoc} */
@Override public boolean isDeterministic() {
return true;
}
/** {@inheritDoc} */
@Override public boolean canGetRowCount() {
return true;
}
/** {@inheritDoc} */
@Override public boolean canDrop() {
return true;
}
/** {@inheritDoc} */
@Override public long getRowCount(Session ses) {
return idx.getRowCount(ses);
}
/** {@inheritDoc} */
@Override public long getRowCountApproximation() {
return idx.getRowCountApproximation();
}
/** {@inheritDoc} */
@Override public long getDiskSpaceUsed() {
return 0;
}
/** {@inheritDoc} */
@Override public void checkRename() {
throw DbException.getUnsupportedException("rename");
}
}