Create D4M tables.

Five Accumulo tables support D4M. This method creates them
using the default root (unless the caller changes that default).

Tedge, TedgeTranspose, TedgeDegree, TedgeMetadata, TedgeText
323313
public void createTables() {
        Validate.notNull(connector, "connector must not be null");
        Validate.notNull(tableOperations, "tableOperations must not be null");

        /*
         * This code sets the default values. If you want to change them,
         * you can over-write the metadata entries instead of changing
         * the values here.
         */
        Value defaultFieldDelimiter = new Value("\t".getBytes(charset));
        Value defaultFactDelimiter = new Value("|".getBytes(charset));

        int isEdgePresent = tableOperations.exists(getEdgeTable()) ? 1 : 0;
        int isTransposePresent = tableOperations.exists(getTransposeTable()) ? 1 : 0;
        int isDegreePresent = tableOperations.exists(getDegreeTable()) ? 1 : 0;
        int isMetatablePresent = tableOperations.exists(getMetadataTable()) ? 1 : 0;
        int isTextPresent = tableOperations.exists(getTextTable()) ? 1 : 0;

        int tableCount = isEdgePresent + isTransposePresent + isDegreePresent + isMetatablePresent + isTextPresent;

        if (tableCount > 0 && tableCount < 5) {
            throw new D4MException("D4M: RootName[" + getRootName() + "] Inconsistent state - one or more D4M tables is missing.");
        }

        if (tableCount == 5) {
            // assume the tables are correct.
            return;
        }

        try {
            tableOperations.create(getEdgeTable());
            tableOperations.create(getTransposeTable());
            tableOperations.create(getDegreeTable());
            tableOperations.create(getMetadataTable());
            tableOperations.create(getTextTable());

            IteratorSetting degreeIteratorSetting = new IteratorSetting(7, SummingCombiner.class);
            SummingCombiner.setEncodingType(degreeIteratorSetting, LongCombiner.Type.STRING);
            SummingCombiner.setColumns(degreeIteratorSetting, Collections.singletonList(new IteratorSetting.Column("", "degree")));
            tableOperations.attachIterator(getDegreeTable(), degreeIteratorSetting);

            IteratorSetting fieldIteratorSetting = new IteratorSetting(7, SummingCombiner.class);
            SummingCombiner.setEncodingType(fieldIteratorSetting, LongCombiner.Type.STRING);
            SummingCombiner.setColumns(fieldIteratorSetting, Collections.singletonList(new IteratorSetting.Column("field", "")));
            tableOperations.attachIterator(getMetadataTable(), fieldIteratorSetting);

            Mutation mutation = new Mutation(PROPERTY);
            mutation.put(FIELD_DELIMITER_PROPERTY_NAME, EMPTY_CQ, defaultFieldDelimiter);
            mutation.put(FACT_DELIMITER_PROPERTY_NAME, EMPTY_CQ, defaultFactDelimiter);
            
            BatchWriterConfig bwConfig = new BatchWriterConfig();
            bwConfig.setMaxLatency(10000, TimeUnit.MINUTES);
            bwConfig.setMaxMemory(10000000);
            bwConfig.setMaxWriteThreads(5);
            bwConfig.setTimeout(5, TimeUnit.MINUTES);
            
            BatchWriter writer = connector.createBatchWriter(getMetadataTable(), bwConfig);
            writer.addMutation(mutation);
            writer.close();
        } catch (AccumuloException | AccumuloSecurityException | TableExistsException | TableNotFoundException e) {
            throw new D4MException("Error creating tables.", e);
        }

    }
56862
def create_node_tables(self):
        
        self.cursor.execute('PRAGMA foreign_keys=1')
        self.cursor.execute('''
            CREATE TABLE IF NOT EXISTS datasets (
                id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                key TEXT NOT NULL
            )
        ''')
        self.cursor.execute('''
            CREATE TABLE IF NOT EXISTS nodes (
                id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                value TEXT NOT NULL
            )
        ''')
        self.cursor.execute('''
            CREATE TABLE IF NOT EXISTS links (
                dataset REFERENCES datasets (id),
                source REFERENCES nodes (id),
                target REFERENCES nodes (id),
                value TEXT,
                bvalue TEXT,
                count INTEGER NOT NULL DEFAULT 1
            )
        ''')
        self.cursor.execute(
            'CREATE UNIQUE INDEX IF NOT EXISTS node ON nodes (value)'
        )
        self.cursor.execute(
            'CREATE INDEX IF NOT EXISTS link_source ON links (source, dataset)'
        )
        self.cursor.execute(
            'CREATE INDEX IF NOT EXISTS link_target ON links (target, dataset)'
        )
384324
def create_table(self):
        

        all_tables = self.aws_conn.list_tables()['TableNames']

        if self.table_name in all_tables:
            log.info("Table %s already exists" % self.table_name)
        else:
            log.info("Table %s does not exist: creating it" % self.table_name)

            self.table = Table.create(
                self.table_name,
                schema=[
                    HashKey('key')
                ],
                throughput={
                    'read': 10,
                    'write': 10,
                },
                connection=self.aws_conn,
            )
