/** * Resets this program, so it can be run through again. */ public void reset(String sessionId){ counter = 0; this.tempTables = new TempTableStore(sessionId, TransactionMode.ISOLATE_WRITES); this.startedTxn = false; this.trappingExceptions = false; }
@Override public TempMetadataID getGlobalTempTableMetadataId(String matTableName) { return this.tableStore.getMetadataStore().getTempGroupID(matTableName); }
public void close() throws TeiidComponentException { if (this.tempTableStore != null) { this.tempTableStore.removeTempTables(); if (this.tempTableStore.getProcessors() != null) { for (TableProcessor proc : this.tempTableStore.getProcessors().values()) { proc.close(); } this.tempTableStore.setProcessors(null); } } this.root.close(); }
Create create = (Create)command; String tempTableName = create.getTable().getName(); if (contextStore.hasTempTable(tempTableName, true)) { throw new QueryProcessingException(QueryPlugin.Event.TEIID30229, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30229, tempTableName)); contextStore.addForeignTempTable(tempTableName, create); } else { contextStore.addTempTable(tempTableName, create, bufferManager, true, context); contextStore.removeTempTableByName(tempTableName, context); return CollectionTupleSource.createUpdateCountTupleSource(0);
if (tts.getTempTable(tempTableID) == null) { tts.addTempTable(tempTableID, create, buffer, true, context); return tts.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context); TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context); if (tempTable != null) { if (processors != null) { create.setElementSymbolsAsColumns(withProcessor.columns); withProcessor.alterCreate(create); tempTable = addTempTable(tempTableID, create, buffer, true, context); TempTable tt = withProcessor.process(tempTable); if (tt != tempTable) { return parentTempTableStore.getOrCreateTempTable(tempTableID, command, buffer, delegate, forUpdate, context, group); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(columns); return addTempTable(tempTableID, create, buffer, true, context);
/** * @see ProcessorPlan#connectDataManager(ProcessorDataManager) */ public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) { if (this.with != null) { context = context.clone(); tempTableStore = new TempTableStore(context.getConnectionId(), TransactionMode.NONE); tempTableStore.setParentTempTableStore(context.getTempTableStore()); context.setTempTableStore(tempTableStore); } setContext(context); connectExternal(this.root, context, dataMgr, bufferMgr); }
@Override public List<?> updateMatViewRow(String matTableName, List<?> tuple, boolean delete) throws TeiidComponentException { TempTable tempTable = tableStore.getTempTable(matTableName); if (tempTable != null) { TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName); synchronized (id) { boolean clone = tempTable.getActive().get() != 0; if (clone) { tempTable = tempTable.clone(); } List<?> result = tempTable.updateTuple(tuple, delete); if (clone) { swapTempTable(matTableName, tempTable); } return result; } } return null; }
public void setUp(QueryMetadataInterface qmi, ProcessorDataManager dm, BufferManager bm) { tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$ metadata = new TempMetadataAdapter(qmi, tempStore.getMetadataStore()); metadata.setSession(true); SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); cache.setTupleBufferCache(bm); dataManager = new TempTableDataManager(dm, bm, cache); }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { if (with != null && tempTableStore.getProcessors() == null) { HashMap<String, TableProcessor> processors = new HashMap<String, TableProcessor>(); tempTableStore.setProcessors(processors); for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); ProcessorPlan initial = setQuery.getLeftQuery().getProcessorPlan(); QueryProcessor withProcessor = new QueryProcessor(initial, getContext().clone(), root.getBufferManager(), root.getDataManager()); processors.put(withCommand.getGroupSymbol().getName(), new RecursiveTableProcessor(withProcessor, withCommand.getColumns(), setQuery.getRightQuery().getProcessorPlan(), setQuery.isAll())); continue; } ProcessorPlan plan = withCommand.getCommand().getProcessorPlan(); QueryProcessor withProcessor = new QueryProcessor(plan, getContext().clone(), root.getBufferManager(), root.getDataManager()); processors.put(withCommand.getGroupSymbol().getName(), new TableProcessor(withProcessor, withCommand.getColumns())); } } this.root.open(); }
this.cursorStates = this.cursorStates.getParentContext(); TempTableStore tempTableStore = program.getTempTableStore(); this.getContext().setTempTableStore(tempTableStore.getParentTempTableStore()); tempTableStore.removeTempTables(); if (program.startedTxn()) { TransactionService ts = this.getContext().getTransactionServer();
TransactionContext tc = context.getTransactionContext(); if (tc != null) { TempTableSynchronization synch = getSynchronization(context); if (synch != null && synch.existingTables.contains(tempTable.getId())) { TempTable result = synch.tables.get(tempTableID); TransactionContext tc = context.getTransactionContext(); if (tc != null && tc.getIsolationLevel() > Connection.TRANSACTION_READ_COMMITTED) { TempTableSynchronization synch = getSynchronization(context); if (synch != null) { TempTable result = synch.tables.get(tempTableID); return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
@Override public TempTable getTempTable(String matTableName) { return this.tableStore.getTempTable(matTableName); }
public void removeTempTableByName(final String tempTableName, CommandContext context) throws TeiidProcessingException { TempTableSynchronization synch = getSynchronization(context); tempMetadataStore.removeTempGroup(tempTableName); final TempTable table = this.tempTables.remove(tempTableName); if (table == null) { foreignTempTables.remove(tempTableName); return; } if (transactionMode != TransactionMode.ISOLATE_WRITES || synch == null || !synch.existingTables.contains(table.getId())) { table.remove(); } }
private void swapTempTable(String tempTableName, TempTable tempTable) { this.tableStore.getTempTables().put(tempTableName, tempTable); }
TeiidProcessingException { final String groupKey = group.getNonCorrelationName(); final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true, true, context, group); if (command instanceof Insert) { Insert insert = (Insert)command;
@Override public TempTable createMatTable(final String tableName, GroupSymbol group) throws TeiidComponentException, QueryMetadataException, TeiidProcessingException { Create create = getCreateCommand(group, true, metadata); TempTable table = tableStore.addTempTable(tableName, create, bufferManager, false, null); table.setUpdatable(false); CacheHint hint = table.getCacheHint(); if (hint != null) { table.setPreferMemory(hint.isPrefersMemory()); if (hint.getTtl() != null) { getMatTableInfo(tableName).setTtl(hint.getTtl()); } if (!create.getPrimaryKey().isEmpty()) { table.setUpdatable(hint.isUpdatable(false)); } } return table; }
Create create = (Create)command; String tempTableName = create.getTable().getName(); if (contextStore.hasTempTable(tempTableName, true)) { throw new QueryProcessingException(QueryPlugin.Event.TEIID30229, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30229, tempTableName)); contextStore.addForeignTempTable(tempTableName, create); } else { contextStore.addTempTable(tempTableName, create, bufferManager, true, context); contextStore.removeTempTableByName(tempTableName, context); return CollectionTupleSource.createUpdateCountTupleSource(0);
if (tts.getTempTable(tempTableID) == null) { tts.addTempTable(tempTableID, create, buffer, true, context); return getTempTable(tempTableID, command, buffer, delegate, forUpdate, context); TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context); if (tempTable != null) { if (processors != null) { create.setElementSymbolsAsColumns(withProcessor.columns); withProcessor.alterCreate(create); tempTable = addTempTable(tempTableID, create, buffer, true, context); TempTable tt = withProcessor.process(tempTable); if (tt != tempTable) { return parentTempTableStore.getOrCreateTempTable(tempTableID, command, buffer, delegate, forUpdate, context, group); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(columns); return addTempTable(tempTableID, create, buffer, true, context);
/** * @see ProcessorPlan#initialize(ProcessorDataManager, Object) */ public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) { context = context.clone(); setContext(context); TempTableStore tempTableStore = new TempTableStore(context.getConnectionId(), TransactionMode.NONE); tempTableStore.setParentTempTableStore(context.getTempTableStore()); context.setTempTableStore(tempTableStore); this.dataMgr = dataMgr; this.bufferMgr = bufferMgr; this.env.initialize(context, this.dataMgr, this.bufferMgr); }
@Override public List<?> updateMatViewRow(String matTableName, List<?> tuple, boolean delete) throws TeiidComponentException { TempTable tempTable = tableStore.getTempTable(matTableName); if (tempTable != null) { TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName); synchronized (id) { boolean clone = tempTable.getActive().get() != 0; if (clone) { tempTable = tempTable.clone(); } List<?> result = tempTable.updateTuple(tuple, delete); if (clone) { swapTempTable(matTableName, tempTable); } return result; } } return null; }