-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resharding: Consumer-side support for list, set, map types
- Loading branch information
Showing
75 changed files
with
3,905 additions
and
1,526 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
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
23 changes: 23 additions & 0 deletions
23
hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeDataElements.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,23 @@ | ||
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 HollowTypeDataElements { | ||
|
||
public int maxOrdinal; | ||
|
||
public GapEncodedVariableLengthIntegerReader encodedAdditions; | ||
public GapEncodedVariableLengthIntegerReader encodedRemovals; | ||
|
||
public final ArraySegmentRecycler memoryRecycler; | ||
public final MemoryMode memoryMode; | ||
|
||
public HollowTypeDataElements(MemoryMode memoryMode, ArraySegmentRecycler memoryRecycler) { | ||
this.memoryMode = memoryMode; | ||
this.memoryRecycler = memoryRecycler; | ||
} | ||
|
||
public abstract void destroy(); | ||
} |
75 changes: 75 additions & 0 deletions
75
hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeDataElementsJoiner.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,75 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; | ||
|
||
public abstract class HollowTypeDataElementsJoiner<T extends HollowTypeDataElements> { | ||
public final int fromMask; | ||
public final int fromOrdinalShift; | ||
public final T[] from; | ||
|
||
public T to; | ||
|
||
public HollowTypeDataElementsJoiner(T[] 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 (int i=0;i<from.length;i++) { | ||
if (from[i].maxOrdinal == -1) { | ||
continue; | ||
} | ||
if (from[i].maxOrdinal > (1<<29) | ||
|| from[i].maxOrdinal != 0 && (from.length > (1<<29)/from[i].maxOrdinal) | ||
|| from[i].maxOrdinal * from.length + i > (1<<29)) { | ||
throw new IllegalArgumentException("Too large to join, maxOrdinal would exceed 2<<29"); | ||
} | ||
} | ||
|
||
for (HollowTypeDataElements elements : from) { | ||
if (elements.encodedAdditions != null) { | ||
throw new IllegalStateException("Encountered encodedAdditions in data elements joiner- 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 T join() { | ||
|
||
initToElements(); | ||
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; | ||
} | ||
|
||
/** | ||
* Initialize the target data elements. | ||
*/ | ||
public abstract void initToElements(); | ||
|
||
/** | ||
* Populate the stats of the target data elements. | ||
*/ | ||
public abstract void populateStats(); | ||
|
||
/** | ||
* Copy records from the source data elements to the target data elements. | ||
*/ | ||
public abstract void copyRecords(); | ||
|
||
|
||
} |
73 changes: 73 additions & 0 deletions
73
hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeDataElementsSplitter.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,73 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; | ||
|
||
/** | ||
* Join multiple {@code HollowListTypeDataElements}s into 1 {@code HollowListTypeDataElements}. | ||
* Ordinals are remapped and corresponding data is copied over. | ||
* The original data elements are not destroyed. | ||
* The no. of passed data elements must be a power of 2. | ||
*/ | ||
public abstract class HollowTypeDataElementsSplitter<T extends HollowTypeDataElements> { | ||
public final int numSplits; | ||
public final int toMask; | ||
public final int toOrdinalShift; | ||
public final T from; | ||
|
||
public T[] to; | ||
|
||
public HollowTypeDataElementsSplitter(T 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 T[] split() { | ||
|
||
initToElements(); | ||
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; | ||
} | ||
|
||
/** | ||
* Initialize the target data elements. | ||
*/ | ||
public abstract void initToElements(); | ||
|
||
/** | ||
* Populate the stats of the target data elements. | ||
*/ | ||
public abstract void populateStats(); | ||
|
||
/** | ||
* Copy records from the source data elements to the target data elements. | ||
*/ | ||
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
8 changes: 8 additions & 0 deletions
8
hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeReadStateShard.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,8 @@ | ||
package com.netflix.hollow.core.read.engine; | ||
|
||
public interface HollowTypeReadStateShard { | ||
|
||
HollowTypeDataElements getDataElements(); | ||
|
||
int getShardOrdinalShift(); | ||
} |
Oops, something went wrong.