use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexAndNewDocPartIndex.
/**
* Test a new index and new doc part index Case 1&3.OK1.1
*
* @throws Exception
*/
@Test
public void testNewIndexAndNewDocPartIndex() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaField("fieldName2", "fieldId2", 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").getMetaDocPartByTableRef(tableRefFactory.createRoot()).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId2", 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.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testNewIndexMultiFieldsAndNewDocPartIndex.
/**
* Test a new index with multiple fields and new doc part index Case 1&3.OK1.2
*
* @throws Exception
*/
@Test
public void testNewIndexMultiFieldsAndNewDocPartIndex() 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").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").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.createRoot(), "fieldName4", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName2").addMetaIndexField(tableRefFactory.createRoot(), "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().addMetaDocPartIndexColumn("fieldId4", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createRoot()).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId5", 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.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndexWithDocPartIndexIncludedByOtherIndex.
/**
* Test remove an index that relates to a doc part index that also relate to another index Case
* 2&1.OK1.1
*
* @throws Exception
*/
@Test
public void testRemoveIndexWithDocPartIndexIncludedByOtherIndex() throws Exception {
MutableMetaSnapshot currentModifiedSnapshot = new WrapperMutableMetaSnapshot(currentSnapshot);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").addMetaIndex("idxName2", false).addMetaIndexField(tableRefFactory.createRoot(), "fieldName1", 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.ImmutableMetaSnapshot in project torodb by torodb.
the class SnapshotMergerForIndexTest method testRemoveIndexWithMuliFieldsInMultiDocParts.
/**
* Test remove an index with multiple fields in multiple doc parts Case
* [2&1.OK1|2&2.OK1|2&3.OK1].3
*
* @throws Exception
*/
@Test
public void testRemoveIndexWithMuliFieldsInMultiDocParts() 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);
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 testNewIndexMultiFieldsInMultiDocPartsWithOldDocPartIndexAndNewDocPartIndex.
/**
* Test a new index with multiple fields and old doc part index and a new one Case 1&3.OK2.3
*
* @throws Exception
*/
@Test
public void testNewIndexMultiFieldsInMultiDocPartsWithOldDocPartIndexAndNewDocPartIndex() 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").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2"), "docPartId2");
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").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);
currentModifiedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaIndexByName("idxName3").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();
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.createChild(tableRefFactory.createRoot(), "docPartName2")).addMetaDocPartIndex(false).addMetaDocPartIndexColumn("fieldId4", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).getAddedMutableMetaDocPartIndexes().iterator().next().addMetaDocPartIndexColumn("fieldId5", FieldIndexOrdering.ASC);
changedSnapshot.getMetaDatabaseByName("dbName1").getMetaCollectionByName("colName1").getMetaDocPartByTableRef(tableRefFactory.createChild(tableRefFactory.createRoot(), "docPartName2")).getAddedMutableMetaDocPartIndexes().iterator().next().immutableCopy("idxId3");
new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
}
Aggregations