Search in sources :

Example 6 with DeleteStatement

use of herddb.model.commands.DeleteStatement in project herddb by diennea.

the class CalcitePlanner method planDelete.

private PlannerOp planDelete(EnumerableTableModify dml) {
    PlannerOp input = convertRelNode(dml.getInput(), null, false, false);
    final String tableSpace = dml.getTable().getQualifiedName().get(0);
    final String tableName = dml.getTable().getQualifiedName().get(1);
    final TableImpl tableImpl = (TableImpl) dml.getTable().unwrap(org.apache.calcite.schema.Table.class);
    Table table = tableImpl.tableManager.getTable();
    DeleteStatement delete = null;
    if (input instanceof TableScanOp) {
        delete = new DeleteStatement(tableSpace, tableName, null, null);
    } else if (input instanceof FilterOp) {
        FilterOp filter = (FilterOp) input;
        if (filter.getInput() instanceof TableScanOp) {
            SQLRecordPredicate pred = new SQLRecordPredicate(table, null, filter.getCondition());
            delete = new DeleteStatement(tableSpace, tableName, null, pred);
        }
    } else if (input instanceof BindableTableScanOp) {
        BindableTableScanOp filter = (BindableTableScanOp) input;
        Predicate pred = filter.getStatement().getPredicate();
        delete = new DeleteStatement(tableSpace, tableName, null, pred);
    }
    if (delete != null) {
        return new SimpleDeleteOp(delete);
    } else {
        return new DeleteOp(tableSpace, tableName, input);
    }
}
Also used : PlannerOp(herddb.model.planner.PlannerOp) Table(herddb.model.Table) ShowCreateTableCalculator.calculateShowCreateTable(herddb.sql.functions.ShowCreateTableCalculator.calculateShowCreateTable) SqlStdOperatorTable(org.apache.calcite.sql.fun.SqlStdOperatorTable) RelOptTable(org.apache.calcite.plan.RelOptTable) ProjectableFilterableTable(org.apache.calcite.schema.ProjectableFilterableTable) ScannableTable(org.apache.calcite.schema.ScannableTable) AbstractTable(org.apache.calcite.schema.impl.AbstractTable) ModifiableTable(org.apache.calcite.schema.ModifiableTable) FilteredTableScanOp(herddb.model.planner.FilteredTableScanOp) BindableTableScanOp(herddb.model.planner.BindableTableScanOp) TableScanOp(herddb.model.planner.TableScanOp) FilterOp(herddb.model.planner.FilterOp) DeleteStatement(herddb.model.commands.DeleteStatement) Predicate(herddb.model.Predicate) SimpleDeleteOp(herddb.model.planner.SimpleDeleteOp) DeleteOp(herddb.model.planner.DeleteOp) SimpleDeleteOp(herddb.model.planner.SimpleDeleteOp) BindableTableScanOp(herddb.model.planner.BindableTableScanOp)

Example 7 with DeleteStatement

use of herddb.model.commands.DeleteStatement in project herddb by diennea.

the class SimpleCDCTest method testBasicCaptureDataChange.

