private CharsToNameCanonicalizer makeOrphan(int seed) { return new CharsToNameCanonicalizer(null, true, true, _symbols, _buckets, _size, seed, _longestCollisionList); }
int index = _hashToIndex(h); String sym = _symbols[index]; copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _longestCollisionList = Math.max(newB.length(), _longestCollisionList); if (_longestCollisionList > MAX_COLL_CHAIN_LENGTH) { reportTooManyCollisions(MAX_COLL_CHAIN_LENGTH);
protected final String _parseApostropheFieldName() throws IOException, JsonParseException { // Note: mostly copy of_parseFieldName int ptr = _inputPtr; int hash = 0; final int inputLen = _inputEnd; if (ptr < inputLen) { final int[] codes = CharTypes.getInputCodeLatin1(); final int maxCode = codes.length; do { int ch = _inputBuffer[ptr]; if (ch == '\'') { int start = _inputPtr; _inputPtr = ptr+1; // to skip the quote return _symbols.findSymbol(_inputBuffer, start, ptr - start, hash); } if (ch < maxCode && codes[ch] != 0) { break; } hash = (hash * 31) + ch; ++ptr; } while (ptr < inputLen); } int start = _inputPtr; _inputPtr = ptr; return _parseFieldName2(start, hash, INT_APOSTROPHE); }
public void release() { // If nothing has been added, nothing to do if (!maybeDirty()) { return; } if (_parent != null) { _parent.mergeChild(this); /* Let's also mark this instance as dirty, so that just in * case release was too early, there's no corruption * of possibly shared data. */ _dirty = false; } }
if (child.size() > MAX_ENTRIES_FOR_REUSE || child._longestCollisionList > MAX_COLL_CHAIN_FOR_REUSE) { initTables(DEFAULT_TABLE_SIZE); if (child.size() <= size()) { // nothing to add return;
copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); hash = calcHash(buffer, start, len) & _indexMask;
/** * Overridable factory method that actually instantiates parser * using given {@link Reader} object for reading content. *<p> * This method is specifically designed to remain * compatible between minor versions so that sub-classes can count * on it being called as expected. That is, it is part of official * interface from sub-class perspective, although not a public * method available to users of factory implementations. */ protected JsonParser _createJsonParser(Reader r, IOContext ctxt) throws IOException, JsonParseException { return new ReaderBasedParser(ctxt, _parserFeatures, r, _objectCodec, _rootCharSymbols.makeChild(isEnabled(JsonParser.Feature.CANONICALIZE_FIELD_NAMES), isEnabled(JsonParser.Feature.INTERN_FIELD_NAMES))); }
_sizeThreshold = _thresholdSize(newSize); if (symbol != null) { ++count; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol; ++count; String symbol = b.getSymbol(); int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol;
protected static CharsToNameCanonicalizer createRoot(int hashSeed) { return sBootstrapSymbolTable.makeOrphan(hashSeed); }
/** * Main method for constructing a master symbol table instance. * * @param initialSize Minimum initial size for bucket array; internally * will always use a power of two equal to or bigger than this value. */ private CharsToNameCanonicalizer() { // these settings don't really matter for the bootstrap instance _canonicalize = true; _intern = true; // And we'll also set flags so no copying of buckets is needed: _dirty = true; _hashSeed = 0; _longestCollisionList = 0; initTables(DEFAULT_TABLE_SIZE); }
copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); hash = calcHash(buffer, start, len) & _indexMask;
public void release() { // If nothing has been added, nothing to do if (!maybeDirty()) { return; } if (_parent != null) { _parent.mergeChild(this); /* Let's also mark this instance as dirty, so that just in * case release was too early, there's no corruption * of possibly shared data. */ _dirty = false; } }
if (child.size() > MAX_ENTRIES_FOR_REUSE || child._longestCollisionList > MAX_COLL_CHAIN_FOR_REUSE) { initTables(DEFAULT_TABLE_SIZE); if (child.size() <= size()) { // nothing to add return;
public JsonParser constructParser(int features, ObjectCodec codec, BytesToNameCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols) throws IOException, JsonParseException { JsonEncoding enc = detectEncoding(); // As per [JACKSON-259], may want to fully disable canonicalization: boolean canonicalize = JsonParser.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(features); boolean intern = JsonParser.Feature.INTERN_FIELD_NAMES.enabledIn(features); if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performance; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) */ if (canonicalize) { BytesToNameCanonicalizer can = rootByteSymbols.makeChild(canonicalize, intern); return new Utf8StreamParser(_context, features, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedParser(_context, features, constructReader(), codec, rootCharSymbols.makeChild(canonicalize, intern)); }
_sizeThreshold = _thresholdSize(newSize); if (symbol != null) { ++count; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol; ++count; String symbol = b.getSymbol(); int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol;
protected static CharsToNameCanonicalizer createRoot(int hashSeed) { return sBootstrapSymbolTable.makeOrphan(hashSeed); }
/** * Main method for constructing a master symbol table instance. * * @param initialSize Minimum initial size for bucket array; internally * will always use a power of two equal to or bigger than this value. */ private CharsToNameCanonicalizer() { // these settings don't really matter for the bootstrap instance _canonicalize = true; _intern = true; // And we'll also set flags so no copying of buckets is needed: _dirty = true; _hashSeed = 0; _longestCollisionList = 0; initTables(DEFAULT_TABLE_SIZE); }
int index = _hashToIndex(h); String sym = _symbols[index]; copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _longestCollisionList = Math.max(newB.length(), _longestCollisionList); if (_longestCollisionList > MAX_COLL_CHAIN_LENGTH) { reportTooManyCollisions(MAX_COLL_CHAIN_LENGTH);