/** * Constructor used for read operations. The table is used to obtain data used to lay out memory * for the result. * * @param storeTable the table * @param operation the operation * @param transaction the transaction */ public OperationImpl( Table storeTable, NdbOperation operation, ClusterTransactionImpl transaction) { this(operation, transaction); TableImpl tableImpl = (TableImpl) storeTable; this.maximumColumnId = tableImpl.getMaximumColumnId(); this.bufferSize = tableImpl.getBufferSize(); this.offsets = tableImpl.getOffsets(); this.lengths = tableImpl.getLengths(); this.maximumColumnLength = tableImpl.getMaximumColumnLength(); }
@Override public TableImpl createTable(String name) throws IllegalArgumentException { Utility.checkTableNameIsCorrect(name); Path tablePath = databaseRoot.resolve(name); if (tables.containsKey(name) && tables.get(name) != null) { return null; } TableImpl newTable; try { newTable = TableImpl.createTable(tablePath); } catch (DatabaseException exc) { throw new IllegalArgumentException(exc.getMessage(), exc); } tables.put(name, newTable); return newTable; }
/** * Scans database directory and reads all tables from it. * * @throws DatabaseException */ private void reloadTables() throws DatabaseException { tables.clear(); try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(databaseRoot)) { for (Path tablePath : dirStream) { String tableName = tablePath.getFileName().toString(); try { TableImpl table = TableImpl.getTable(tablePath); tables.put(tableName, table); } catch (DatabaseException exc) { // mark as corrupt tables.put(tableName, null); corruptTables.put( tableName, (exc instanceof TableCorruptException ? (TableCorruptException) exc : new TableCorruptException(tableName, exc.getMessage(), exc))); } } } catch (IOException exc) { throw new DatabaseException("Failed to scan database directory", exc); } }