/// <summary>Constructor used when creating a child instance</summary> private ByteQuadsCanonicalizer(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer parent, bool intern, int seed, bool failOnDoS, com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer.TableInfo state) { _parent = parent; _seed = seed; _intern = intern; _failOnDoS = failOnDoS; _tableInfo = null; // not used by child tables // Then copy shared state _count = state.count; _hashSize = state.size; _secondaryStart = _hashSize << 2; // right after primary area _tertiaryStart = _secondaryStart + (_secondaryStart >> 1); // right after secondary _tertiaryShift = state.tertiaryShift; _hashArea = state.mainHash; _names = state.names; _spilloverEnd = state.spilloverEnd; _longNameOffset = state.longNameOffset; // and then set other state to reflect sharing status _needRehash = false; _hashShared = true; }
public UTF8StreamJsonParser(com.fasterxml.jackson.core.io.IOContext ctxt, int features , Sharpen.InputStream @in, com.fasterxml.jackson.core.ObjectCodec codec, com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer sym, byte[] inputBuffer, int start, int end, bool bufferRecyclable) : base(ctxt, features) { // This is the main input-code lookup table, fetched eagerly // Latin1 encoding is not supported, but we do use 8-bit subset for // pre-processing task, to simplify first pass, keep it fast. /* /********************************************************** /* Configuration /********************************************************** */ /* /********************************************************** /* Parsing state /********************************************************** */ /* /********************************************************** /* Input buffering (from former 'StreamBasedParserBase') /********************************************************** */ /* /********************************************************** /* Current input data /********************************************************** */ /* /********************************************************** /* Life-cycle /********************************************************** */ _inputStream = @in; _objectCodec = codec; _symbols = sym; _inputBuffer = inputBuffer; _inputPtr = start; _inputEnd = end; _currInputRowStart = start; // If we have offset, need to omit that from byte offset, so: _currInputProcessed = -start; _bufferRecyclable = bufferRecyclable; }
/// <summary> /// Constructor used for creating per-<code>JsonFactory</code> "root" /// symbol tables: ones used for merging and sharing common symbols /// </summary> /// <param name="sz">Initial primary hash area size</param> /// <param name="intern"> /// Whether Strings contained should be /// <see cref="string.Intern()"/> /// ed /// </param> /// <param name="seed"> /// Random seed valued used to make it more difficult to cause /// collisions (used for collision-based DoS attacks). /// </param> private ByteQuadsCanonicalizer(int sz, bool intern, int seed, bool failOnDoS) { // private static final int DEFAULT_T_SIZE = 256; // 64k entries == 2M mem hash area /* /********************************************************** /* Linkage, needed for merging symbol tables /********************************************************** */ /* /********************************************************** /* Configuration /********************************************************** */ /* /********************************************************** /* First, main hash area info /********************************************************** */ /* /********************************************************** /* Then information on collisions etc /********************************************************** */ /* /********************************************************** /* Sharing, versioning /********************************************************** */ // // // Which of the buffers may be shared (and are copy-on-write)? /* /********************************************************** /* Bit of DoS detection goodness /********************************************************** */ /* /********************************************************** /* Life-cycle: constructors /********************************************************** */ _parent = null; _seed = seed; _intern = intern; _failOnDoS = failOnDoS; // Sanity check: let's now allow hash sizes below certain minimum value if (sz < MIN_HASH_SIZE) { sz = MIN_HASH_SIZE; } else { // Also; size must be 2^N; otherwise hash algorithm won't // work... so let's just pad it up, if so if ((sz & (sz - 1)) != 0) { // only true if it's 2^N int curr = MIN_HASH_SIZE; while (curr < sz) { curr += curr; } sz = curr; } } _tableInfo = new java.util.concurrent.atomic.AtomicReference<com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer.TableInfo >(com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer.TableInfo.createInitial( sz)); }