twdsilva commented on a change in pull request #473: PHOENIX-5138 - ViewIndexId
sequences created after PHOENIX-5132 shoul…
URL: https://github.com/apache/phoenix/pull/473#discussion_r269708099
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
##########
@@ -588,4 +602,85 @@ public void testMoveParentChildLinks() throws Exception {
return childLinkSet;
}
+ @Test
+ public void testMergeViewIndexSequences() throws Exception {
+ testMergeViewIndexSequencesHelper(false);
+ }
+
+ @Test
+ public void testMergeViewIndexSequencesWithNamespaces() throws Exception {
+ testMergeViewIndexSequencesHelper(true);
+ }
+
+ private void testMergeViewIndexSequencesHelper(boolean
isNamespaceMappingEnabled) throws Exception {
+ PhoenixConnection conn = getConnection(false, null,
isNamespaceMappingEnabled).unwrap(PhoenixConnection.class);
+ ConnectionQueryServices cqs = conn.getQueryServices();
+ //First delete any sequences that may exist from previous tests
+ conn.createStatement().execute("DELETE FROM " +
PhoenixDatabaseMetaData.SYSTEM_SEQUENCE);
+ conn.commit();
+ cqs.clearCache();
+ //Now make sure that running the merge logic doesn't cause a problem
when there are no
+ //sequences
+ UpgradeUtil.mergeViewIndexIdSequences(cqs, conn);
+ PName tenantOne = PNameFactory.newName("TENANT_ONE");
+ PName tenantTwo = PNameFactory.newName("TENANT_TWO");
+ String tableName =
+ SchemaUtil.getPhysicalHBaseTableName("TEST",
+ "T_" + generateUniqueName(),
isNamespaceMappingEnabled).getString();
+ PName viewIndexTable =
PNameFactory.newName(MetaDataUtil.getViewIndexPhysicalName(tableName));
+ SequenceKey sequenceOne =
+ createViewIndexSequenceWithOldName(cqs, tenantOne, viewIndexTable,
isNamespaceMappingEnabled);
+ SequenceKey sequenceTwo =
+ createViewIndexSequenceWithOldName(cqs, tenantTwo, viewIndexTable,
isNamespaceMappingEnabled);
+ SequenceKey sequenceGlobal =
+ createViewIndexSequenceWithOldName(cqs, null, viewIndexTable,
isNamespaceMappingEnabled);
+
+ List<SequenceAllocation> allocations = Lists.newArrayList();
+ long val1 = 10;
+ long val2 = 100;
+ long val3 = 1000;
+ allocations.add(new SequenceAllocation(sequenceOne, val1));
+ allocations.add(new SequenceAllocation(sequenceGlobal, val2));
+ allocations.add(new SequenceAllocation(sequenceTwo, val3));
+
+
+ long[] incrementedValues = new long[3];
+ SQLException[] exceptions = new SQLException[3];
+ cqs.incrementSequences(allocations,
EnvironmentEdgeManager.currentTimeMillis(), incrementedValues,
Review comment:
Maybe add a comment saying simulate creating many view indexes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services