use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexMultiFieldInMultiDocParts.
/**
* Test a new index with multiple fields in multiple doc parts Case [1&1.OK1|1&2.OK1].3
*
* @throws Exception
*/
@Test
public void testNewIndexMultiFieldInMultiDocParts() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
ImmutableMetaSnapshot currentSnapshot = currentModifiedSnapshot.immutableCopy();
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndex.
/**
* Test remove an index Case [2&1.OK1|2&2.OK1|2&3.OK1].1
*
* @throws Exception
*/
@Test
public void testRemoveIndex() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
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.WrapperMutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexMultiFieldsInMultiDocPartsAndNewDocPartIndex.
/**
* Test a new index with multiple fields in multiple doc parts and new doc part index Case
* 1&3.OK1.3
*
* @throws Exception
*/
@Test
public void testNewIndexMultiFieldsInMultiDocPartsAndNewDocPartIndex() 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);
ImmutableMetaSnapshot currentSnapshot = currentModifiedSnapshot.immutableCopy();
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName4", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "fieldName5", FieldIndexOrdering.ASC);
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(currentSnapshot, changedSnapshot).merge();
}
use of com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testIndexWithNewOrphanDocPartIndexConflict.
/**
* Test that an exception is thrown on new doc part index with missing index conflicts Case
* 3&2.KO1.1
*
* @throws Exception
*/
@Test
public void testIndexWithNewOrphanDocPartIndexConflict() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").removeMetaIndexByName("idxName1");
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).removeMetaDocPartIndexByIdentifier("idxId1");
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName1", "fieldId2", 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().immutableCopy("idxId2");
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.WrapperMutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testIndexWithMultiFieldsWithOldMissingDocPartIndexConflict.
/**
* Test that an exception is thrown on new index with multiple fields with missing doc part index
* conflicts Case 1&3.KO1.2
*
* @throws Exception
*/
@Test
public void testIndexWithMultiFieldsWithOldMissingDocPartIndexConflict() 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);
MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName2", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "fieldName3", FieldIndexOrdering.ASC);
try {
new SnapshotMerger(currentModifiedSnapshot.immutableCopy(), changedSnapshot).merge();
Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
} catch (UnmergeableException ex) {
}
}
Aggregations