-
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.
- Loading branch information
Showing
12 changed files
with
198 additions
and
39 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
53 changes: 53 additions & 0 deletions
53
...ow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeShardsHolder.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.list; | ||
|
||
import com.netflix.hollow.core.read.engine.HollowTypeReadStateShard; | ||
import com.netflix.hollow.core.read.engine.ShardsHolder; | ||
|
||
public class HollowListTypeShardsHolder extends ShardsHolder { | ||
final HollowListTypeReadStateShard shards[]; | ||
final int shardNumberMask; | ||
|
||
/** | ||
* Thread safe construction of ShardHolder with given shards | ||
* @param fromShards shards to be used | ||
*/ | ||
public HollowListTypeShardsHolder(HollowTypeReadStateShard[] fromShards) { | ||
this.shards = new HollowListTypeReadStateShard[fromShards.length]; | ||
for (int i=0; i<fromShards.length; i++) { | ||
this.shards[i] = (HollowListTypeReadStateShard) fromShards[i]; | ||
} | ||
this.shardNumberMask = fromShards.length - 1; | ||
} | ||
|
||
/** | ||
* Thread safe construction of a ShardHolder which has all the shards from {@code oldShards} except | ||
* the shard at index {@code newShardIndex}, using the shard {@code newShard} at that index instead. | ||
* @param oldShards original shards | ||
* @param newShard a new shard | ||
* @param newShardIndex index at which to place the new shard | ||
*/ | ||
HollowListTypeShardsHolder(HollowListTypeReadStateShard[] oldShards, HollowListTypeReadStateShard newShard, int newShardIndex) { | ||
int numShards = oldShards.length; | ||
HollowListTypeReadStateShard[] shards = new HollowListTypeReadStateShard[numShards]; | ||
for (int i=0; i<numShards; i++) { | ||
if (i == newShardIndex) { | ||
shards[i] = newShard; | ||
} else { | ||
shards[i] = oldShards[i]; | ||
} | ||
} | ||
this.shards = shards; | ||
this.shardNumberMask = numShards - 1; | ||
} | ||
|
||
@Override | ||
public HollowTypeReadStateShard[] getShards() { | ||
throw new UnsupportedOperationException("Not implemented yet"); | ||
// return shards; | ||
} | ||
|
||
@Override | ||
public int getShardNumberMask() { | ||
return shardNumberMask; | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeShardsHolder.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.map; | ||
|
||
import com.netflix.hollow.core.read.engine.HollowTypeReadStateShard; | ||
import com.netflix.hollow.core.read.engine.ShardsHolder; | ||
|
||
public class HollowMapTypeShardsHolder extends ShardsHolder { | ||
final HollowMapTypeReadStateShard shards[]; | ||
final int shardNumberMask; | ||
|
||
/** | ||
* Thread safe construction of ShardHolder with given shards | ||
* @param fromShards shards to be used | ||
*/ | ||
public HollowMapTypeShardsHolder(HollowTypeReadStateShard[] fromShards) { | ||
this.shards = new HollowMapTypeReadStateShard[fromShards.length]; | ||
for (int i=0; i<fromShards.length; i++) { | ||
this.shards[i] = (HollowMapTypeReadStateShard) fromShards[i]; | ||
} | ||
this.shardNumberMask = fromShards.length - 1; | ||
} | ||
|
||
/** | ||
* Thread safe construction of a ShardHolder which has all the shards from {@code oldShards} except | ||
* the shard at index {@code newShardIndex}, using the shard {@code newShard} at that index instead. | ||
* @param oldShards original shards | ||
* @param newShard a new shard | ||
* @param newShardIndex index at which to place the new shard | ||
*/ | ||
HollowMapTypeShardsHolder(HollowMapTypeReadStateShard[] oldShards, HollowMapTypeReadStateShard newShard, int newShardIndex) { | ||
int numShards = oldShards.length; | ||
HollowMapTypeReadStateShard[] shards = new HollowMapTypeReadStateShard[numShards]; | ||
for (int i=0; i<numShards; i++) { | ||
if (i == newShardIndex) { | ||
shards[i] = newShard; | ||
} else { | ||
shards[i] = oldShards[i]; | ||
} | ||
} | ||
this.shards = shards; | ||
this.shardNumberMask = numShards - 1; | ||
} | ||
|
||
@Override | ||
public HollowTypeReadStateShard[] getShards() { | ||
throw new UnsupportedOperationException("Not implemented yet"); | ||
// return shards; | ||
} | ||
|
||
@Override | ||
public int getShardNumberMask() { | ||
return shardNumberMask; | ||
} | ||
} |
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.