@Override public boolean needsLoading(String matTableName, Serializable loadingAddress, boolean firstPass, boolean refresh, boolean invalidate) { MatTableInfo info = getMatTableInfo(matTableName); return info.shouldLoad(loadingAddress, firstPass, refresh, invalidate); }
@Override public boolean needsLoading(String matTableName, Serializable loadingAddress, boolean firstPass, boolean refresh, boolean invalidate) { MatTableInfo info = getMatTableInfo(matTableName); return info.shouldLoad(loadingAddress, firstPass, refresh, invalidate); }
@Override public boolean needsLoading(String matTableName, Serializable loadingAddress, boolean firstPass, boolean refresh, boolean invalidate) { MatTableInfo info = getMatTableInfo(matTableName); return info.shouldLoad(loadingAddress, firstPass, refresh, invalidate); }
@Override public void failedLoad(String matTableName) { MatTableInfo info = getMatTableInfo(matTableName); synchronized (info) { if (info.state != MatState.LOADED) { info.setState(MatState.FAILED_LOAD, null); } } }
@Override public void failedLoad(String matTableName) { MatTableInfo info = getMatTableInfo(matTableName); synchronized (info) { if (info.state != MatState.LOADED) { info.setState(MatState.FAILED_LOAD, null); } } }
@Override public void failedLoad(String matTableName) { MatTableInfo info = getMatTableInfo(matTableName); synchronized (info) { if (info.state != MatState.LOADED) { info.setState(MatState.FAILED_LOAD, null); } } }
@Override public void loaded(String matTableName, TempTable table) { swapTempTable(matTableName, table); this.getMatTableInfo(matTableName).setState(MatState.LOADED, true); }
@Override public void loaded(String matTableName, TempTable table) { swapTempTable(matTableName, table); this.getMatTableInfo(matTableName).setState(MatState.LOADED, true); }
@Override public void loaded(String matTableName, TempTable table) { swapTempTable(matTableName, table); this.getMatTableInfo(matTableName).setState(MatState.LOADED, true); }
private void sendTable(String stateId, ObjectOutputStream oos, boolean writeName) throws IOException, TeiidComponentException { TempTable tempTable = this.tableStore.getTempTable(stateId); if (tempTable == null) { return; } MatTableInfo info = getMatTableInfo(stateId); if (!info.isValid()) { return; } if (writeName) { oos.writeObject(stateId); } oos.writeLong(info.updateTime); oos.writeObject(info.loadingAddress); oos.writeObject(info.state); tempTable.writeTo(oos); }
private void sendTable(String stateId, ObjectOutputStream oos, boolean writeName) throws IOException, TeiidComponentException { TempTable tempTable = this.tableStore.getTempTable(stateId); if (tempTable == null) { return; } MatTableInfo info = getMatTableInfo(stateId); if (!info.isValid()) { return; } if (writeName) { oos.writeObject(stateId); } oos.writeLong(info.updateTime); oos.writeObject(info.loadingAddress); oos.writeObject(info.state); tempTable.writeTo(oos); }
private void sendTable(String stateId, ObjectOutputStream oos, boolean writeName) throws IOException, TeiidComponentException { TempTable tempTable = this.tableStore.getTempTable(stateId); if (tempTable == null) { return; } MatTableInfo info = getMatTableInfo(stateId); if (!info.isValid()) { return; } if (writeName) { oos.writeObject(stateId); } oos.writeLong(info.updateTime); oos.writeObject(info.loadingAddress); oos.writeObject(info.state); tempTable.writeTo(oos); }
@Override public void setState(String stateId, InputStream istream) { try { ObjectInputStream ois = new ObjectInputStream(istream); loadTable(stateId, ois); ois.close(); } catch (Exception e) { MatTableInfo info = this.getMatTableInfo(stateId); if (!info.isUpToDate()) { info.setState(MatState.FAILED_LOAD, null); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30222, e); } }
@Override public void setState(String stateId, InputStream istream) { try { ObjectInputStream ois = new ObjectInputStream(istream); loadTable(stateId, ois); ois.close(); } catch (Exception e) { MatTableInfo info = this.getMatTableInfo(stateId); if (!info.isUpToDate()) { info.setState(MatState.FAILED_LOAD, null); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30222, e); } }
@Override public void setState(String stateId, InputStream istream) { try { ObjectInputStream ois = new ObjectInputStream(istream); loadTable(stateId, ois); ois.close(); } catch (Exception e) { MatTableInfo info = this.getMatTableInfo(stateId); if (!info.isUpToDate()) { info.setState(MatState.FAILED_LOAD, null); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30222, e); } }
MatTableInfo info = this.getMatTableInfo(stateId); synchronized (info) { swapTempTable(stateId, tempTable);
@Test public void testReadWrite() throws Exception { execute("SELECT * from vgroup3 where x = 'one'", Arrays.asList("one", "zne")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); String matTableName = RelationalPlanner.MAT_PREFIX + "MATVIEW.VGROUP3"; this.globalStore.getState(matTableName, baos); MatTableInfo matTableInfo = this.globalStore.getMatTableInfo(matTableName); long time = matTableInfo.getUpdateTime(); this.globalStore.failedLoad(matTableName); this.globalStore.setState(matTableName, new ByteArrayInputStream(baos.toByteArray())); assertEquals(time, matTableInfo.getUpdateTime()); execute("SELECT * from vgroup3 where x = 'one'", Arrays.asList("one", "zne")); execute("select lookup('mattable.info', 'e1', 'e2', 5)", Arrays.asList((String)null)); baos = new ByteArrayOutputStream(); String codeTableName = "#CODE_MATTABLE.INFO.E2.E1"; this.globalStore.getState(codeTableName, baos); this.globalStore.setState(codeTableName, new ByteArrayInputStream(baos.toByteArray())); }
@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; }
@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; }
@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; }