Search in sources :

Example 31 with Record

use of herddb.model.Record in project herddb by diennea.

the class SysindexcolumnsTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) {
    List<Table> tables = tableSpaceManager.getAllVisibleTables(transaction);
    List<Record> result = new ArrayList<>();
    tables.forEach(r -> {
        // PK
        int posPk = 0;
        for (String pk : r.getPrimaryKey()) {
            Column column = r.getColumn(pk);
            String indexName = BLinkKeyToPageIndex.deriveIndexName(r.name);
            result.add(RecordSerializer.makeRecord(table, "index_type", "pk", "column_name", column.name, "ordinal_position", posPk++, "clustered", 1, "unique", 1, "tablespace", r.tablespace, "table_name", r.name, "index_name", indexName, // uuid = index_name in BLink !
            "index_uuid", // uuid = index_name in BLink !
            indexName));
        }
        Map<String, AbstractIndexManager> indexesOnTable = tableSpaceManager.getIndexesOnTable(r.name);
        if (indexesOnTable != null) {
            indexesOnTable.values().forEach(indexManager -> {
                Index index = indexManager.getIndex();
                int pos = 0;
                for (Column cc : index.getColumns()) {
                    result.add(RecordSerializer.makeRecord(table, "tablespace", r.tablespace, "table_name", r.name, "index_name", index.name, "index_uuid", index.uuid, "index_type", index.type, "column_name", cc.name, "ordinal_position", pos++, "clustered", 0, "unique", index.unique ? 1 : 0));
                }
            });
        }
    });
    return result;
}
Also used : Table(herddb.model.Table) AbstractIndexManager(herddb.core.AbstractIndexManager) Column(herddb.model.Column) ArrayList(java.util.ArrayList) Record(herddb.model.Record) Index(herddb.model.Index) BLinkKeyToPageIndex(herddb.index.blink.BLinkKeyToPageIndex)

Example 32 with Record

use of herddb.model.Record in project herddb by diennea.

the class SysstatementsTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) {
    ConcurrentHashMap<Long, RunningStatementInfo> runningStatements = tableSpaceManager.getDbmanager().getRunningStatements().getRunningStatements();
    List<Record> result = new ArrayList<>();
    long now = System.currentTimeMillis();
    for (RunningStatementInfo info : runningStatements.values()) {
        result.add(RecordSerializer.makeRecord(table, "id", info.getId(), "tablespace", info.getTablespace(), "query", info.getQuery(), "startts", new java.sql.Timestamp(info.getStartTimestamp()), "runningtime", (now - info.getStartTimestamp()), "batches", info.getNumBatches(), "info", info.getInfo()));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Record(herddb.model.Record) RunningStatementInfo(herddb.core.RunningStatementInfo)

Example 33 with Record

use of herddb.model.Record in project herddb by diennea.

the class SysnodesTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) throws StatementExecutionException {
    try {
        Collection<NodeMetadata> nodes = tableSpaceManager.getMetadataStorageManager().listNodes();
        List<Record> result = new ArrayList<>();
        for (NodeMetadata t : nodes) {
            result.add(RecordSerializer.makeRecord(table, "nodeid", t.nodeId, "address", t.host + ":" + t.port, "ssl", t.ssl ? 1 : 0));
        }
        return result;
    } catch (MetadataStorageManagerException error) {
        throw new StatementExecutionException(error);
    }
}
Also used : NodeMetadata(herddb.model.NodeMetadata) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) ArrayList(java.util.ArrayList) Record(herddb.model.Record) StatementExecutionException(herddb.model.StatementExecutionException)

Example 34 with Record

use of herddb.model.Record in project herddb by diennea.

the class SystablespacesTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) throws StatementExecutionException {
    try {
        Collection<String> names = tableSpaceManager.getMetadataStorageManager().listTableSpaces();
        List<Record> result = new ArrayList<>();
        for (String name : names) {
            TableSpace t = tableSpaceManager.getMetadataStorageManager().describeTableSpace(name);
            if (t != null) {
                result.add(RecordSerializer.makeRecord(table, "tablespace_name", t.name, "uuid", t.uuid, "leader", t.leaderId, "expectedreplicacount", t.expectedReplicaCount, "maxleaderinactivitytime", t.maxLeaderInactivityTime, "replica", t.replicas.stream().collect(Collectors.joining(","))));
            }
        }
        return result;
    } catch (MetadataStorageManagerException error) {
        throw new StatementExecutionException(error);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) TableSpace(herddb.model.TableSpace) ArrayList(java.util.ArrayList) Record(herddb.model.Record) StatementExecutionException(herddb.model.StatementExecutionException)

Example 35 with Record

use of herddb.model.Record in project herddb by diennea.

the class SystransactionsTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) {
    List<Transaction> transactions = tableSpaceManager.getTransactions();
    List<Record> result = new ArrayList<>();
    for (Transaction tx : transactions) {
        result.add(RecordSerializer.makeRecord(table, "tablespace", tableSpaceManager.getTableSpaceName(), "txid", tx.transactionId, "creationtimestamp", new java.sql.Timestamp(tx.localCreationTimestamp)));
    }
    return result;
}
Also used : Transaction(herddb.model.Transaction) ArrayList(java.util.ArrayList) Record(herddb.model.Record)

Aggregations

Record (herddb.model.Record)146 InsertStatement (herddb.model.commands.InsertStatement)82 Bytes (herddb.utils.Bytes)82 Test (org.junit.Test)75 Table (herddb.model.Table)72 GetResult (herddb.model.GetResult)67 GetStatement (herddb.model.commands.GetStatement)64 TransactionContext (herddb.model.TransactionContext)59 CreateTableStatement (herddb.model.commands.CreateTableStatement)44 ArrayList (java.util.ArrayList)42 CreateTableSpaceStatement (herddb.model.commands.CreateTableSpaceStatement)37 DeleteStatement (herddb.model.commands.DeleteStatement)36 UpdateStatement (herddb.model.commands.UpdateStatement)36 HashMap (java.util.HashMap)36 Path (java.nio.file.Path)34 BeginTransactionStatement (herddb.model.commands.BeginTransactionStatement)33 StatementExecutionException (herddb.model.StatementExecutionException)32 TransactionResult (herddb.model.TransactionResult)31 DMLStatementExecutionResult (herddb.model.DMLStatementExecutionResult)29 CommitTransactionStatement (herddb.model.commands.CommitTransactionStatement)28