-
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 data elements and splitter for polymorphism
- Loading branch information
Showing
10 changed files
with
259 additions
and
124 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
hollow/src/main/java/com/netflix/hollow/core/read/engine/AbstractHollowTypeDataElements.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,19 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
import com.netflix.hollow.core.memory.MemoryMode; | ||
import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; | ||
import com.netflix.hollow.core.memory.pool.ArraySegmentRecycler; | ||
|
||
public abstract class AbstractHollowTypeDataElements { | ||
|
||
public int maxOrdinal; | ||
public GapEncodedVariableLengthIntegerReader encodedAdditions; | ||
public GapEncodedVariableLengthIntegerReader encodedRemovals; | ||
public final ArraySegmentRecycler memoryRecycler; | ||
public final MemoryMode memoryMode; | ||
|
||
public AbstractHollowTypeDataElements(MemoryMode memoryMode, ArraySegmentRecycler memoryRecycler) { | ||
this.memoryMode = memoryMode; | ||
this.memoryRecycler = memoryRecycler; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...main/java/com/netflix/hollow/core/read/engine/AbstractHollowTypeDataElementsSplitter.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,53 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; | ||
|
||
public abstract class AbstractHollowTypeDataElementsSplitter { | ||
public final int numSplits; | ||
public final int toMask; | ||
public final int toOrdinalShift; | ||
public final AbstractHollowTypeDataElements from; | ||
|
||
public AbstractHollowTypeDataElements[] to; | ||
|
||
public AbstractHollowTypeDataElementsSplitter(AbstractHollowTypeDataElements from, int numSplits) { | ||
this.from = from; | ||
this.numSplits = numSplits; | ||
this.toMask = numSplits - 1; | ||
this.toOrdinalShift = 31 - Integer.numberOfLeadingZeros(numSplits); | ||
|
||
if (numSplits<=0 || !((numSplits&(numSplits-1))==0)) { | ||
throw new IllegalStateException("Must split by power of 2"); | ||
} | ||
|
||
if (from.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[] split() { | ||
for(int i=0;i<to.length;i++) { | ||
to[i].maxOrdinal = -1; | ||
} | ||
populateStats(); | ||
|
||
copyRecords(); | ||
|
||
if (from.encodedRemovals != null) { | ||
GapEncodedVariableLengthIntegerReader[] splitRemovals = from.encodedRemovals.split(numSplits); | ||
for(int i=0;i<to.length;i++) { | ||
to[i].encodedRemovals = splitRemovals[i]; | ||
} | ||
} | ||
|
||
return to; | ||
} | ||
|
||
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
Oops, something went wrong.