proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/SerializableReader.java
SerializableReader
read
class SerializableReader<T extends Serializable> implements SizedReader<T>, BytesReader<T> { @NotNull @Override public T read(@NotNull Bytes in, long size, @Nullable T using) { return read(in, using); } @NotNull @Override public T read(Bytes in, @Nullable T using) {<FILL_FUNCTION_B...
try { return (T) new ObjectInputStream(in.inputStream()).readObject(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); }
169
50
219
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/SizedMarshallableDataAccess.java
SizedMarshallableDataAccess
getUsing
class SizedMarshallableDataAccess<T> extends InstanceCreatingMarshaller<T> implements DataAccess<T>, Data<T> { // Config fields private SizedReader<T> sizedReader; private SizedWriter<? super T> sizedWriter; // Cache fields private transient boolean bytesInit; private transient Bytes b...
if (using == null) using = createInstance(); T result = sizedReader.read(bytes, size(), using); bytes.readPosition(0); return result;
1,049
48
1,097
<methods>public void readMarshallable(net.openhft.chronicle.wire.WireIn) ,public void writeMarshallable(net.openhft.chronicle.wire.WireOut) <variables>private java.lang.reflect.Type tClass
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/StopBitSizeMarshaller.java
StopBitSizeMarshaller
minStoringLengthOfSizesInRange
class StopBitSizeMarshaller implements SizeMarshaller, EnumMarshallable<StopBitSizeMarshaller> { public static final StopBitSizeMarshaller INSTANCE = new StopBitSizeMarshaller(); private static final long MIN_ENCODABLE_SIZE = Long.MIN_VALUE; private static final long MAX_ENCODABLE_SIZE = Long.MAX_VA...
rangeChecks(minSize, maxSize); // different signs if (minSize * maxSize < 0) { // the range includes 0 which encoding length is 1 return 1; } return min(storingLength(minSize), storingLength(maxSize));
466
74
540
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/StringBuilderSizedReader.java
StringBuilderSizedReader
read
class StringBuilderSizedReader implements SizedReader<StringBuilder>, EnumMarshallable<StringBuilderSizedReader> { public static final StringBuilderSizedReader INSTANCE = new StringBuilderSizedReader(); private StringBuilderSizedReader() { } @NotNull @Override public StringBuilder read...
if (0 > size || size > Integer.MAX_VALUE) throw new IllegalStateException("positive int size expected, " + size + " given"); int csLen = (int) size; if (using == null) { using = new StringBuilder(csLen); } else { using.setLength(0); using....
141
123
264
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/StringBuilderUtf8DataAccess.java
StringBuilderUtf8DataAccess
getUsing
class StringBuilderUtf8DataAccess extends AbstractCharSequenceUtf8DataAccess<StringBuilder> { public StringBuilderUtf8DataAccess() { this(DEFAULT_BYTES_CAPACITY); } private StringBuilderUtf8DataAccess(long bytesCapacity) { super(bytesCapacity); } @Override public Strin...
if (using != null) { using.setLength(0); } else { using = new StringBuilder(cs.length()); } using.append(cs); return using;
155
55
210
<methods>public net.openhft.chronicle.bytes.RandomDataInput bytes() ,public java.lang.StringBuilder get() ,public Data<java.lang.StringBuilder> getData(java.lang.StringBuilder) ,public long offset() ,public void readMarshallable(net.openhft.chronicle.wire.WireIn) ,public long size() ,public void uninit() ,public void w...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/StringBytesReader.java
StringBytesReader
read
class StringBytesReader implements BytesReader<String>, StatefulCopyable<StringBytesReader> { /** * Cache field */ private transient StringBuilder sb; public StringBytesReader() { initTransients(); } private void initTransients() { sb = new StringBuilder(); } @N...
if (in.readUtf8(sb)) { return sb.toString(); } else { throw new NullPointerException("BytesReader couldn't read null"); }
215
48
263
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/StringSizedReader.java
StringSizedReader
read
class StringSizedReader implements SizedReader<String>, StatefulCopyable<StringSizedReader> { /** * Cache field */ private transient StringBuilder sb; public StringSizedReader() { initTransients(); } private void initTransients() { sb = new StringBuilder(); } @N...
if (0 > size || size > Integer.MAX_VALUE) throw new IllegalStateException("positive int size expected, " + size + " given"); sb.setLength(0); BytesUtil.parseUtf8(in, sb, (int) size); return sb.toString();
225
75
300
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/TypedMarshallableReaderWriter.java
TypedMarshallableReaderWriter
read
class TypedMarshallableReaderWriter<V extends Marshallable> extends CachingCreatingMarshaller<V> { public TypedMarshallableReaderWriter(Class<V> vClass) { super(vClass); } @NotNull @Override public V read(Bytes in, long size, @Nullable V using) {<FILL_FUNCTION_BODY>} protected...
BinaryWire wire = Wires.binaryWireForRead(in, in.readPosition(), size); return (V) wire.getValueIn().object(using, tClass());
136
47
183
<methods>public void <init>(Class<V>) ,public long size(V) ,public void write(Bytes#RAW, long, V) <variables>static final ThreadLocal<java.lang.Object> LAST_TL,static final ThreadLocal<net.openhft.chronicle.wire.Wire> WIRE_TL
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/ValueDataAccess.java
ValueDataAccess
allocateBytesStoreForInstance
class ValueDataAccess<T> extends AbstractData<T> implements DataAccess<T> { /** * Config field */ private Class<T> valueType; // Cache fields private transient Class<? extends T> nativeClass; private transient Class<? extends T> heapClass; private transient Byteable nativeInstance; ...
long instanceSize = nativeInstance.maxSize(); if (instanceSize > 0x7FFFFFF0) { return BytesStore.nativeStoreWithFixedCapacity(instanceSize); } else { return BytesStore.wrap(ByteBuffer.allocate(Maths.toUInt31(instanceSize))); }
794
82
876
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/hash/serialization/impl/ValueReader.java
ValueReader
initTransients
class ValueReader<T> implements SizedReader<T>, BytesReader<T>, StatefulCopyable<ValueReader<T>> { /** * Config field */ private Class<T> valueType; // Cache fields private transient Class<? extends T> nativeClass; private transient Class<? extends T> heapClass; private trans...
nativeClass = Values.nativeClassFor(valueType); heapClass = Values.heapClassFor(valueType); nativeReference = (Byteable) Values.newNativeReference(valueType);
622
53
675
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/ChronicleHashCorruptionImpl.java
ChronicleHashCorruptionImpl
set
class ChronicleHashCorruptionImpl implements ChronicleHashCorruption { private int segmentIndex; private Supplier<String> messageSupplier; private Throwable exception; private String message; public static void report( ChronicleHashCorruption.Listener corruptionListener, Ch...
this.segmentIndex = segmentIndex; this.messageSupplier = messageSupplier; this.exception = exception; this.message = null;
384
42
426
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/ChronicleMapEntrySet.java
ChronicleMapEntrySet
contains
class ChronicleMapEntrySet<K, V> extends AbstractSet<Map.Entry<K, V>> { private final AbstractChronicleMap<K, V> map; public ChronicleMapEntrySet(AbstractChronicleMap<K, V> map) { this.map = map; } @NotNull public Iterator<Map.Entry<K, V>> iterator() { return new ChronicleMapItera...
if (!(o instanceof Map.Entry)) return false; Map.Entry<?, ?> e = (Map.Entry<?, ?>) o; try { V v = map.get(e.getKey()); return v != null && v.equals(e.getValue()); } catch (ClassCastException | NullPointerException ex) { return false; ...
311
98
409
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/ChronicleMapIterator.java
ChronicleMapIterator
remove
class ChronicleMapIterator<K, V, E> implements Iterator<E>, Consumer<MapEntry<K, V>> { final AbstractChronicleMap<K, V> map; private final Thread ownerThread = Thread.currentThread(); private final Queue<E> entryBuffer = new ArrayDeque<>(); E returned; private int segmentIndex; ChronicleMapIte...
checkSingleThreaded(); if (returned == null) throw new IllegalStateException(map.toIdentityString()); removeReturned(); returned = null;
789
45
834
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/JsonSerializer.java
JsonSerializer
xStream
class JsonSerializer { private JsonSerializer() { } static final String LOG_ERROR_SUGGEST_X_STREAM = "map.getAll(<file>) and map.putAll(<file>) methods require the JSON XStream serializer, " + "we don't include these artifacts by default as some users don't require this func...
try { final XStream xstream = new XStream(new JettisonMappedXmlDriver()); xstream.setMode(XStream.NO_REFERENCES); xstream.alias("cmap", map.getClass()); registerChronicleMapConverter(map, xstream); xstream.registerConverter(new ByteBufferConverter())...
702
286
988
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/MapDiagnostics.java
MapDiagnostics
printMapStats
class MapDiagnostics { private MapDiagnostics() { } public static void main(String[] args) throws IOException { String mapFile = args[0]; try (ChronicleMap map = ChronicleMap.of(Object.class, Object.class) .createPersistedTo(new File(mapFile))) { printMapStats(m...
for (int i = 0; i < map.segments(); i++) { try (MapSegmentContext<K, V, ?> c = map.segmentContext(i)) { System.out.printf("segment %d contains %d entries\n", i, c.size()); c.forEachSegmentEntry(e -> System.out.printf("%s, %d bytes -> %s, %d bytes\n", ...
137
134
271
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/MapMethodsSupport.java
MapMethodsSupport
returnCurrentValueIfPresent
class MapMethodsSupport { private MapMethodsSupport() { } static <V> void returnCurrentValueIfPresent( MapQueryContext<?, V, ?> q, ReturnValue<V> returnValue) {<FILL_FUNCTION_BODY>} static <V> boolean tryReturnCurrentValueIfPresent( MapQueryContext<?, V, ?> q, ReturnValue<V> r...
MapEntry<?, V> entry = q.entry(); if (entry != null) returnValue.returnValue(entry.value());
241
38
279
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java
OldDeletedEntriesCleanupThread
cleanupSegment
class OldDeletedEntriesCleanupThread extends Thread implements MapClosable, Predicate<ReplicableEntry> { /** * Don't store a strong ref to a map in order to avoid it's leaking, if the user forgets to close() map, from where this thread is shut down * explicitly. Dereference map within a single me...
ReplicatedChronicleMap<?, ?, ?> map = mapRef.get(); if (map == null) return -1; int segmentIndex = map.globalMutableState().getCurrentCleanupSegmentIndex(); int nextSegmentIndex; try (MapSegmentContext<?, ?, ?> context = map.segmentContext(segmentIndex)) { ...
1,619
272
1,891
<methods>public void <init>() ,public void <init>(java.lang.Runnable) ,public void <init>(java.lang.String) ,public void <init>(java.lang.ThreadGroup, java.lang.Runnable) ,public void <init>(java.lang.ThreadGroup, java.lang.String) ,public void <init>(java.lang.Runnable, java.lang.String) ,public void <init>(java.lang....
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/SelectedSelectionKeySet.java
SelectedSelectionKeySet
flip
class SelectedSelectionKeySet extends AbstractSet<SelectionKey> { private SelectionKey[] keysA; private int keysASize; private SelectionKey[] keysB; private int keysBSize; private boolean isA = true; SelectedSelectionKeySet() { keysA = new SelectionKey[1024]; keysB = keysA.clon...
if (isA) { isA = false; keysA[keysASize] = null; keysBSize = 0; return keysA; } else { isA = true; keysB[keysBSize] = null; keysASize = 0; return keysB; }
545
85
630
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/channel/MapHandler.java
MapHandler
createMapHandler
class MapHandler<VALUE, REPLY> extends AbstractHandler<MapHandler<VALUE, REPLY>> { protected MapService<VALUE, REPLY> mapService; private String mapName; protected MapHandler(String mapName) { this.mapName = mapName; } public static <V, O> MapHandler<V, O> createMapHandler(String mapName, ...
MapHandler<V, O> mh = new MapHandler<>(mapName); mh.mapService = mapService; return mh;
365
40
405
<methods>public void <init>() ,public java.lang.Boolean buffered() ,public MapHandler<VALUE,REPLY> buffered(java.lang.Boolean) <variables>private java.lang.Boolean buffered
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/channel/internal/MapChannel.java
MapChannel
createMap
class MapChannel<VALUE, REPLY> extends SimpleCloseable implements ChronicleChannel { private static final OkHeader OK = new OkHeader(); private final String mapName; private final MapService<VALUE, REPLY> mapService; private final ChronicleChannelCfg channelCfg; private final ChronicleMap<Bytes<?>,...
// assume it has to already exist, but if not take a guess on sizes final Class<VALUE> valueClass = mapService.valueClass(); final Class<Bytes<?>> bytesClass = (Class) Bytes.class; final ChronicleMapBuilder<Bytes<?>, VALUE> builder = ChronicleMap.of(bytesClass, valueClass) ...
645
296
941
<methods>public final void close() ,public boolean isClosed() <variables>private volatile transient boolean closed
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/data/DummyValueZeroData.java
DummyValueZeroData
getUsing
class DummyValueZeroData<V> extends AbstractData<V> { private final Bytes zeroBytes = ZeroBytesStore.INSTANCE.bytesForRead(); @StageRef VanillaChronicleMapHolder<?, ?, ?> mh; @StageRef ValueBytesInterop<V> vi; @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; @Override ...
checkOnEachPublicOperation.checkOnEachPublicOperation(); zeroBytes.readPosition(0); try { return vi.valueReader.read(zeroBytes, size(), using); } catch (Exception e) { throw zeroReadException(e); }
443
69
512
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/EntryValueBytesData.java
EntryValueBytesData
innerGetUsing
class EntryValueBytesData<V> extends AbstractData<V> { @StageRef VanillaChronicleMapHolder<?, V, ?> mh; @StageRef ValueBytesInterop<V> vi; @StageRef SegmentStages s; @StageRef MapEntryStages<?, V> entry; @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; @Stag...
Bytes segmentBytes = s.segmentBytesForRead(); segmentBytes.readPosition(entry.valueOffset); return vi.valueReader.read(segmentBytes, size(), usingValue);
482
50
532
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/WrappedValueBytesData.java
WrappedValueBytesData
getUnusedWrappedValueBytesData
class WrappedValueBytesData<V> extends AbstractData<V> { @Stage("WrappedValueBytes") private final VanillaBytes wrappedValueBytes = VanillaBytes.vanillaBytes(); @StageRef ValueBytesInterop<V> vi; @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; private WrappedValueBytesData<...
if (!wrappedValueBytesStoreInit()) return this; if (next == null) next = new WrappedValueBytesData<>(); return next.getUnusedWrappedValueBytesData();
834
53
887
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/data/instance/WrappedValueInstanceDataHolder.java
WrappedValueInstanceDataHolder
getUnusedWrappedValueHolder
class WrappedValueInstanceDataHolder<V> { public Data<V> wrappedData = null; @StageRef VanillaChronicleMapHolder<?, V, ?> mh; private final DataAccess<V> wrappedValueDataAccess = mh.m().valueDataAccess.copy(); private WrappedValueInstanceDataHolder<V> next; private V value; boolean nextIni...
if (!valueInit()) return this; if (next == null) next = new WrappedValueInstanceDataHolder<>(); return next.getUnusedWrappedValueHolder();
319
49
368
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/entry/ReplicatedMapEntryStages.java
ReplicatedMapEntryStages
updatedReplicationStateOnPresentEntry
class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V> implements MapReplicableEntry<K, V> { @StageRef ReplicatedChronicleMapHolder<?, ?, ?> mh; @StageRef ReplicationUpdate ru; @Stage("ReplicationState") long replicationBytesOffset = -1; void initReplicationState() { ...
if (!ru.replicationUpdateInit()) { s.innerWriteLock.lock(); long timestamp = Math.max(timestamp() + 1, currentTime()); updateReplicationState(mh.m().identifier(), timestamp); }
1,123
61
1,184
<methods>public non-sealed void <init>() ,public boolean entryDeleted() ,public long entryEnd() ,public final long entrySize(long, long) ,public final void freeExtraAllocatedChunks() ,public void initValue(Data<?>) ,public void innerDefaultReplaceValue(Data<V>) ,public long innerEntrySize(long, long) ,public long newEn...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/input/ReplicatedInput.java
ReplicatedInput
processReplicatedEvent
class ReplicatedInput<K, V, R> implements RemoteOperationContext<K>, MapRemoteQueryContext<K, V, R>, Replica.QueryContext<K, V> { @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; @StageRef ReplicatedChronicleMapHolder<K, V, R> mh; @StageRef ReplicationUpdate<K> ru; @...
long timestamp = replicatedInputBytes.readStopBit(); byte identifier = replicatedInputBytes.readByte(); ru.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier); boolean isDeleted = replicatedInputBytes.readBoolean(); long keySize = mh.m().keySizeMarshaller.readSiz...
414
296
710
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java
MapSegmentIteration
doReplaceValue
class MapSegmentIteration<K, V, R> extends HashSegmentIteration<K, MapEntry<K, V>> implements MapEntry<K, V>, IterationContext<K, V, R> { @StageRef MapEntryStages<K, V> entry; @StageRef WrappedValueInstanceDataHolder<V> wrappedValueInstanceDataHolder; @StageRef WrappedValueInstanceDataH...
throwExceptionIfClosed(); checkOnEachPublicOperation.checkOnEachPublicOperation(); try { entry.innerDefaultReplaceValue(newValue); } finally { s.innerWriteLock.unlock(); }
238
60
298
<methods>public non-sealed void <init>() ,public void checkEntryNotRemovedOnThisIteration() ,public void doRemove() ,public java.lang.Object entryForIteration() ,public void forEachSegmentEntry(Consumer<? super MapEntry<K,V>>) ,public boolean forEachSegmentEntryWhile(Predicate<? super MapEntry<K,V>>) ,public boolean fo...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedMapSegmentIteration.java
ReplicatedMapSegmentIteration
doInsert
class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentIteration<K, V, R> implements ReplicatedIterationContext<K, V, R>, ReplicableEntry, ReplicatedHashSegmentContext<K, MapEntry<K, V>> { @StageRef VanillaChronicleMapHolder<K, V, R> mh; @StageRef ReplicatedMapEntryStages<K, V> ...
throwExceptionIfClosed(); if (mh.set() == null) throw new IllegalStateException(mh.h().toIdentityString() + ": Called SetAbsentEntry.doInsert() from Map context"); doInsert((Data<V>) DummyValueData.INSTANCE);
1,219
78
1,297
<methods>public non-sealed void <init>() ,public WrappedValueInstanceDataHolderAccess<K,V,?> context() ,public void doReplaceValue(Data<V>) ,public void hookAfterEachIteration() <variables>MapEntryStages<K,V> entry,WrappedValueInstanceDataHolder<V> wrappedValueInstanceDataHolder,WrappedValueInstanceDataHolderAccess<K,V...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedTierRecovery.java
ReplicatedTierRecovery
cleanupModificationIterationBits
class ReplicatedTierRecovery extends TierRecovery { @StageRef ReplicatedChronicleMapHolder<?, ?, ?> rh; @StageRef SegmentStages s; @StageRef ReplicatedMapEntryStages<?, ?> e; @Override public void removeDuplicatesInSegment( ChronicleHashCorruption.Listener corruptionListene...
ReplicatedChronicleMap<?, ?, ?> m = rh.m(); ReplicatedChronicleMap<?, ?, ?>.ModificationIterator[] its = m.acquireAllModificationIterators(); ReusableBitSet freeList = s.freeList; for (long pos = 0; pos < m.actualChunksPerSegmentTier; ) { long nextPos = freeL...
506
356
862
<methods>public non-sealed void <init>() ,public int recoverTier(int, net.openhft.chronicle.hash.ChronicleHashCorruption.Listener, net.openhft.chronicle.map.ChronicleHashCorruptionImpl) ,public void removeDuplicatesInSegment(net.openhft.chronicle.hash.ChronicleHashCorruption.Listener, net.openhft.chronicle.map.Chronicl...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/map/ReplicatedChronicleMapHolderImpl.java
ReplicatedChronicleMapHolderImpl
initMap
class ReplicatedChronicleMapHolderImpl<K, V, R> extends Chaining implements ReplicatedChronicleMapHolder<K, V, R> { @Stage("Map") private ReplicatedChronicleMap<K, V, R> m = null; public ReplicatedChronicleMapHolderImpl(VanillaChronicleMap map) { super(map); } public Repli...
// alternative to this "unsafe" casting approach is proper generalization // of Chaining/ChainingInterface, but this causes issues with current version // of stage-compiler. // TODO generalize Chaining with <M extends VanillaCM> when stage-compiler is improved. //noinspection un...
350
97
447
<methods>public void <init>(VanillaChronicleMap#RAW) ,public void <init>(net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface, VanillaChronicleMap#RAW) ,public T contextAtIndexInChain(int) ,public T getContext(Class<? extends T>, BiFunction<net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface,VanillaChr...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/map/VanillaChronicleMapHolderImpl.java
VanillaChronicleMapHolderImpl
initMap
class VanillaChronicleMapHolderImpl<K, V, R> extends Chaining implements VanillaChronicleMapHolder<K, V, R> { @Stage("Map") private VanillaChronicleMap<K, V, R> m = null; public VanillaChronicleMapHolderImpl(VanillaChronicleMap map) { super(map); } public VanillaChronicleM...
// alternative to this "unsafe" casting approach is proper generalization // of Chaining/ChainingInterface, but this causes issues with current version // of stage-compiler. // TODO generalize Chaining with <M extends VanillaCM> when stage-compiler is improved. //noinspection un...
344
81
425
<methods>public void <init>(VanillaChronicleMap#RAW) ,public void <init>(net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface, VanillaChronicleMap#RAW) ,public T contextAtIndexInChain(int) ,public T getContext(Class<? extends T>, BiFunction<net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface,VanillaChr...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/map/WrappedValueBytesDataAccess.java
WrappedValueBytesDataAccess
wrapValueBytesAsData
class WrappedValueBytesDataAccess<K, V, R> implements MapContext<K, V, R> { @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; @StageRef WrappedValueBytesData<V> wrappedValueBytesData; @Override public Data<V> wrapValueBytesAsData(BytesStore bytesStore, long offset, long size) {<...
Objects.requireNonNull(bytesStore); checkOnEachPublicOperation.checkOnEachPublicOperation(); WrappedValueBytesData<V> wrapped = this.wrappedValueBytesData; wrapped = wrapped.getUnusedWrappedValueBytesData(); wrapped.initWrappedValueBytesStore(bytesStore, offset, size); r...
111
87
198
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/map/WrappedValueInstanceDataHolderAccess.java
WrappedValueInstanceDataHolderAccess
wrapValueAsData
class WrappedValueInstanceDataHolderAccess<K, V, R> implements MapContext<K, V, R>, SetContext<K, R> { @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; @StageRef WrappedValueInstanceDataHolder<V> wrappedValueInstanceDataHolder; @Override public Data<V> wrapValueAsData(V...
checkOnEachPublicOperation.checkOnEachPublicOperation(); WrappedValueInstanceDataHolder<V> wrapped = this.wrappedValueInstanceDataHolder; wrapped = wrapped.getUnusedWrappedValueHolder(); wrapped.initValue(value); return wrapped.wrappedData;
115
71
186
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapAbsent.java
MapAbsent
doInsert
class MapAbsent<K, V> implements Absent<K, V> { @StageRef public KeySearch<K> ks; @StageRef public HashLookupSearch hashLookupSearch; @StageRef public CheckOnEachPublicOperation checkOnEachPublicOperation; @StageRef public SegmentStages s; @StageRef MapQuery<K, V, ?> q; @Sta...
q.putPrefix(); if (!q.entryPresent()) { putEntry(value); s.incrementModCount(); ks.setSearchState(PRESENT); q.initPresenceOfEntry(EntryPresence.PRESENT); } else { throw new IllegalStateException(mh.h().toIdentityString() + ...
471
110
581
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapQuery.java
MapQuery
doReplaceValue
class MapQuery<K, V, R> extends HashQuery<K> implements MapEntry<K, V>, ExternalMapQueryContext<K, V, R>, ExternalSetQueryContext<K, R>, QueryContextInterface<K, V, R>, MapAndSetContext<K, V, R> { @StageRef public AcquireHandle<K, V> acquireHandle; @StageRef public DefaultReturnValue<V>...
putPrefix(); if (entryPresent()) { e.innerDefaultReplaceValue(newValue); s.incrementModCount(); ks.setSearchState(PRESENT); initPresenceOfEntry(EntryPresence.PRESENT); } else { throw new IllegalStateException(mh.h().toIdentityString() ...
778
110
888
<methods>public non-sealed void <init>() ,public void doRemove() ,public void dropSearchIfNestedContextsAndPresentHashLookupSlotCheckFailed() ,public boolean entryPresent() ,public void initPresenceOfEntry(net.openhft.chronicle.hash.impl.stage.query.HashQuery.EntryPresence) ,public DataAccess<K> inputKeyDataAccess() ,p...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/query/ReplicatedMapAbsent.java
ReplicatedMapAbsent
doInsert
class ReplicatedMapAbsent<K, V> extends MapAbsent<K, V> { @StageRef MapQuery<K, V, ?> q; @StageRef ReplicatedMapEntryStages<K, V> e; @StageRef ReplicationUpdate<K> ru; @NotNull @Override public Data<K> absentKey() { checkOnEachPublicOperation.checkOnEachPublicOperation(); ...
q.putPrefix(); if (!q.entryPresent()) { if (!ks.searchStatePresent()) { putEntry(value); e.updatedReplicationStateOnAbsentEntry(); ks.setSearchState(PRESENT); q.initPresenceOfEntry(EntryPresence.PRESENT); } else { ...
159
200
359
<methods>public non-sealed void <init>() ,public Data<K> absentKey() ,public MapQuery<K,V,?> context() ,public void doInsert(Data<V>) ,public void doInsert() <variables>public net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation checkOnEachPublicOperation,MapEntryStages<K,V> e,public net.openhft.chroni...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/query/ReplicatedMapQuery.java
ReplicatedMapQuery
absentEntry
class ReplicatedMapQuery<K, V, R> extends MapQuery<K, V, R> implements MapRemoteQueryContext<K, V, R>, SetRemoteQueryContext<K, R>, ReplicableEntry, MapReplicableEntry<K, V>, SetReplicableEntry<K> { @StageRef ReplicatedMapEntryStages<K, V> e; @StageRef ReplicationUpdate ru; @StageR...
checkOnEachPublicOperation.checkOnEachPublicOperation(); if (entryPresent()) { return null; } else { if (!ks.searchStatePresent()) { return absentDelegating; } else { assert e.entryDeleted(); return absent; ...
575
79
654
<methods>public non-sealed void <init>() ,public Absent<K,V> absentEntry() ,public MapQuery<K,V,R> context() ,public void doReplaceValue(Data<V>) ,public MapQuery<K,V,R> entry() ,public Data<K> getInputKeyBytesAsData(BytesStore#RAW, long, long) ,public DataAccess<V> inputValueDataAccess() <variables>public MapAbsent<K,...
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/replication/ReplicatedQueryAlloc.java
ReplicatedQueryAlloc
alloc
class ReplicatedQueryAlloc extends QueryAlloc { final CleanupAction cleanupAction = new CleanupAction(); @StageRef ReplicatedChronicleMapHolder<?, ?, ?> mh; @StageRef SegmentStages s; /** * Returns {@code true} if at least one old deleted entry was removed. * * @param prevPos po...
long ret = s.allocReturnCode(chunks); if (ret >= 0) { if (prevPos >= 0) s.free(prevPos, prevChunks); return ret; } int firstAttemptedTier = s.tier; long firstAttemptedTierIndex = s.tierIndex; long firstAttemptedTierBaseAddr = s.tie...
562
522
1,084
<methods>public non-sealed void <init>() ,public long alloc(int, long, int) <variables>public net.openhft.chronicle.hash.impl.stage.entry.SegmentStages s
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/replication/ReplicationUpdate.java
ReplicationUpdate
initReplicationUpdate
class ReplicationUpdate<K> implements RemoteOperationContext<K> { @Stage("ReplicationUpdate") public byte innerRemoteIdentifier = (byte) 0; @Stage("ReplicationUpdate") public long innerRemoteTimestamp; @Stage("ReplicationUpdate") public byte innerRemoteNodeIdentifier; @StageRef SegmentSt...
innerRemoteTimestamp = timestamp; if (identifier == 0) throw new IllegalStateException(mh.h().toIdentityString() + ": identifier can't be 0"); innerRemoteIdentifier = identifier; if (remoteNodeIdentifier == 0) { throw new IllegalStateException( ...
651
112
763
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/ret/DefaultReturnValue.java
DefaultReturnValue
returnValue
class DefaultReturnValue<V> implements InstanceReturnValue<V> { private V defaultReturnedValue = null; abstract boolean defaultReturnedValueInit(); private void initDefaultReturnedValue(@NotNull Data<V> value) { defaultReturnedValue = value.getUsing(null); } @Override public void retu...
if (defaultReturnedValueInit()) { return defaultReturnedValue; } else { return null; }
135
35
170
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/impl/stage/ret/UsingReturnValue.java
UsingReturnValue
returnValue
class UsingReturnValue<V> implements UsableReturnValue<V> { private V usingReturnValue = (V) USING_RETURN_VALUE_UNINIT; private V returnedValue = null; @Override public void initUsingReturnValue(V usingReturnValue) { this.usingReturnValue = usingReturnValue; } abstract boolean returne...
if (returnedValueInit()) { return returnedValue; } else { return null; }
188
32
220
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/map/internal/InternalAssertUtil.java
InternalAssertUtil
assertAddress
class InternalAssertUtil { private static final boolean IS_64_BIT = Jvm.is64bit(); // Suppresses default constructor, ensuring non-instantiability. private InternalAssertUtil() { } public static boolean assertAddress(final long address) {<FILL_FUNCTION_BODY>} public static boolean assertPosi...
if (Jvm.is64bit()) { // It is highly unlikely that we would ever address farther than 2^63 assert address > 0 : "address is non positive: " + address; } else { // These memory addresses are illegal on a 32-bit machine assert address != 0 && address != -1 ...
123
104
227
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilderPrivateAPI.java
ChronicleSetBuilderPrivateAPI
remoteOperations
class ChronicleSetBuilderPrivateAPI<K> implements ChronicleHashBuilderPrivateAPI<K, SetRemoteOperations<K, ?>> { private final ChronicleHashBuilderPrivateAPI<K, MapRemoteOperations<K, DummyValue, ?>> mapB; public ChronicleSetBuilderPrivateAPI( ChronicleHashBuilderPrivateAPI<K, MapRemoteOpe...
mapB.remoteOperations(new MapRemoteOperations<K, DummyValue, Object>() { @Override public void remove(MapRemoteQueryContext<K, DummyValue, Object> q) { //noinspection unchecked remoteOperations.remove((SetRemoteQueryContext) q); } ...
765
147
912
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/chronicle/set/SetFromMap.java
SetFromMap
toIdentityString
class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> { private final ChronicleMap<E, DummyValue> m; // The backing map private transient Set<E> s; // Its keySet SetFromMap(VanillaChronicleMap<E, DummyValue, ?> map) { m = map; map.chronicleSet = this; s = map...
throwExceptionIfClosed(); return "ChronicleSet{" + "name=" + name() + ", file=" + file() + ", identityHashCode=" + System.identityHashCode(this) + "}";
1,340
65
1,405
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/xstream/converters/AbstractChronicleMapConverter.java
AbstractChronicleMapConverter
unmarshal
class AbstractChronicleMapConverter<K, V> implements Converter { private final Map<K, V> map; private final Class mapClazz; AbstractChronicleMapConverter(@NotNull Map<K, V> map) { this.map = map; this.mapClazz = map.getClass(); } private static <E> E deserialize(@NotNull Unmarshal...
// empty map if ("[\"\"]".equals(reader.getValue())) return null; if (!"cmap".equals(reader.getNodeName())) throw new ConversionException("should be under 'cmap' node"); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ...
754
245
999
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/xstream/converters/ByteBufferConverter.java
ByteBufferConverter
unmarshal
class ByteBufferConverter implements Converter { private final Charset charset = Charset.forName("ISO-8859-1"); private final CharsetDecoder decoder = charset.newDecoder(); @Override public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext marshallingContext) { ByteBuf...
reader.moveDown(); int position = (Integer) unmarshallingContext.convertAnother(null, int.class); reader.moveUp(); reader.moveDown(); int capacity = (Integer) unmarshallingContext.convertAnother(null, int.class); reader.moveUp(); reader.moveDown(); int...
439
338
777
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/xstream/converters/CharSequenceConverter.java
CharSequenceConverter
unmarshal
class CharSequenceConverter implements Converter { @Override public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context) { writer.setValue(source.toString()); } @Override public Object unmarshal(HierarchicalStreamReader reader, Unmarshalling...
if (context.getRequiredType() == StringBuilder.class) { return new StringBuilder(reader.getValue()); } else { return reader.getValue(); }
130
46
176
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/xstream/converters/ValueConverter.java
ValueConverter
unmarshal
class ValueConverter implements Converter { @Override public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) { ValueModel valueModel = ValueModel.acquire(o.getClass()); valueModel.fields().forEach(fieldModel -> { if (fieldModel instanceof Array...
try { ValueModel valueModel = ValueModel.acquire(context.getRequiredType()); Object result = valueModel.heapClass().newInstance(); fillInObject(reader, context, valueModel, result); return result; } catch (Exception e) { throw new ConversionEx...
865
101
966
<no_super_class>
OpenHFT_Chronicle-Map
Chronicle-Map/src/main/java/net/openhft/xstream/converters/VanillaChronicleMapConverter.java
VanillaChronicleMapConverter
marshal
class VanillaChronicleMapConverter<K, V> extends AbstractChronicleMapConverter<K, V> { public VanillaChronicleMapConverter(@NotNull Map<K, V> map) { super(map); } @Override public void marshal(Object o, final HierarchicalStreamWriter writer, final MarshallingContext marshallingCont...
((ChronicleMap<K, V>) o).forEachEntry(e -> { writer.startNode("entry"); { final Object key = e.key().get(); writer.startNode(key.getClass().getName()); marshallingContext.convertAnother(key); writer.endNode(); ...
107
140
247
<methods>public boolean canConvert(Class#RAW) ,public void marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext) ,public java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters....
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/ChronicleHistoryReaderMain.java
ChronicleHistoryReaderMain
options
class ChronicleHistoryReaderMain { public static void main(@NotNull String[] args) { new ChronicleHistoryReaderMain().run(args); } protected void run(String[] args) { final Options options = options(); final CommandLine commandLine = parseCommandLine(args, options); try (f...
final Options options = new Options(); ChronicleReaderMain.addOption(options, "d", "directory", true, "Directory containing chronicle queue files", true); ChronicleReaderMain.addOption(options, "h", "help-message", false, "Print this help and exit", false); ChronicleReaderMain.addOption...
724
289
1,013
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/channel/PipeHandler.java
PipeHandler
run
class PipeHandler extends AbstractHandler<PipeHandler> { private String publish; private String subscribe; private SyncMode syncMode; private transient Thread tailerThread; private Predicate<Wire> filter = null; private int publishSourceId = 0; private int subscribeSourceId = 0; priva...
Pauser pauser = Pauser.balanced(); try (ChronicleQueue subscribeQ = newQueue(context, subscribe, syncMode, subscribeSourceId)) { final ExcerptTailer tailer; if (channel instanceof BufferedChronicleChannel) { BufferedChronicleChannel bc = (BufferedChronicleChann...
938
407
1,345
<methods>public void <init>() ,public java.lang.Boolean buffered() ,public net.openhft.chronicle.queue.channel.PipeHandler buffered(java.lang.Boolean) <variables>private java.lang.Boolean buffered
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/channel/PublishHandler.java
PublishHandler
copyFromChannelToQueue
class PublishHandler extends AbstractHandler<PublishHandler> { private String publish; private SyncMode syncMode; private int publishSourceId = 0; static void copyFromChannelToQueue(ChronicleChannel channel, Pauser pauser, ChronicleQueue publishQueue, SyncMode syncMode) {<FILL_FUNCTION_BODY>} priv...
try (ChronicleQueue publishQ = publishQueue; ExcerptAppender appender = publishQ.createAppender()) { appender.singleThreadedCheckDisabled(true); // assume we are thread safe boolean needsSync = false; while (!channel.isClosed()) { try (Document...
508
263
771
<methods>public void <init>() ,public java.lang.Boolean buffered() ,public net.openhft.chronicle.queue.channel.PublishHandler buffered(java.lang.Boolean) <variables>private java.lang.Boolean buffered
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/channel/SubscribeHandler.java
NoOp
run
class NoOp extends SelfDescribingMarshallable implements Consumer { @Override public void accept(Object o) { return; } } public final static Consumer NO_OP = new NoOp(); private String subscribe; private transient boolean closeWhenRunEnds = true; private SyncMo...
Pauser pauser = Pauser.balanced(); final ExcerptTailer tailer; try (ChronicleQueue subscribeQ = newQueue(context, subscribe, syncMode, sourceId)) { InternalChronicleChannel icc = (InternalChronicleChannel) channel; if (icc.supportsEventPoller()) { taile...
819
207
1,026
<methods>public void <init>() ,public java.lang.Boolean buffered() ,public net.openhft.chronicle.queue.channel.SubscribeHandler buffered(java.lang.Boolean) <variables>private java.lang.Boolean buffered
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/channel/impl/PublishQueueChannel.java
PublishQueueChannel
testMessage
class PublishQueueChannel implements ChronicleChannel { private final ChronicleChannelCfg channelCfg; private final AbstractHandler publishHandler; private final ChannelHeader headerOut; private final ChronicleQueue publishQueue; private final ExcerptTailer tailer; public PublishQueueChannel(Ch...
try (DocumentContext dc = writingDocument(true)) { dc.wire().write("testMessage").writeLong(NanoTime.INSTANCE, now); }
479
45
524
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/channel/impl/SubscribeQueueChannel.java
SubscribeQueueChannel
readingDocument
class SubscribeQueueChannel implements ChronicleChannel { private final ChronicleChannelCfg channelCfg; private final AbstractHandler pipeHandler; private final ChannelHeader headerOut; private final ChronicleQueue subscribeQueue; private final ExcerptTailer tailer; private long lastTestMessage;...
final DocumentContext dc = tailer.readingDocument(true); if (dc.isMetaData()) { final Wire wire = dc.wire(); long pos = wire.bytes().readPosition(); final String event = wire.readEvent(String.class); if ("testMessage".equals(event)) { fina...
452
200
652
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/RollingResourcesCache.java
RollingResourcesCache
parseCount0
class RollingResourcesCache { public static final ParseCount NO_PARSE_COUNT = new ParseCount("", Integer.MIN_VALUE); private static final int CACHE_SIZE = Jvm.getInteger("chronicle.queue.rollingResourceCache.size", 128); private static final int ONE_DAY_IN_MILLIS = 86400000; private static final int MAX...
try { TemporalAccessor parse = formatter.parse(name); if (!parse.isSupported(ChronoField.EPOCH_DAY)) { final WeekFields weekFields = WeekFields.of(formatter.getLocale()); if (parse.isSupported(weekFields.weekBasedYear()) && parse.isSupported(weekFields.we...
1,351
407
1,758
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/WireStorePool.java
WireStorePool
acquire
class WireStorePool extends SimpleCloseable { @NotNull private final WireStoreSupplier supplier; private final StoreFileListener storeFileListener; private WireStorePool(@NotNull WireStoreSupplier supplier, StoreFileListener storeFileListener) { this.supplier = supplier; this.storeFileL...
throwExceptionIfClosed(); // reuse cycle store when applicable if (oldStore != null && oldStore.cycle() == cycle && !oldStore.isClosed()) return oldStore; SingleChronicleQueueStore store = this.supplier.acquire(cycle, createStrategy); if (store != null) { ...
440
148
588
<methods>public final void close() ,public boolean isClosed() <variables>private volatile transient boolean closed
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/FileSystemDirectoryListing.java
FileSystemDirectoryListing
refresh
class FileSystemDirectoryListing extends SimpleCloseable implements DirectoryListing { private final File queueDir; private final ToIntFunction<String> fileNameToCycleFunction; private int minCreatedCycle = Integer.MAX_VALUE; private int maxCreatedCycle = Integer.MIN_VALUE; private long lastRefreshT...
lastRefreshTimeMS = System.currentTimeMillis(); final String[] fileNamesList = queueDir.list(); String minFilename = INITIAL_MIN_FILENAME; String maxFilename = INITIAL_MAX_FILENAME; if (fileNamesList != null) { for (String fileName : fileNamesList) { ...
365
300
665
<methods>public final void close() ,public boolean isClosed() <variables>private volatile transient boolean closed
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/MicroToucher.java
MicroToucher
bgExecute
class MicroToucher { private final StoreAppender appender; private long lastPageTouched = 0; private volatile long lastPageToSync = 0; private long lastPageSynced = 0; public MicroToucher(StoreAppender appender) { this.appender = appender; } public boolean execute() { final...
final long lastPage = this.lastPageToSync; final long start = this.lastPageSynced; final long length = Math.min(8 << 20, lastPage - start); // System.out.println("len "+length); if (length < 8 << 20) return; final Wire bufferWire = appender.wire(); if...
479
146
625
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/ReferenceCountedCache.java
ReferenceCountedCache
releaseResource
class ReferenceCountedCache<K, T extends ReferenceCounted & Closeable, V, E extends Throwable> extends AbstractCloseable { private final Map<K, T> cache = new LinkedHashMap<>(); private final Function<T, V> transformer; private final ThrowingFunction<K, T, E> creator; private final ReferenceCha...
try { if (value != null) value.release(this); } catch (Exception e) { Jvm.debug().on(getClass(), e); }
732
50
782
<methods>public static void assertCloseablesClosed() ,public final void close() ,public net.openhft.chronicle.core.StackTrace createdHere() ,public static void disableCloseableTracing() ,public static void enableCloseableTracing() ,public static void gcAndWaitForCloseablesToClose() ,public boolean isClosed() ,public bo...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/RollCycleEncodeSequence.java
RollCycleEncodeSequence
getSequence
class RollCycleEncodeSequence implements Sequence { private final TwoLongValue writePositionAndSequence; private final int cycleShift; private final long sequenceMask; RollCycleEncodeSequence(LongValue writePositionAndSequence, int indexCount, int indexSpacing) { this.cycleShift = Math.max(32, ...
if (writePositionAndSequence == null) return Sequence.NOT_FOUND; // We only deal with the 2nd long in the TwoLongValue, and we use it to keep track of current position // and current sequence. We use the same encoding as index (cycle number is shifted left by cycleShift //...
650
279
929
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/SCQMeta.java
SCQMeta
overrideFrom
class SCQMeta implements Metadata { @NotNull private final SCQRoll roll; private final int deltaCheckpointInterval; private int sourceId; @SuppressWarnings("unused") @UsedViaReflection SCQMeta(@NotNull WireIn wire) { this.roll = Objects.requireNonNull(wire.read(MetaDataField.roll).t...
if (!(metadata instanceof SCQMeta)) throw new IllegalStateException("Expected SCQMeta, got " + metadata.getClass()); SCQMeta other = (SCQMeta) metadata; SCQRoll roll = other.roll; if (roll.epoch() != this.roll.epoch()) { Jvm.warn().on(getClass(), "Overriding ro...
436
493
929
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/SCQRoll.java
SCQRoll
toString
class SCQRoll implements Demarshallable, WriteMarshallable { private int length; @Nullable private String format; @Nullable private LocalTime rollTime; @Nullable private ZoneId rollTimeZone; private long epoch; /** * used by {@link Demarshallable} * * @param wire a wi...
return "SCQRoll{" + "length=" + length + ", format='" + format + '\'' + ", epoch=" + epoch + ", rollTime=" + rollTime + ", rollTimeZone=" + rollTimeZone + '}';
843
72
915
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/TableDirectoryListing.java
TableDirectoryListing
refresh
class TableDirectoryListing extends AbstractCloseable implements DirectoryListing { private static final String HIGHEST_CREATED_CYCLE = "listing.highestCycle"; private static final String LOWEST_CREATED_CYCLE = "listing.lowestCycle"; private static final String MOD_COUNT = "listing.modCount"; static fi...
if (!force) { return; } lastRefreshTimeMS = System.currentTimeMillis(); final long currentMin0 = minCycleValue.getVolatileValue(); final long currentMax0 = maxCycleValue.getVolatileValue(); while (true) { throwExceptionIfClosed(); ...
1,006
496
1,502
<methods>public static void assertCloseablesClosed() ,public final void close() ,public net.openhft.chronicle.core.StackTrace createdHere() ,public static void disableCloseableTracing() ,public static void enableCloseableTracing() ,public static void gcAndWaitForCloseablesToClose() ,public boolean isClosed() ,public bo...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/TableDirectoryListingReadOnly.java
TableDirectoryListingReadOnly
init
class TableDirectoryListingReadOnly extends TableDirectoryListing { TableDirectoryListingReadOnly(final @NotNull TableStore<?> tableStore) { super(tableStore, null, null); } @Override protected void checkReadOnly(@NotNull TableStore<?> tableStore) { // no-op } @Override pu...
throwExceptionIfClosedInSetter(); // it is possible if r/o queue created at same time as r/w queue for longValues to be only half-written final long timeoutMillis = System.currentTimeMillis() + 500; while (true) { try { initLongValues(); brea...
192
131
323
<methods>public int getMaxCreatedCycle() ,public int getMinCreatedCycle() ,public void init() ,public long lastRefreshTimeMS() ,public long modCount() ,public void onFileCreated(java.io.File, int) ,public void onRoll(int) ,public void refresh(boolean) ,public java.lang.String toString() <variables>private static final ...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/TableStoreWriteLock.java
TableStoreWriteLock
lockAssertPostConditions
class TableStoreWriteLock extends AbstractTSQueueLock implements WriteLock { public static final String APPEND_LOCK_KEY = "chronicle.append.lock"; private static final String LOCK_KEY = "chronicle.write.lock"; private final long timeout; private Thread lockedByThread = null; private StackTrace locke...
//noinspection ConstantConditions,AssertWithSideEffects assert SKIP_ASSERTIONS || ((lockedByThread = Thread.currentThread()) != null && (lockedHere = new StackTrace()) != null);
1,351
58
1,409
<methods>public void <init>(java.lang.String, TableStore<?>, Supplier<net.openhft.chronicle.threads.TimingPauser>) ,public boolean forceUnlockIfProcessIsDead() ,public boolean isLockedByCurrentProcess(java.util.function.LongConsumer) ,public long lockedBy() ,public java.lang.String toString() <variables>protected stati...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/ThreadLocalAppender.java
ThreadLocalAppender
acquireThreadLocalAppender
class ThreadLocalAppender { private ThreadLocalAppender() { // Intentional no-op } /** * Returns a ExcerptAppender for the given ChronicleQueue that is local to the current Thread. * <p> * An Appender can be used to store new excerpts sequentially to the queue. * <p> * <b>...
if (!(queue instanceof SingleChronicleQueue)) { throw new IllegalArgumentException("acquireThreadLocalAppender only accepts instances of SingleChronicleQueue"); } SingleChronicleQueue singleChronicleQueue = (SingleChronicleQueue) queue; return singleChronicleQueue.acquireThr...
317
87
404
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/single/namedtailer/IndexUpdaterFactory.java
IndexUpdaterFactory
createIndexUpdater
class IndexUpdaterFactory { /** * Create an instance of an {@link IndexUpdater} depending on the values provided. */ @Nullable public static IndexUpdater createIndexUpdater(@Nullable String tailerName, @NotNull SingleChronicleQueue queue) {<FILL_FUNCTION_BODY>} /** * An index updater th...
if (tailerName == null) { // A null index updater is used when a plain (unnamed) tailer is in use // Note this nullness is not ideal and needs to be tackled in a future refactor of StoreTailer return null; } else if (tailerName.startsWith(SingleChronicleQueue.REPLICA...
570
215
785
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/table/AbstractTSQueueLock.java
AbstractTSQueueLock
forceUnlockIfProcessIsDead
class AbstractTSQueueLock extends AbstractCloseable implements Closeable { protected static final String UNLOCK_MAIN_MSG = ". You can manually unlock with net.openhft.chronicle.queue.main.UnlockMain"; protected static final String UNLOCKING_FORCIBLY_MSG = ". Unlocking forcibly. Note that this feature is designe...
long pid; for (; ; ) { pid = this.lock.getVolatileValue(); if (pid == UNLOCKED) return true; // mask off thread (if used) int realPid = (int) pid; if (!Jvm.isProcessAlive(realPid)) { Jvm.warn().on(this.getClass...
1,012
283
1,295
<methods>public static void assertCloseablesClosed() ,public final void close() ,public net.openhft.chronicle.core.StackTrace createdHere() ,public static void disableCloseableTracing() ,public static void enableCloseableTracing() ,public static void gcAndWaitForCloseablesToClose() ,public boolean isClosed() ,public bo...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/table/ReadonlyTableStore.java
ReadonlyTableStore
bytes
class ReadonlyTableStore<T extends Metadata> extends AbstractCloseable implements TableStore<T> { private final T metadata; public ReadonlyTableStore(T metadata) { this.metadata = metadata; singleThreadedCheckDisabled(true); } @Override public T metadata() { return metadata...
throwExceptionIfClosed(); UnsupportedOperationException read_only = new UnsupportedOperationException("Read only"); throw read_only;
487
38
525
<methods>public static void assertCloseablesClosed() ,public final void close() ,public net.openhft.chronicle.core.StackTrace createdHere() ,public static void disableCloseableTracing() ,public static void enableCloseableTracing() ,public static void gcAndWaitForCloseablesToClose() ,public boolean isClosed() ,public bo...
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/impl/table/SingleTableBuilder.java
SingleTableBuilder
builder
class SingleTableBuilder<T extends Metadata> implements Builder<TableStore<T>> { static { CLASS_ALIASES.addAlias(WireType.class); CLASS_ALIASES.addAlias(SingleTableStore.class, "STStore"); } @NotNull private final File file; @NotNull private final T metadata; private WireT...
if (file.isDirectory()) { throw new IllegalArgumentException("Tables should be configured with the table file, not a directory. Actual file used: " + file.getParentFile()); } if (!file.getName().endsWith(SingleTableStore.SUFFIX)) { throw new IllegalArgumentException("Inv...
1,528
110
1,638
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/domestic/QueueOffsetSpec.java
QueueOffsetSpec
apply
class QueueOffsetSpec { private static final String TOKEN_DELIMITER = ";"; private final Type type; private final String[] spec; private QueueOffsetSpec(final Type type, final String[] spec) { this.type = type; this.spec = spec; } public static QueueOffsetSpec ofEpoch(final lon...
switch (type) { case EPOCH: builder.epoch(Long.parseLong(spec[0])); break; case ROLL_TIME: builder.rollTime(toLocalTime(spec[0]), toZoneId(spec[1])); break; case NONE: break; default:...
951
106
1,057
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/main/InternalBenchmarkMain.java
InternalBenchmarkMain
benchmark
class InternalBenchmarkMain { static volatile boolean running = true; static int throughput = Integer.getInteger("throughput", 250); // MB/s static int runtime = Integer.getInteger("runtime", 300); // seconds static String basePath = System.getProperty("path", OS.TMP); static volatile long readerLoo...
Histogram writeTime = new Histogram(32, 7); Histogram transportTime = new Histogram(32, 7); Histogram readTime = new Histogram(32, 7); String path = basePath + "/test-q-" + messageSize; ChronicleQueue queue = createQueue(path); // Pretoucher will only work with Queue E...
933
1,060
1,993
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/main/InternalDumpMain.java
InternalDumpMain
dump
class InternalDumpMain { private static final String FILE = System.getProperty("file"); private static final boolean SKIP_TABLE_STORE = Jvm.getBoolean("skipTableStoreDump"); private static final boolean UNALIGNED = Jvm.getBoolean("dumpUnaligned"); private static final int LENGTH = ", 0".length(); s...
if (path.isDirectory()) { final FilenameFilter filter = SKIP_TABLE_STORE ? (d, n) -> n.endsWith(SingleChronicleQueue.SUFFIX) : (d, n) -> n.endsWith(SingleChronicleQueue.SUFFIX) || n.endsWith(SingleTableStore.SUFFIX); ...
740
243
983
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/main/InternalPingPongMain.java
InternalPingPongMain
pingPong
class InternalPingPongMain { // static int throughput = Integer.getInteger("throughput", 250); // MB/s static int runtime = Integer.getInteger("runtime", 30); // seconds static String basePath = System.getProperty("path", OS.TMP); static AtomicLong writeTime = new AtomicLong(); static AtomicInteg...
String path = InternalPingPongMain.basePath + "/test-q-" + Time.uniqueId(); Histogram readDelay = new Histogram(); Histogram readDelay2 = new Histogram(); try (ChronicleQueue queue = createQueue(path)) { Thread reader = new Thread(() -> { ExcerptTailer taile...
296
589
885
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/main/InternalRemovableRollFileCandidatesMain.java
InternalRemovableRollFileCandidatesMain
main
class InternalRemovableRollFileCandidatesMain { /** * Produces a list of removable roll file candidates and prints * their absolute path to standard out row-by-row. * * @param args the directory. If no directory is given, "." is assumed */ public static void main(String[] args) {<FILL_F...
final File dir; if (args.length == 0) { dir = new File("."); } else { dir = new File(args[0]); } FileUtil.removableRollFileCandidates(dir) .map(File::getAbsolutePath) .forEach(System.out::println);
98
87
185
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/main/InternalUnlockMain.java
InternalUnlockMain
unlock
class InternalUnlockMain { static { SingleChronicleQueueBuilder.addAliases(); } public static void main(String[] args) { unlock(args[0]); } private static void unlock(@NotNull String dir) {<FILL_FUNCTION_BODY>} }
File path = new File(dir); if (!path.isDirectory()) { System.err.println("Path argument must be a queue directory"); System.exit(1); } File storeFilePath = new File(path, QUEUE_METADATA_FILE); if (!storeFilePath.exists()) { System.err.printl...
78
245
323
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/InternalDummyMethodReaderQueueEntryHandler.java
InternalDummyMethodReaderQueueEntryHandler
accept
class InternalDummyMethodReaderQueueEntryHandler implements QueueEntryHandler { private final Bytes<?> textConversionTarget = Bytes.allocateElasticOnHeap(); private final WireType wireType; public InternalDummyMethodReaderQueueEntryHandler(@NotNull WireType wireType) { this.wireType = requireNonNul...
long elementCount = 0; while (wireIn.hasMore()) { new BinaryWire(wireIn.bytes()).copyOne(wireType.apply(textConversionTarget)); elementCount++; if ((elementCount & 1) == 0) { messageHandler.accept(textConversionTarget.toString()); tex...
156
98
254
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/InternalMessageToTextQueueEntryHandler.java
InternalMessageToTextQueueEntryHandler
accept
class InternalMessageToTextQueueEntryHandler implements QueueEntryHandler { private final Bytes<?> textConversionTarget = Bytes.allocateElasticOnHeap(); private final WireType wireType; public InternalMessageToTextQueueEntryHandler(WireType wireType) { this.wireType = requireNonNull(wireType); ...
final Bytes<?> serialisedMessage = wireIn.bytes(); final byte dataFormatIndicator = serialisedMessage.readByte(serialisedMessage.readPosition()); String text; if (isBinaryFormat(dataFormatIndicator)) { textConversionTarget.clear(); final BinaryWire binaryWire = ...
186
153
339
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/MessageCountingMessageConsumer.java
MessageCountingMessageConsumer
consume
class MessageCountingMessageConsumer implements MessageConsumer { private final long matchLimit; private final MessageConsumer wrappedConsumer; private long matches = 0; /** * Constructor * * @param matchLimit The limit used to determine {@link #matchLimitReached()} * @param wr...
final boolean consume = wrappedConsumer.consume(index, message); if (consume) { matches++; } return consume;
190
40
230
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/PatternFilterMessageConsumer.java
PatternFilterMessageConsumer
consume
class PatternFilterMessageConsumer implements MessageConsumer { private final List<Pattern> patterns; private final boolean shouldBePresent; private final MessageConsumer nextMessageConsumer; /** * Constructor * * @param patterns The list of patterns to match against * @...
for (Pattern pattern : patterns) { if (shouldBePresent != pattern.matcher(message).find()) { return false; } } return nextMessageConsumer.consume(index, message);
219
57
276
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/queueentryreaders/AbstractTailerPollingQueueEntryReader.java
AbstractTailerPollingQueueEntryReader
read
class AbstractTailerPollingQueueEntryReader implements QueueEntryReader { private final ExcerptTailer tailer; private final Function<ExcerptTailer, DocumentContext> pollMethod; protected AbstractTailerPollingQueueEntryReader(ExcerptTailer tailer, Function<ExcerptTailer, DocumentContext> pollMethod) { ...
try (DocumentContext dc = pollMethod.apply(tailer)) { if (!dc.isPresent()) { return false; } doRead(dc); return true; }
154
54
208
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/queueentryreaders/MethodReaderQueueEntryReader.java
MethodReaderQueueEntryReader
read
class MethodReaderQueueEntryReader implements QueueEntryReader { private final ExcerptTailer tailer; private final MessageConsumer messageConsumer; private final MethodReader methodReader; private final Bytes<ByteBuffer> bytes; public MethodReaderQueueEntryReader(ExcerptTailer tailer, MessageConsu...
if (!methodReader.readOne()) { return false; } messageConsumer.consume(tailer.lastReadIndex(), bytes.toString()); bytes.clear(); return true;
354
52
406
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/reader/queueentryreaders/VanillaQueueEntryReader.java
VanillaQueueEntryReader
read
class VanillaQueueEntryReader implements QueueEntryReader { private final ExcerptTailer tailer; private final Function<ExcerptTailer, DocumentContext> pollMethod; private final QueueEntryHandler messageConverter; private final MessageConsumer messageConsumer; public VanillaQueueEntryReader(@NotNul...
try (DocumentContext dc = pollMethod.apply(tailer)) { if (!dc.isPresent()) { return false; } messageConverter.accept(dc.wire(), val -> messageConsumer.consume(dc.index(), val)); return true; }
192
74
266
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/util/InternalFileUtil.java
ProcFdWalker
visitFile
class ProcFdWalker extends SimpleFileVisitor<Path> { private final Set<String> openFiles = new HashSet<>(); @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {<FILL_FUNCTION_BODY>} @Override public FileVisitResult visitFileFailed(Path file, IOExc...
if (file.toAbsolutePath().toString().matches("/proc/\\d+/fd/\\d+")) { try { final String e = file.toRealPath().toAbsolutePath().toString(); openFiles.add(e); } catch (NoSuchFileException | AccessDeniedException e) { ...
289
153
442
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/writer/ChronicleWriter.java
ChronicleWriter
asMethodWriter
class ChronicleWriter { private Path basePath; private String methodName; private List<String> files; private Class<?> writeTo; public void execute() throws IOException { try (final ChronicleQueue queue = ChronicleQueue.singleBuilder(this.basePath).build(); final ExcerptAppende...
try { this.writeTo = Class.forName(interfaceName); } catch (ClassNotFoundException e) { throw Jvm.rethrow(e); } return this;
474
52
526
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/internal/writer/ChronicleWriterMain.java
ChronicleWriterMain
printHelpAndExit
class ChronicleWriterMain { public void run(@NotNull String[] args) throws Exception { final Options options = options(); final CommandLine commandLine = parseCommandLine(args, options); final ChronicleWriter writer = new ChronicleWriter(); configure(writer, commandLine); ...
final PrintWriter writer = new PrintWriter(System.out); new HelpFormatter().printHelp( writer, 180, this.getClass().getSimpleName() + " files..", message, options, HelpFormatter.DEFAULT_LEFT_PAD, ...
510
114
624
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/rollcycles/RollCycleArithmetic.java
RollCycleArithmetic
toIndex
class RollCycleArithmetic { /** * Sunday 1970 Jan 4th 00:00:00 UTC */ public static final int SUNDAY_00_00 = 259_200_000; private final int cycleShift; private final int indexCount; private final int indexSpacing; private final long sequenceMask; public static RollCycleArithmetic ...
return ((long) cycle << cycleShift) + (sequenceNumber & sequenceMask);
463
22
485
<no_super_class>
OpenHFT_Chronicle-Queue
Chronicle-Queue/src/main/java/net/openhft/chronicle/queue/util/ToolsUtil.java
ToolsUtil
warnIfResourceTracing
class ToolsUtil { private ToolsUtil() { } /** * When running tools e.g. ChronicleReader, from the CQ source dir, resource tracing may be turned on */ public static void warnIfResourceTracing() {<FILL_FUNCTION_BODY>} }
// System.err (*not* logger as slf4j may not be set up e.g. when running queue_reader.sh) if (Jvm.isResourceTracing()) System.err.println("Resource tracing is turned on - this will eventually die with OOME");
77
70
147
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/ActionEnter.java
ActionEnter
getStartIndex
class ActionEnter { private HttpServletRequest request = null; private String rootPath = null; private String contextPath = null; private String actionType = null; private ConfigManager configManager = null; public ActionEnter ( HttpServletRequest request, String rootPath, String userId) { this.request = ...
String start = this.request.getParameter( "start" ); try { return Integer.parseInt( start ); } catch ( Exception e ) { return 0; }
816
55
871
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/Encoder.java
Encoder
toUnicode
class Encoder { public static String toUnicode ( String input ) {<FILL_FUNCTION_BODY>} }
StringBuilder builder = new StringBuilder(); char[] chars = input.toCharArray(); for ( char ch : chars ) { if ( ch < 256 ) { builder.append( ch ); } else { builder.append( "\\u" + Integer.toHexString( ch& 0xffff ) ); } } return builder.toString();
34
115
149
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/PathFormat.java
PathFormat
parse
class PathFormat { private static final String TIME = "time"; private static final String FULL_YEAR = "yyyy"; private static final String YEAR = "yy"; private static final String MONTH = "mm"; private static final String DAY = "dd"; private static final String HOUR = "hh"; private static final String MINUTE = ...
Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE ); Matcher matcher = pattern.matcher(input); PathFormat.currentDate = new Date(); StringBuffer sb = new StringBuffer(); while ( matcher.find() ) { matcher.appendReplacement(sb, PathFormat.getString( matcher.gro...
1,184
151
1,335
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/define/BaseState.java
BaseState
toString
class BaseState implements State { private boolean state = false; private String info = null; private Map<String, String> infoMap = new HashMap<String, String>(); public BaseState () { this.state = true; } public BaseState ( boolean state ) { this.setState( state ); } public BaseState ( boolean state, ...
String key = null; String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info; StringBuilder builder = new StringBuilder(); builder.append( "{\"state\": \"" + stateVal + "\"" ); Iterator<String> iterator = this.infoMap.keySet().iterator(); while ( iterator.hasNext() ) { ...
457
186
643
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/define/MultiState.java
MultiState
toJSONString
class MultiState implements State { private boolean state = false; private String info = null; private Map<String, Long> intMap = new HashMap<String, Long>(); private Map<String, String> infoMap = new HashMap<String, String>(); private List<String> stateList = new ArrayList<String>(); public MultiState ( boole...
String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info; StringBuilder builder = new StringBuilder(); builder.append( "{\"state\": \"" + stateVal + "\"" ); // 数字转换 Iterator<String> iterator = this.intMap.keySet().iterator(); while ( iterator.hasNext() ) { ...
327
387
714
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/hunter/FileManager.java
FileManager
getAllowFiles
class FileManager { private String dir = null; private String rootPath = null; private String[] allowFiles = null; private int count = 0; public FileManager ( Map<String, Object> conf ) { this.rootPath = (String)conf.get( "rootPath" ); this.dir = this.rootPath + (String)conf.get( "dir" ); this.allowFiles...
String[] exts = null; String ext = null; if ( fileExt == null ) { return new String[ 0 ]; } exts = (String[])fileExt; for ( int i = 0, len = exts.length; i < len; i++ ) { ext = exts[ i ]; exts[ i ] = ext.replace( ".", "" ); } return exts;
612
130
742
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java
ImageHunter
captureRemoteData
class ImageHunter { private String filename = null; private String savePath = null; private String rootPath = null; private List<String> allowTypes = null; private long maxSize = -1; private List<String> filters = null; public ImageHunter ( Map<String, Object> conf ) { this.filename = (String)conf.get(...
HttpURLConnection connection = null; URL url = null; String suffix = null; try { url = new URL( urlStr ); if ( !validHost( url.getHost() ) ) { return new BaseState( false, AppInfo.PREVENT_HOST ); } connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFol...
534
428
962
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java
Base64Uploader
save
class Base64Uploader { public static State save(String content, Map<String, Object> conf) {<FILL_FUNCTION_BODY>} private static byte[] decode(String content) { return Base64.decodeBase64(content); } private static boolean validSize(byte[] data, long length) { return data.length <= length; } }
byte[] data = decode(content); long maxSize = ((Long) conf.get("maxSize")).longValue(); if (!validSize(data, maxSize)) { return new BaseState(false, AppInfo.MAX_SIZE); } String suffix = FileType.getSuffix("JPG"); String savePath = PathFormat.parse((String) conf.get("savePath"), (String) conf....
99
241
340
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java
BinaryUploader
save
class BinaryUploader { public static final State save(HttpServletRequest request, Map<String, Object> conf) {<FILL_FUNCTION_BODY>} private static boolean validType(String type, String[] allowTypes) { List<String> list = Arrays.asList(allowTypes); return list.contains(type); } }
FileItemStream fileStream = null; boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null; if (!ServletFileUpload.isMultipartContent(request)) { return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT); } ServletFileUpload upload = new ServletFileUpload( new DiskFileItemFactory()); ...
93
612
705
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/upload/StorageManager.java
StorageManager
saveTmpFile
class StorageManager { public static final int BUFFER_SIZE = 8192; public StorageManager() { } public static State saveBinaryFile(byte[] data, String path) { if(!FileMagicUtils.isUserUpFileType(data,path.substring(path.lastIndexOf(".")))){ return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE); } Fil...
State state = null; File targetFile = new File(path); if (targetFile.canWrite()) { return new BaseState(false, AppInfo.PERMISSION_DENIED); } try { FileUtils.moveFile(tmpFile, targetFile); } catch (IOException e) { e.printStackTrace(); return new BaseState(false, AppInfo.IO_ERROR); } state...
1,155
168
1,323
<no_super_class>
wkeyuan_DWSurvey
DWSurvey/src/main/java/com/baidu/ueditor/upload/Uploader.java
Uploader
doExec
class Uploader { private HttpServletRequest request = null; private Map<String, Object> conf = null; public Uploader(HttpServletRequest request, Map<String, Object> conf) { this.request = request; this.conf = conf; } public final State doExec() {<FILL_FUNCTION_BODY>} }
String filedName = (String) this.conf.get("fieldName"); State state = null; if ("true".equals(this.conf.get("isBase64"))) { state = Base64Uploader.save(this.request.getParameter(filedName), this.conf); } else { state = BinaryUploader.save(this.request, this.conf); } return state;
89
113
202
<no_super_class>