Search in sources :

Example 16 with ScanResult

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

the class ProjectOp method execute.

@Override
public StatementExecutionResult execute(TableSpaceManager tableSpaceManager, TransactionContext transactionContext, StatementEvaluationContext context, boolean lockRequired, boolean forWrite) throws StatementExecutionException {
    // TODO merge projection + scan + sort + limit
    StatementExecutionResult input = this.input.execute(tableSpaceManager, transactionContext, context, lockRequired, forWrite);
    ScanResult downstream = (ScanResult) input;
    DataScanner dataScanner = downstream.dataScanner;
    DataScanner projected = new ProjectedDataScanner(dataScanner, projection.getFieldNames(), projection.getColumns(), context);
    return new ScanResult(downstream.transactionId, projected);
}
Also used : ScanResult(herddb.model.ScanResult) DataScanner(herddb.model.DataScanner) StatementExecutionResult(herddb.model.StatementExecutionResult)

Example 17 with ScanResult

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

the class SortOp method execute.

@Override
public StatementExecutionResult execute(TableSpaceManager tableSpaceManager, TransactionContext transactionContext, StatementEvaluationContext context, boolean lockRequired, boolean forWrite) throws StatementExecutionException {
    // TODO merge projection + scan + sort + limit
    StatementExecutionResult input = this.input.execute(tableSpaceManager, transactionContext, context, lockRequired, forWrite);
    ScanResult downstreamScanResult = (ScanResult) input;
    final DataScanner inputScanner = downstreamScanResult.dataScanner;
    try (DataScanner dataScanner = inputScanner) {
        MaterializedRecordSet recordSet = tableSpaceManager.getDbmanager().getRecordSetFactory().createRecordSet(inputScanner.getFieldNames(), inputScanner.getSchema());
        while (dataScanner.hasNext()) {
            DataAccessor row = dataScanner.next();
            recordSet.add(row);
        }
        recordSet.writeFinished();
        recordSet.sort(this);
        SimpleDataScanner result = new SimpleDataScanner(downstreamScanResult.transactionId, recordSet);
        return new ScanResult(downstreamScanResult.transactionId, result);
    } catch (DataScannerException ex) {
        throw new StatementExecutionException(ex);
    }
}
Also used : ScanResult(herddb.model.ScanResult) SimpleDataScanner(herddb.core.SimpleDataScanner) DataScanner(herddb.model.DataScanner) MaterializedRecordSet(herddb.core.MaterializedRecordSet) DataAccessor(herddb.utils.DataAccessor) StatementExecutionResult(herddb.model.StatementExecutionResult) SimpleDataScanner(herddb.core.SimpleDataScanner) StatementExecutionException(herddb.model.StatementExecutionException) DataScannerException(herddb.model.DataScannerException)

Example 18 with ScanResult

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

the class AggregateOp method execute.

@Override
public StatementExecutionResult execute(TableSpaceManager tableSpaceManager, TransactionContext transactionContext, StatementEvaluationContext context, boolean lockRequired, boolean forWrite) throws StatementExecutionException {
    StatementExecutionResult input = this.input.execute(tableSpaceManager, transactionContext, context, lockRequired, forWrite);
    ScanResult downstreamScanResult = (ScanResult) input;
    final DataScanner inputScanner = downstreamScanResult.dataScanner;
    AggregatedDataScanner filtered = new AggregatedDataScanner(inputScanner, context, tableSpaceManager.getDbmanager().getRecordSetFactory());
    return new ScanResult(downstreamScanResult.transactionId, filtered);
}
Also used : ScanResult(herddb.model.ScanResult) SimpleDataScanner(herddb.core.SimpleDataScanner) DataScanner(herddb.model.DataScanner) StatementExecutionResult(herddb.model.StatementExecutionResult)

Aggregations

ScanResult (herddb.model.ScanResult)18 DataScanner (herddb.model.DataScanner)14 DataScannerException (herddb.model.DataScannerException)11 StatementExecutionException (herddb.model.StatementExecutionException)11 StatementExecutionResult (herddb.model.StatementExecutionResult)10 DataAccessor (herddb.utils.DataAccessor)10 TransactionContext (herddb.model.TransactionContext)9 DMLStatementExecutionResult (herddb.model.DMLStatementExecutionResult)5 DMLStatement (herddb.model.DMLStatement)4 LimitedDataScanner (herddb.model.LimitedDataScanner)4 Table (herddb.model.Table)4 SimpleDataScanner (herddb.core.SimpleDataScanner)3 ScanStatement (herddb.model.commands.ScanStatement)3 ArrayList (java.util.ArrayList)3 MemoryMetadataStorageManager (herddb.mem.MemoryMetadataStorageManager)2 Column (herddb.model.Column)2 NotLeaderException (herddb.model.NotLeaderException)2 InsertStatement (herddb.model.commands.InsertStatement)2 RawKeyEquals (herddb.model.predicates.RawKeyEquals)2 TranslatedQuery (herddb.sql.TranslatedQuery)2