use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndexWithMultiFieldsInMultiDocPartsAndRemoveDocPartIndexes.
/**
* Test remove an index with multiple fields in multiple doc parts and remove multiple doc part
* indexes Case [2&1.OK2|2&2.OK2|2&3.OK2].3
*
* @throws Exception
*/
@Test
public void testRemoveIndexWithMultiFieldsInMultiDocPartsAndRemoveDocPartIndexes() 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").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "docPartId2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
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").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaField("fieldName4", "fieldId4", FieldType.STRING);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaField("fieldName5", "fieldId5", FieldType.STRING);
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");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId4", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId5", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).getAddedMutableMetaDocPartIndexes().iterator().next().immutableCopy("idxId3");
ImmutableMetaSnapshot currentSnapshot = currentModifiedSnapshot.immutableCopy();
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").removeMetaIndexByName("idxName2");
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).removeMetaDocPartIndexByIdentifier("idxId3");
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexRemovedConflict.
/**
* Test an exception is thrown when a new index with multiple fields in multiple doc parts has
* same doc part index as an old remove index Case 1&2.KO1.3
*
* @throws Exception
*/
@Test
public void testNewIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexRemovedConflict() 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.DESC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.DESC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName3"), "fieldName6", FieldIndexOrdering.DESC);
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").removeMetaIndexByName("idxName2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName3", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName3").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.DESC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.DESC);
try {
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
} catch (UnmergeableException ex) {
}
}
use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndexWithMuliFields.
/**
* Test remove an index with multiple fields Case [2&1.OK1|2&2.OK1|2&3.OK1].2
*
* @throws Exception
*/
@Test
public void testRemoveIndexWithMuliFields() 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").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName4", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName5", FieldIndexOrdering.ASC);
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").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName4", "fieldId4", FieldType.STRING);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName5", "fieldId5", FieldType.STRING);
ImmutableMetaSnapshot currentSnapshot = currentModifiedSnapshot.immutableCopy();
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").removeMetaIndexByName("idxName2");
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testIndexWithMultiFieldsInMultiDocPartsWithNewOrphanDocPartIndexConflict.
/**
* Test that an exception is thrown on new doc part index with missing index with multiple fields
* in multiple doc parts conflicts Case 3&2.KO1.2
*
* @throws Exception
*/
@Test
public void testIndexWithMultiFieldsInMultiDocPartsWithNewOrphanDocPartIndexConflict() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId12", FieldType.STRING);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName3", "fieldId13", FieldType.STRING);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "docPartId2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaField("fieldName4", "fieldId14", FieldType.STRING);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaField("fieldName5", "fieldId15", FieldType.STRING);
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").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId12", FieldIndexOrdering.ASC);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId13", 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").removeMetaIndexByName("idxName2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId2", FieldType.BINARY);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName3", "fieldId3", FieldType.BINARY);
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("idxId3");
try {
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
} catch (UnmergeableException ex) {
}
}
use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexRemoved.
/**
* Test when an index with multiple fields in multiple doc parts is removed and has same old
* removed index Case 2&2.OK3.3
*
* @throws Exception
*/
@Test
public void testRemoveIndexWithMultiFieldsInMultiDocPartsWithOldIndexWithSameDocPartIndexRemoved() 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").removeMetaIndexByName("idxName2");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").removeMetaIndexByName("idxName2");
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId2");
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
}
Aggregations