@Test
public void testBasicCaptureDataChange() throws Exception {
    ServerConfiguration serverconfig_1 = newServerConfigurationWithAutoPort(folder.newFolder().toPath());
    serverconfig_1.set(ServerConfiguration.PROPERTY_NODEID, "server1");
    serverconfig_1.set(ServerConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
    ClientConfiguration client_configuration = new ClientConfiguration(folder.newFolder().toPath());
    client_configuration.set(ClientConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
    try (Server server_1 = new Server(serverconfig_1)) {
        server_1.start();
        server_1.waitForStandaloneBoot();
        Table table = Table.builder().name("t1").column("c", ColumnTypes.INTEGER).column("d", ColumnTypes.INTEGER).primaryKey("c").build();
        server_1.getManager().executeStatement(new CreateTableStatement(table), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 1, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 2, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        long tx = TestUtils.beginTransaction(server_1.getManager(), TableSpace.DEFAULT);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 3, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx));
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 4, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx));
        List<ChangeDataCapture.Mutation> mutations = new ArrayList<>();
        try (final ChangeDataCapture cdc = new ChangeDataCapture(server_1.getManager().getTableSpaceManager(TableSpace.DEFAULT).getTableSpaceUUID(), client_configuration, new ChangeDataCapture.MutationListener() {

            @Override
            public void accept(ChangeDataCapture.Mutation mutation) {
                LOG.log(Level.INFO, "mutation " + mutation);
                assertTrue(mutation.getTimestamp() > 0);
                assertNotNull(mutation.getLogSequenceNumber());
                assertNotNull(mutation.getTable());
                mutations.add(mutation);
            }
        }, LogSequenceNumber.START_OF_TIME, new InMemoryTableHistoryStorage())) {
            cdc.start();
            cdc.run();
            // we are missing the last entry, because it is not confirmed yet on BookKeeper at this point
            // also the mutations in the transaction are not visible
            assertEquals(3, mutations.size());
            // commit the transaction
            TestUtils.commitTransaction(server_1.getManager(), TableSpace.DEFAULT, tx);
            server_1.getManager().executeUpdate(new UpdateStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 4, "d", 2), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            cdc.run();
            assertEquals(5, mutations.size());
            server_1.getManager().executeStatement(new AlterTableStatement(Arrays.asList(Column.column("e", ColumnTypes.INTEGER)), Collections.emptyList(), Collections.emptyList(), null, table.name, TableSpace.DEFAULT, null, Collections.emptyList(), Collections.emptyList()), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            cdc.run();
            assertEquals(6, mutations.size());
            // transaction to be rolled back
            long tx2 = TestUtils.beginTransaction(server_1.getManager(), TableSpace.DEFAULT);
            server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 30, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx2));
            server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 31, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx2));
            TestUtils.roolbackTransaction(server_1.getManager(), TableSpace.DEFAULT, tx2);
            // nothing is to be sent to CDC
            cdc.run();
            assertEquals(7, mutations.size());
            server_1.getManager().executeUpdate(new DeleteStatement(TableSpace.DEFAULT, "t1", Bytes.from_int(1), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            cdc.run();
            assertEquals(7, mutations.size());
            // close the server...close the ledger, now we can read the last mutation
            server_1.close();
            cdc.run();
            assertEquals(8, mutations.size());
            int i = 0;
            assertEquals(ChangeDataCapture.MutationType.CREATE_TABLE, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.UPDATE, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.ALTER_TABLE, mutations.get(i++).getMutationType());
            assertEquals(ChangeDataCapture.MutationType.DELETE, mutations.get(i++).getMutationType());
        }
    }
}
Also used : UpdateStatement(herddb.model.commands.UpdateStatement) Table(herddb.model.Table) Server(herddb.server.Server) AlterTableStatement(herddb.model.commands.AlterTableStatement) ServerConfiguration(herddb.server.ServerConfiguration) CreateTableStatement(herddb.model.commands.CreateTableStatement) ArrayList(java.util.ArrayList) DeleteStatement(herddb.model.commands.DeleteStatement) InsertStatement(herddb.model.commands.InsertStatement) TransactionContext(herddb.model.TransactionContext) ClientConfiguration(herddb.client.ClientConfiguration) Test(org.junit.Test)

Example 8 with DeleteStatement

use of herddb.model.commands.DeleteStatement in project herddb by diennea.

the class SimpleCDCTest method testBasicCaptureDataChangeWithRestart.

