Skip to content

Commit

Permalink
PHOENIX-6239: NullPointerException when index table does not use COLU…
Browse files Browse the repository at this point in the history
…MN_ENCODED_BYTES (#994)

Co-authored-by: Swaroopa Kadam <s.kadam@apache.org>
  • Loading branch information
swaroopak and Swaroopa Kadam committed Dec 2, 2020
1 parent f604877 commit 0b69306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import java.util.Collection;
import java.util.Properties;

import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -74,10 +73,10 @@ public class AlterAddCascadeIndexIT extends ParallelStatsDisabledIT {

public AlterAddCascadeIndexIT(boolean isViewIndex, boolean mutable) {
this.isViewIndex = isViewIndex;
StringBuilder optionBuilder = new StringBuilder();
StringBuilder optionBuilder = new StringBuilder("COLUMN_ENCODED_BYTES=0");
if (!mutable) {

optionBuilder.append(" IMMUTABLE_ROWS=true");
optionBuilder.append(", IMMUTABLE_ROWS=true, IMMUTABLE_STORAGE_SCHEME='ONE_CELL_PER_COLUMN'");
}
this.mutable = mutable;
this.tableDDLOptions = optionBuilder.toString();
Expand Down Expand Up @@ -160,7 +159,7 @@ public void testAlterDBOAddCascadeIndexAllUpsert() throws Exception {
assertNumberOfHBaseCells( "_IDX_"+fullTableName,6);
}
else {
assertNumberOfHBaseCells( "_IDX_"+fullTableName,4);
assertNumberOfHBaseCells( "_IDX_"+fullTableName,6);
}
} else {
assertDBODefinition(conn, phoenixObjectName, PTableType.TABLE, 4, columnArray, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4201,7 +4201,9 @@ private HashMap<PTable, PColumn> getPTablePColumnHashMapForCascade(List<PTable>
for (PTable index : indexesPTable) {
int iPos = indexToColumnSizeMap.get(index);
EncodedCQCounter cqCounterToUse = index.getEncodedCQCounter();
Integer encodedCQ = index.isAppendOnlySchema() ? Integer.valueOf(ENCODED_CQ_COUNTER_INITIAL_VALUE + iPos) : cqCounterToUse.getNextQualifier(familyName) + iPos;
int baseCount = 0;
baseCount = (cqCounterToUse != null && cqCounterToUse.getNextQualifier(familyName)!=null) ? cqCounterToUse.getNextQualifier(familyName) : 0 ;
Integer encodedCQ = index.isAppendOnlySchema() ? Integer.valueOf(ENCODED_CQ_COUNTER_INITIAL_VALUE + iPos) : baseCount + iPos;
byte[] columnQualifierBytes = EncodedColumnsUtil.getColumnQualifierBytes(indexColDef.getColumnDefName().getColumnName(), encodedCQ, index, indexColDef.isPK());
PColumn iColumn = newColumn(iPos, indexColDef, null, index.getDefaultFamilyName() == null ? null : index.getDefaultFamilyName().getString(), false, columnQualifierBytes, willBeImmutableRows);
indexColumn.put(index, iColumn);
Expand Down

0 comments on commit 0b69306

Please sign in to comment.