Search in sources :

Example 61 with WrapperMutableMetaSnapshot

use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerForIndexTest method testIndexWithMultiFieldsWithNewFieldAndNewDocPartIndex.

/**
   * Test new field with new doc part index for existing index with multiple fields conflicts Case
   * 3&3.OK1.2
   *
   * @throws Exception
   */
@Test
public void testIndexWithMultiFieldsWithNewFieldAndNewDocPartIndex() throws Exception {
    MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId2", FieldType.STRING);
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentModifiedSnapshot.immutableCopy());
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName3", "fieldId3", FieldType.STRING);
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId2", FieldIndexOrdering.ASC);
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId3", FieldIndexOrdering.ASC);
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().immutableCopy("idxId2");
    new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 62 with WrapperMutableMetaSnapshot

use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerForIndexTest method testRemoveIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexAddedConflict.

/**
   * Test an exception is thrown when an index with multiple fields in multiple doc parts is removed
   * and has same doc part index as an old added index Case 2&1.KO1.3
   *
   * @throws Exception
   */
@Test
public void testRemoveIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexAddedConflict() throws Exception {
    MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId2", FieldType.STRING);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName3", "fieldId3", FieldType.STRING);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", true).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName3"), "fieldName6", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId2", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId3", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().immutableCopy("idxId2");
    ImmutableMetaSnapshot currentSnapshot = currentModifiedSnapshot.immutableCopy();
    currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName3", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName3").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName3").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
    currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName3").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").removeMetaIndexByName("idxName2");
    changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
    try {
        new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 63 with WrapperMutableMetaSnapshot

use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testCollectionIdConflict.

/**
   * Test that an exception is thrown on collection id conflicts
   *
   * @throws Exception
   */
@Test
public void testCollectionIdConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId2");
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 64 with WrapperMutableMetaSnapshot

use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testFieldIdConflict.

/**
   * Test that an exception is thrown on field id conflicts
   *
   * @throws Exception
   */
@Test
public void testFieldIdConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaField("fieldName1", "fieldId2", FieldType.INTEGER);
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 65 with WrapperMutableMetaSnapshot

use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testScalarTypeConflict.

/**
   * Test that an exception is thrown on scalar type conflicts
   *
   * @throws Exception
   */
@Test
public void testScalarTypeConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createRoot(), "docPartId1").addMetaScalar("fieldId2", FieldType.INTEGER);
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Aggregations

MutableMetaSnapshot (com.torodb.core.transaction.metainf.MutableMetaSnapshot)69 WrapperMutableMetaSnapshot (com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot)69 Test (org.junit.Test)69 ImmutableMetaSnapshot (com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)55 UnmergeableException (com.torodb.core.transaction.metainf.UnmergeableException)34 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)1