77148
def _CreateDatabase(self):
    
    goodlogging.Log.Info("DB", "Initialising new database", verbosity=self.logVerbosity)

    with sqlite3.connect(self._dbPath) as db:
      # Configuration tables
      db.execute("CREATE TABLE Config ("
                  "Name TEXT UNIQUE NOT NULL, "
                  "Value TEXT)")

      db.execute("CREATE TABLE IgnoredDir ("
                  "DirName TEXT UNIQUE NOT NULL)")

      db.execute("CREATE TABLE SupportedFormat ("
                  "FileFormat TEXT UNIQUE NOT NULL)")

      # Look-up tables
      db.execute("CREATE TABLE TVLibrary ("
                  "ShowID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
                  "ShowName TEXT UNIQUE NOT NULL, "
                  "ShowDir TEXT UNIQUE)")

      db.execute("CREATE TABLE FileName ("
                  "FileName TEXT UNIQUE NOT NULL, "
                  "ShowID INTEGER, "
                  "FOREIGN KEY (ShowID) REFERENCES ShowName(ShowID))")

      db.execute("CREATE TABLE SeasonDir ("
                  "ShowID INTEGER, "
                  "Season INTEGER NOT NULL, "
                  "SeasonDir TEXT NOT NULL, "
                  "FOREIGN KEY (ShowID) REFERENCES ShowName(ShowID),"
                  "CONSTRAINT SeasonDirPK PRIMARY KEY (ShowID,Season))")

      db.commit()

    goodlogging.Log.Info("DB", "Database initialisation complete", verbosity=self.logVerbosity)
305935
private void createTables() throws SQLException {
        Statement stmt = this.conn.createStatement();

        stmt.execute(DbConstants.DROP_METADATA_STATEMENT);
        stmt.execute(DbConstants.DROP_INDEX_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.DROP_DATA_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORIES_STATEMENT);

        stmt.execute(DbConstants.CREATE_CATEGORIES_STATEMENT);
        stmt.execute(DbConstants.CREATE_DATA_STATEMENT);
        stmt.execute(DbConstants.CREATE_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.CREATE_INDEX_STATEMENT);
        stmt.execute(DbConstants.CREATE_METADATA_STATEMENT);

        stmt.close();
    }
738304
public static RowSchema fromColumns(List<AccumuloColumnHandle> columns)
    {
        RowSchema schema = new RowSchema();
        for (AccumuloColumnHandle columnHandle : columns) {
            schema.addColumn(
                    columnHandle.getName(),
                    columnHandle.getFamily(),
                    columnHandle.getQualifier(),
                    columnHandle.getType(),
                    columnHandle.isIndexed());
        }
        return schema;
    }
1269315
def _create_sqlite_metatable(self):
        
        sys.stderr.write("Indexing schema. This will take a second...")
        rows_to_insert = []
        tables = [row[0] for row in self.cur.execute("select name from sqlite_master where type='table';")]
        for table in tables:
            for row in self.cur.execute("pragma table_info('{0}')".format(table)):
                rows_to_insert.append((table, row[1], row[2]))
        # find for table and column names
        self.cur.execute("drop table if exists tmp_dbpy_schema;")
        self.cur.execute("create temp table tmp_dbpy_schema(table_name varchar, column_name varchar, data_type varchar);")
        for row in rows_to_insert:
            self.cur.execute("insert into tmp_dbpy_schema(table_name, column_name, data_type) values('{0}', '{1}', '{2}');".format(*row))
        self.cur.execute("SELECT name, sql  FROM sqlite_master where sql like '%REFERENCES%';")

        # find for foreign keys
        self.cur.execute("drop table if exists tmp_dbpy_foreign_keys;")
        self.cur.execute("create temp table tmp_dbpy_foreign_keys(table_name varchar, column_name varchar, foreign_table varchar, foreign_column varchar);")
        foreign_keys = []
        self.cur.execute("SELECT name, sql  FROM sqlite_master ;")
        for (table_name, sql) in self.cur:
            rgx = "FOREIGN KEY \(\[(.*)\]\) REFERENCES \[(.*)\] \(\[(.*)\]\)"
            if sql is None:
                continue
            for (column_name, foreign_table, foreign_key) in re.findall(rgx, sql):
                foreign_keys.append((table_name, column_name, foreign_table, foreign_key))
        for row in foreign_keys:
            sql_insert = "insert into tmp_dbpy_foreign_keys(table_name, column_name, foreign_table, foreign_column) values('{0}', '{1}', '{2}', '{3}');"
            self.cur.execute(sql_insert.format(*row))

        self.con.commit()
        sys.stderr.write("finished!\n")
451484
def createTable(dbconn, pd):
    """"""
    cols = ('%s %s' % (defn.name, getTypename(defn)) for defn in pd.fields)
    sql  = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (pd.name, ', '.join(cols))

    dbconn.execute(sql)
    dbconn.commit()
293862
def create_table(group, name, dtype, **attributes):
    """"""
    dset = group.create_dataset(
        name, shape=(0,), dtype=dtype, maxshape=(None,))
    set_attributes(dset, **attributes)
    return dset
