-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HCOLL-349 HCOLL-350 stage compilation via annotation processing
- Loading branch information
Showing
73 changed files
with
5,199 additions
and
12,496 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
80 changes: 80 additions & 0 deletions
80
src/main/java/net/openhft/chronicle/hash/impl/stage/data/bytes/EntryKeyBytesData.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,80 @@ | ||
/* | ||
* Copyright 2015 Higher Frequency Trading | ||
* | ||
* http://www.higherfrequencytrading.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.openhft.chronicle.hash.impl.stage.data.bytes; | ||
|
||
import net.openhft.chronicle.bytes.RandomDataInput; | ||
import net.openhft.chronicle.hash.AbstractData; | ||
import net.openhft.chronicle.hash.impl.stage.entry.HashEntryStages; | ||
import net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation; | ||
import net.openhft.chronicle.hash.impl.stage.hash.KeyBytesInterop; | ||
import net.openhft.sg.Stage; | ||
import net.openhft.sg.StageRef; | ||
import net.openhft.sg.Staged; | ||
|
||
@Staged | ||
public class EntryKeyBytesData<K> extends AbstractData<K> { | ||
|
||
@StageRef KeyBytesInterop<K, ?, ?> ki; | ||
@StageRef HashEntryStages<K> entry; | ||
@StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; | ||
|
||
|
||
@Stage("CachedEntryKey") private K cachedEntryKey; | ||
@Stage("CachedEntryKey") private boolean cachedEntryKeyRead = false; | ||
|
||
private void initCachedEntryKey() { | ||
cachedEntryKey = innerGetUsing(cachedEntryKey); | ||
cachedEntryKeyRead = true; | ||
} | ||
|
||
@Override | ||
public RandomDataInput bytes() { | ||
checkOnEachPublicOperation.checkOnEachPublicOperation(); | ||
return entry.entryBS; | ||
} | ||
|
||
@Override | ||
public long offset() { | ||
checkOnEachPublicOperation.checkOnEachPublicOperation(); | ||
return entry.keyOffset; | ||
} | ||
|
||
@Override | ||
public long size() { | ||
checkOnEachPublicOperation.checkOnEachPublicOperation(); | ||
return entry.keySize; | ||
} | ||
|
||
@Override | ||
public K get() { | ||
checkOnEachPublicOperation.checkOnEachPublicOperation(); | ||
return cachedEntryKey; | ||
} | ||
|
||
@Override | ||
public K getUsing(K usingKey) { | ||
checkOnEachPublicOperation.checkOnEachPublicOperation(); | ||
return innerGetUsing(usingKey); | ||
} | ||
|
||
private K innerGetUsing(K usingKey) { | ||
entry.entryBytes.position(entry.keyOffset); | ||
return ki.keyReader.read(entry.entryBytes, size(), usingKey); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/net/openhft/chronicle/hash/impl/stage/data/bytes/InputKeyBytesData.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,70 @@ | ||
/* | ||
* Copyright 2015 Higher Frequency Trading | ||
* | ||
* http://www.higherfrequencytrading.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.openhft.chronicle.hash.impl.stage.data.bytes; | ||
|
||
import net.openhft.chronicle.bytes.RandomDataInput; | ||
import net.openhft.chronicle.hash.AbstractData; | ||
import net.openhft.chronicle.hash.impl.stage.hash.KeyBytesInterop; | ||
import net.openhft.chronicle.hash.impl.stage.input.HashInputBytes; | ||
import net.openhft.lang.io.Bytes; | ||
import net.openhft.sg.Stage; | ||
import net.openhft.sg.StageRef; | ||
import net.openhft.sg.Staged; | ||
|
||
|
||
@Staged | ||
public class InputKeyBytesData<K> extends AbstractData<K> { | ||
@StageRef HashInputBytes in; | ||
@StageRef KeyBytesInterop<K, ?, ?> ki; | ||
|
||
@Stage("CachedBytesInputKey") private K cachedBytesInputKey; | ||
@Stage("CachedBytesInputKey") private boolean cachedBytesInputKeyRead = false; | ||
|
||
private void initCachedBytesInputKey() { | ||
cachedBytesInputKey = getUsing(cachedBytesInputKey); | ||
cachedBytesInputKeyRead = true; | ||
} | ||
|
||
@Override | ||
public RandomDataInput bytes() { | ||
return in.inputStore; | ||
} | ||
|
||
@Override | ||
public long offset() { | ||
return in.inputKeyOffset; | ||
} | ||
|
||
@Override | ||
public long size() { | ||
return in.inputKeySize; | ||
} | ||
|
||
@Override | ||
public K get() { | ||
return cachedBytesInputKey; | ||
} | ||
|
||
@Override | ||
public K getUsing(K usingKey) { | ||
Bytes inputBytes = in.inputBytes; | ||
inputBytes.position(in.inputKeyOffset); | ||
return ki.keyReader.read(inputBytes, size(), usingKey); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/net/openhft/chronicle/hash/impl/stage/data/instance/InputKeyInstanceData.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,65 @@ | ||
/* | ||
* Copyright 2015 Higher Frequency Trading | ||
* | ||
* http://www.higherfrequencytrading.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.openhft.chronicle.hash.impl.stage.data.instance; | ||
|
||
import net.openhft.chronicle.hash.impl.CopyingInstanceData; | ||
import net.openhft.chronicle.hash.impl.stage.hash.KeyBytesInterop; | ||
import net.openhft.chronicle.hash.impl.value.instance.KeyInitableData; | ||
import net.openhft.chronicle.hash.serialization.internal.MetaBytesInterop; | ||
import net.openhft.lang.io.DirectBytes; | ||
import net.openhft.sg.Stage; | ||
import net.openhft.sg.StageRef; | ||
import net.openhft.sg.Staged; | ||
|
||
@Staged | ||
public abstract class InputKeyInstanceData<K, KI, MKI extends MetaBytesInterop<K, ? super KI>> | ||
extends CopyingInstanceData<K> implements KeyInitableData<K> { | ||
|
||
@StageRef KeyBytesInterop<K, KI, MKI> ki; | ||
|
||
private K key = null; | ||
|
||
@Override | ||
public void initKey(K key) { | ||
this.key = key; | ||
} | ||
|
||
@Override | ||
public K instance() { | ||
return key; | ||
} | ||
|
||
@Stage("Buffer") private DirectBytes buffer; | ||
@Stage("Buffer") private boolean marshalled = false; | ||
|
||
private void initBuffer() { | ||
MKI mki = ki.keyMetaInterop(key); | ||
long size = mki.size(ki.keyInterop, key); | ||
buffer = getBuffer(this.buffer, size); | ||
mki.write(ki.keyInterop, buffer, key); | ||
buffer.flip(); | ||
marshalled = true; | ||
} | ||
|
||
@Override | ||
public K getUsing(K usingKey) { | ||
buffer.position(0); | ||
return ki.keyReader.read(buffer, buffer.limit(), usingKey); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/net/openhft/chronicle/hash/impl/stage/entry/AllocatedChunks.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,47 @@ | ||
/* | ||
* Copyright 2015 Higher Frequency Trading | ||
* | ||
* http://www.higherfrequencytrading.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.openhft.chronicle.hash.impl.stage.entry; | ||
|
||
import net.openhft.chronicle.hash.impl.VanillaChronicleHashHolder; | ||
import net.openhft.sg.StageRef; | ||
import net.openhft.sg.Staged; | ||
|
||
@Staged | ||
public class AllocatedChunks { | ||
|
||
@StageRef public VanillaChronicleHashHolder<?, ?, ?> hh; | ||
@StageRef public SegmentStages s; | ||
@StageRef public HashEntryStages<?> entry; | ||
|
||
public int allocatedChunks = 0; | ||
|
||
public void initAllocatedChunks(int allocatedChunks) { | ||
this.allocatedChunks = allocatedChunks; | ||
} | ||
|
||
public void incrementSegmentEntriesIfNeeded() { | ||
// don't increment | ||
} | ||
|
||
public void initEntryAndKeyCopying(long entrySize, long bytesToCopy) { | ||
initAllocatedChunks(hh.h().inChunks(entrySize)); | ||
entry.copyExistingEntry(s.alloc(allocatedChunks), bytesToCopy); | ||
incrementSegmentEntriesIfNeeded(); | ||
} | ||
} |
Oops, something went wrong.