@Test
public void testBasicCaptureDataChangeWithRestart() throws Exception {
    ServerConfiguration serverconfig_1 = newServerConfigurationWithAutoPort(folder.newFolder().toPath());
    serverconfig_1.set(ServerConfiguration.PROPERTY_NODEID, "server1");
    serverconfig_1.set(ServerConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
    serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
    ClientConfiguration client_configuration = new ClientConfiguration(folder.newFolder().toPath());
    client_configuration.set(ClientConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
    client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
    try (Server server_1 = new Server(serverconfig_1)) {
        server_1.start();
        server_1.waitForStandaloneBoot();
        Table table = Table.builder().name("t1").column("c", ColumnTypes.INTEGER).column("d", ColumnTypes.INTEGER).primaryKey("c").build();
        server_1.getManager().executeStatement(new CreateTableStatement(table), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 1, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 2, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 3, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        server_1.getManager().executeUpdate(new InsertStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 4, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        InMemoryTableHistoryStorage tableHistoryStorage = new InMemoryTableHistoryStorage();
        LogSequenceNumber currentPosition = LogSequenceNumber.START_OF_TIME;
        List<ChangeDataCapture.Mutation> mutations = new ArrayList<>();
        currentPosition = performOneCDCStep(client_configuration, server_1, tableHistoryStorage, currentPosition, mutations);
        // we are missing the last entry, because it is not confirmed yet on BookKeeper at this point
        assertEquals(4, mutations.size());
        server_1.getManager().executeUpdate(new UpdateStatement(TableSpace.DEFAULT, "t1", RecordSerializer.makeRecord(table, "c", 4, "d", 2), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        currentPosition = performOneCDCStep(client_configuration, server_1, tableHistoryStorage, currentPosition, mutations);
        assertEquals(5, mutations.size());
        server_1.getManager().executeStatement(new AlterTableStatement(Arrays.asList(Column.column("e", ColumnTypes.INTEGER)), Collections.emptyList(), Collections.emptyList(), null, table.name, TableSpace.DEFAULT, null, Collections.emptyList(), Collections.emptyList()), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        currentPosition = performOneCDCStep(client_configuration, server_1, tableHistoryStorage, currentPosition, mutations);
        assertEquals(6, mutations.size());
        server_1.getManager().executeUpdate(new DeleteStatement(TableSpace.DEFAULT, "t1", Bytes.from_int(1), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        currentPosition = performOneCDCStep(client_configuration, server_1, tableHistoryStorage, currentPosition, mutations);
        assertEquals(7, mutations.size());
        // close the server...close the ledger, now we can read the last mutation
        server_1.close();
        currentPosition = performOneCDCStep(client_configuration, server_1, tableHistoryStorage, currentPosition, mutations);
        assertEquals(8, mutations.size());
        int i = 0;
        assertEquals(ChangeDataCapture.MutationType.CREATE_TABLE, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.INSERT, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.UPDATE, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.ALTER_TABLE, mutations.get(i++).getMutationType());
        assertEquals(ChangeDataCapture.MutationType.DELETE, mutations.get(i++).getMutationType());
    }
}
Also used : UpdateStatement(herddb.model.commands.UpdateStatement) Table(herddb.model.Table) Server(herddb.server.Server) AlterTableStatement(herddb.model.commands.AlterTableStatement) ServerConfiguration(herddb.server.ServerConfiguration) CreateTableStatement(herddb.model.commands.CreateTableStatement) ArrayList(java.util.ArrayList) LogSequenceNumber(herddb.log.LogSequenceNumber) DeleteStatement(herddb.model.commands.DeleteStatement) InsertStatement(herddb.model.commands.InsertStatement) ClientConfiguration(herddb.client.ClientConfiguration) Test(org.junit.Test)

Example 9 with DeleteStatement

use of herddb.model.commands.DeleteStatement in project herddb by diennea.

the class SimpleRecoveryTest method rollbackDeleteTransactionOnRestart.

@Test
public void rollbackDeleteTransactionOnRestart() throws Exception {
    Path dataPath = folder.newFolder("data").toPath();
    Path logsPath = folder.newFolder("logs").toPath();
    Path metadataPath = folder.newFolder("metadata").toPath();
    Bytes key = Bytes.from_int(1234);
    Bytes value = Bytes.from_long(8888);
    Path tmoDir = folder.newFolder("tmoDir").toPath();
    String nodeId = "localhost";
    try (DBManager manager = new DBManager("localhost", new FileMetadataStorageManager(metadataPath), new FileDataStorageManager(dataPath), new FileCommitLogManager(logsPath), tmoDir, null)) {
        manager.start();
        CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
        manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        manager.waitForTablespace("tblspace1", 10000);
        Table table = Table.builder().tablespace("tblspace1").name("t1").column("id", ColumnTypes.STRING).column("name", ColumnTypes.STRING).primaryKey("id").build();
        CreateTableStatement st2 = new CreateTableStatement(table);
        manager.executeStatement(st2, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        manager.checkpoint();
        InsertStatement insert = new InsertStatement("tblspace1", "t1", new Record(key, value));
        assertEquals(1, manager.executeUpdate(insert, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION).getUpdateCount());
        // transaction is not committed, and the leader dies, key appear again
        long tx = ((TransactionResult) manager.executeStatement(new BeginTransactionStatement("tblspace1"), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION)).getTransactionId();
        DeleteStatement delete = new DeleteStatement("tblspace1", "t1", key, null);
        assertEquals(1, manager.executeUpdate(delete, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx)).getUpdateCount());
    }
    try (DBManager manager = new DBManager("localhost", new FileMetadataStorageManager(metadataPath), new FileDataStorageManager(dataPath), new FileCommitLogManager(logsPath), tmoDir, null)) {
        manager.start();
        manager.waitForTablespace("tblspace1", 10000);
        {
            GetStatement get = new GetStatement("tblspace1", "t1", key, null, false);
            GetResult result = manager.get(get, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            assertTrue(result.found());
            assertEquals(key, result.getRecord().key);
            assertEquals(value, result.getRecord().value);
        }
    }
}
Also used : Path(java.nio.file.Path) TransactionResult(herddb.model.TransactionResult) Table(herddb.model.Table) GetResult(herddb.model.GetResult) FileMetadataStorageManager(herddb.file.FileMetadataStorageManager) CreateTableStatement(herddb.model.commands.CreateTableStatement) DeleteStatement(herddb.model.commands.DeleteStatement) InsertStatement(herddb.model.commands.InsertStatement) Bytes(herddb.utils.Bytes) FileCommitLogManager(herddb.file.FileCommitLogManager) CreateTableSpaceStatement(herddb.model.commands.CreateTableSpaceStatement) TransactionContext(herddb.model.TransactionContext) GetStatement(herddb.model.commands.GetStatement) FileDataStorageManager(herddb.file.FileDataStorageManager) BeginTransactionStatement(herddb.model.commands.BeginTransactionStatement) Record(herddb.model.Record) Test(org.junit.Test)

Example 10 with DeleteStatement

use of herddb.model.commands.DeleteStatement in project herddb by diennea.

the class SimpleRecoveryTest method createInsertDeleteSameTransactionAndRestart.

@Test
public void createInsertDeleteSameTransactionAndRestart() throws Exception {
    Path dataPath = folder.newFolder("data").toPath();
    Path logsPath = folder.newFolder("logs").toPath();
    Path metadataPath = folder.newFolder("metadata").toPath();
    Bytes key = Bytes.from_int(1234);
    Bytes key2 = Bytes.from_int(1235);
    Bytes value = Bytes.from_long(8888);
    Path tmoDir = folder.newFolder("tmoDir").toPath();
    String nodeId = "localhost";
    try (DBManager manager = new DBManager("localhost", new FileMetadataStorageManager(metadataPath), new FileDataStorageManager(dataPath), new FileCommitLogManager(logsPath), tmoDir, null)) {
        manager.start();
        CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
        manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        manager.waitForTablespace("tblspace1", 10000);
        Table table = Table.builder().tablespace("tblspace1").name("t1").column("id", ColumnTypes.STRING).column("name", ColumnTypes.STRING).primaryKey("id").build();
        CreateTableStatement st2 = new CreateTableStatement(table);
        manager.executeStatement(st2, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
        manager.checkpoint();
        long tx = ((TransactionResult) manager.executeStatement(new BeginTransactionStatement("tblspace1"), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION)).getTransactionId();
        InsertStatement insert = new InsertStatement("tblspace1", "t1", new Record(key, value));
        assertEquals(1, manager.executeUpdate(insert, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx)).getUpdateCount());
        DeleteStatement delete = new DeleteStatement("tblspace1", "t1", key, null);
        assertEquals(1, manager.executeUpdate(delete, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx)).getUpdateCount());
        InsertStatement insert2 = new InsertStatement("tblspace1", "t1", new Record(key2, value));
        assertEquals(1, manager.executeUpdate(insert2, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), new TransactionContext(tx)).getUpdateCount());
        manager.executeStatement(new CommitTransactionStatement("tblspace1", tx), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
    }
    try (DBManager manager = new DBManager("localhost", new FileMetadataStorageManager(metadataPath), new FileDataStorageManager(dataPath), new FileCommitLogManager(logsPath), tmoDir, null)) {
        manager.start();
        manager.waitForTablespace("tblspace1", 10000);
        {
            GetStatement get = new GetStatement("tblspace1", "t1", key, null, false);
            GetResult result = manager.get(get, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            assertFalse(result.found());
        }
        {
            GetStatement get = new GetStatement("tblspace1", "t1", key2, null, false);
            GetResult result = manager.get(get, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
            assertTrue(result.found());
            assertEquals(key2, result.getRecord().key);
            assertEquals(value, result.getRecord().value);
        }
    }
}
Also used : Path(java.nio.file.Path) TransactionResult(herddb.model.TransactionResult) Table(herddb.model.Table) GetResult(herddb.model.GetResult) CommitTransactionStatement(herddb.model.commands.CommitTransactionStatement) FileMetadataStorageManager(herddb.file.FileMetadataStorageManager) CreateTableStatement(herddb.model.commands.CreateTableStatement) DeleteStatement(herddb.model.commands.DeleteStatement) InsertStatement(herddb.model.commands.InsertStatement) Bytes(herddb.utils.Bytes) FileCommitLogManager(herddb.file.FileCommitLogManager) CreateTableSpaceStatement(herddb.model.commands.CreateTableSpaceStatement) TransactionContext(herddb.model.TransactionContext) GetStatement(herddb.model.commands.GetStatement) FileDataStorageManager(herddb.file.FileDataStorageManager) BeginTransactionStatement(herddb.model.commands.BeginTransactionStatement) Record(herddb.model.Record) Test(org.junit.Test)

Aggregations

DeleteStatement (herddb.model.commands.DeleteStatement)38 InsertStatement (herddb.model.commands.InsertStatement)33 Test (org.junit.Test)30 Record (herddb.model.Record)29 GetResult (herddb.model.GetResult)23 Table (herddb.model.Table)23 GetStatement (herddb.model.commands.GetStatement)23 Bytes (herddb.utils.Bytes)22 TransactionContext (herddb.model.TransactionContext)20 CreateTableStatement (herddb.model.commands.CreateTableStatement)13 UpdateStatement (herddb.model.commands.UpdateStatement)12 CreateTableSpaceStatement (herddb.model.commands.CreateTableSpaceStatement)11 Path (java.nio.file.Path)9 TransactionResult (herddb.model.TransactionResult)8 BeginTransactionStatement (herddb.model.commands.BeginTransactionStatement)8 FileDataStorageManager (herddb.file.FileDataStorageManager)7 DataScanner (herddb.model.DataScanner)7 ServerConfiguration (herddb.server.ServerConfiguration)7 FileCommitLogManager (herddb.file.FileCommitLogManager)6 FileMetadataStorageManager (herddb.file.FileMetadataStorageManager)6