1197926
function createTables() {
  return bluebird.all(getComponents().map(component => client.createTable(`components.${component}`)))
    .then(() => bluebird.all(getLayouts().map(layout => client.createTableWithMeta(`layouts.${layout}`))))
    .then(() => client.createTableWithMeta('pages'))
    .then(() => client.raw('CREATE TABLE IF NOT EXISTS ?? ( id TEXT PRIMARY KEY NOT NULL, data TEXT NOT NULL, url TEXT );', ['uris']))
    .then(() => createRemainingTables());
}
763883
def _create_tables(self):
        
        cursor = self.conn.cursor()

        create_cmd = """CREATE TABLE IF NOT EXISTS {} (
        fully_qualified_subdomain TEXT NOT NULL,
        domain TEXT NOT NULL,
        sequence INTEGER NOT NULL,
        owner TEXT NOT NULL,
        zonefile_hash TEXT NOT NULL,
        signature TEXT NOT NULL,
        block_height INTEGER NOT NULL,
        parent_zonefile_hash TEXT NOT NULL,
        parent_zonefile_index INTEGER NOT NULL,
        zonefile_offset INTEGER NOT NULL,
        txid TEXT NOT NULL,
        missing TEXT NOT NULL,
        accepted INTEGER NOT NULL,
        resolver TEXT,
        PRIMARY KEY(fully_qualified_subdomain,parent_zonefile_index));
        """.format(self.subdomain_table)
        db_query_execute(cursor, create_cmd, ())

        # set up a queue as well
        queue_con = queuedb_open(self.queue_path)
        queue_con.close()
1370959
public TableMetaReader createTableMetaReader(
      GenDialect dialect,
      DataSource dataSource,
      String schemaName,
      String tableNamePattern,
      String ignoredTableNamePattern,
      List<String> tableTypes) {
    return new TableMetaReader(
        dialect, dataSource, schemaName, tableNamePattern, ignoredTableNamePattern, tableTypes);
  }
477414
public Table createTable(String tableName,
            List<KeySchemaElement> keySchema,
            List<AttributeDefinition> attributeDefinitions,
            ProvisionedThroughput provisionedThroughput) {
        return createTable(new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attributeDefinitions)
            .withProvisionedThroughput(provisionedThroughput));
    }
413257
TwoDimTable createSummaryTable() {
    TwoDimTable table = new TwoDimTable(
        "Status of Deep Learning Model",
        (get_params()._network == null ? ("MLP: " + Arrays.toString(get_params()._hidden)) : get_params()._network.toString()) + ", " + PrettyPrint.bytes(size()) + ", "
        + (!get_params()._autoencoder ? ("predicting " + get_params()._response_column + ", ") : "") +
            (get_params()._autoencoder ? "auto-encoder" :
                _classification ? (_classes + "-class classification") : "regression")
            + ", "
            + String.format("%,d", get_processed_global()) + " training samples, "
            + "mini-batch size " + String.format("%,d", get_params()._mini_batch_size),
        new String[1], //rows
        new String[]{"Input Neurons", "Rate", "Momentum" },
        new String[]{"int", "double", "double" },
        new String[]{"%d", "%5f", "%5f"},
        "");
    table.set(0, 0, _dataInfo!=null ? _dataInfo.fullN() : _width * _height * _channels);
    table.set(0, 1, get_params().learningRate(get_processed_global()));
    table.set(0, 2, get_params().momentum(get_processed_global()));
    summaryTable = table;
    return summaryTable;
  }
523946
private WDataTable createTable() {
		WDataTable tbl = new WDataTable();
		tbl.addColumn(new WTableColumn("First name", new WTextField()));
		tbl.addColumn(new WTableColumn("Last name", new WTextField()));
		tbl.addColumn(new WTableColumn("DOB", new WDateField()));
		tbl.setExpandMode(ExpandMode.CLIENT);

		TableTreeNode root = createTree();
		tbl.setDataModel(new ExampleTreeTableModel(root));

		return tbl;
	}
246440
LogMetadata addLedger(long ledgerId) {
        Preconditions.checkState(this.enabled, "Log is not enabled. Cannot perform any modifications on it.");

        // Copy existing ledgers.
        List<LedgerMetadata> newLedgers = new ArrayList<>(this.ledgers.size() + 1);
        newLedgers.addAll(this.ledgers);

        // Create and add metadata for the new ledger.
        int sequence = this.ledgers.size() == 0 ? INITIAL_LEDGER_SEQUENCE : this.ledgers.get(this.ledgers.size() - 1).getSequence() + 1;
        newLedgers.add(new LedgerMetadata(ledgerId, sequence));
        return new LogMetadata(this.epoch + 1, this.enabled, Collections.unmodifiableList(newLedgers), this.truncationAddress, this.updateVersion.get());
    }
196528
private WDataTable createTable() {
		WDataTable tbl = new WDataTable();
		tbl.addColumn(new WTableColumn("First name", new WTextField()));
		tbl.addColumn(new WTableColumn("Last name", new WTextField()));
		tbl.addColumn(new WTableColumn("DOB", new WDateField()));
		return tbl;
	}