-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor for polymorphism: object/list joiner
- Loading branch information
Showing
10 changed files
with
142 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...c/main/java/com/netflix/hollow/core/read/engine/AbstractHollowTypeDataElementsJoiner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; | ||
|
||
public abstract class AbstractHollowTypeDataElementsJoiner { | ||
public final int fromMask; | ||
public final int fromOrdinalShift; | ||
public final AbstractHollowTypeDataElements[] from; | ||
|
||
public AbstractHollowTypeDataElements to; | ||
|
||
public AbstractHollowTypeDataElementsJoiner(AbstractHollowTypeDataElements[] from) { | ||
this.from = from; | ||
this.fromMask = from.length - 1; | ||
this.fromOrdinalShift = 31 - Integer.numberOfLeadingZeros(from.length); | ||
|
||
if (from.length<=0 || !((from.length&(from.length-1))==0)) { | ||
throw new IllegalStateException("No. of DataElements to be joined must be a power of 2"); | ||
} | ||
|
||
for (AbstractHollowTypeDataElements elements : from) { | ||
if (elements.encodedAdditions != null) { | ||
throw new IllegalStateException("Encountered encodedAdditions in data elements splitter- this is not expected " + | ||
"since encodedAdditions only exist on delta data elements and they dont carry over to target data elements, " + | ||
"delta data elements are never split/joined"); | ||
} | ||
} | ||
} | ||
|
||
public AbstractHollowTypeDataElements join() { | ||
|
||
init(); | ||
|
||
to.maxOrdinal = -1; | ||
|
||
populateStats(); | ||
|
||
copyRecords(); | ||
|
||
GapEncodedVariableLengthIntegerReader[] fromRemovals = new GapEncodedVariableLengthIntegerReader[from.length]; | ||
for (int i=0;i<from.length;i++) { | ||
fromRemovals[i] = from[i].encodedRemovals; | ||
} | ||
to.encodedRemovals = GapEncodedVariableLengthIntegerReader.join(fromRemovals); | ||
|
||
return to; | ||
} | ||
|
||
public abstract void init(); | ||
|
||
public abstract void populateStats(); | ||
|
||
public abstract void copyRecords(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters