-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oak shared config #196
Oak shared config #196
Changes from 7 commits
7db06d1
a03684e
a07289d
e3ec54a
8ae2867
924a391
37b170b
8213884
9d66cf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,27 +21,34 @@ enum State { | |
|
||
|
||
/*-------------- Members --------------*/ | ||
// to compare serilized and object keys | ||
protected final OakSharedConfig<K, V> config; | ||
|
||
// to compare serialized and object keys | ||
protected OakComparator<K> comparator; | ||
|
||
// in split/compact process, represents parent of split (can be null!) | ||
private final AtomicReference<BasicChunk<K, V>> creator; | ||
// chunk can be in the following states: normal, frozen or infant(has a creator) | ||
private final AtomicReference<State> state; | ||
private final AtomicReference<Rebalancer<K, V>> rebalancer; | ||
private final AtomicInteger pendingOps; | ||
private final int maxItems; | ||
protected final int maxItems; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not to use getMaxItems()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems more natural to me to access internal final fields directly. I don't see why we need a function call here. |
||
protected AtomicInteger externalSize; // for updating oak's size (reference to one global per Oak size) | ||
protected final Statistics statistics; | ||
|
||
/*-------------- Constructors and creators --------------*/ | ||
/** | ||
* This constructor is only used internally to instantiate a BasicChunk without a creator and a state. | ||
* The caller should set the creator and state before returning the BasicChunk to the user. | ||
* | ||
* @param config shared configuration | ||
* @param maxItems maximal capacity | ||
*/ | ||
protected BasicChunk(int maxItems, AtomicInteger externalSize, OakComparator<K> comparator) { | ||
protected BasicChunk(OakSharedConfig<K, V> config, int maxItems) { | ||
this.config = config; | ||
this.maxItems = maxItems; | ||
this.externalSize = externalSize; | ||
this.comparator = comparator; | ||
this.externalSize = config.size; | ||
this.comparator = config.comparator; | ||
this.creator = new AtomicReference<>(null); | ||
this.state = new AtomicReference<>(State.NORMAL); | ||
this.pendingOps = new AtomicInteger(); | ||
|
@@ -55,7 +62,6 @@ protected BasicChunk(int maxItems, AtomicInteger externalSize, OakComparator<K> | |
protected void updateBasicChild(BasicChunk<K, V> child) { | ||
child.creator.set(this); | ||
child.state.set(State.INFANT); | ||
return; | ||
} | ||
/*---------------Abstract Read methods -----------------------*/ | ||
abstract void readKey(ThreadContext ctx); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't comparator part of the config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each instance holds its own references to the "config items" it needs.
I implemented it that way to avoid another pointer dereference each time we access these elements.
In addition, the config object is stored here to be passed to the child Chunk instance.