/** * Factory method that should only be called from unit tests, where seed * value should remain the same. */ protected static BytesToNameCanonicalizer createRoot(int seed) { return new BytesToNameCanonicalizer(DEFAULT_T_SIZE, true, seed, true); }
public Name addName(String name, int q1, int q2) { if (_intern) { name = InternCache.instance.intern(name); } int hash = (q2 == 0) ? calcHash(q1) : calcHash(q1, q2); Name symbol = constructName(hash, name, q1, q2); _addSymbol(hash, symbol); return symbol; }
private void _addSymbol(int hash, Name symbol) unshareMain(); rehash(); _mainHash[ix] = (hash << 8); if (_mainNamesShared) { unshareNames(); unshareCollision(); // also allocates if list was null expandCollision(); bucket = findBestBucket();
nukeSymbols(); return; expandCollision(); bucket = findBestBucket();
private Name findName(int q1, int lastQuadBytes) throws JsonParseException { // Usually we'll find it from the canonical symbol table already Name name = _symbols.findName(q1); if (name != null) { return name; } // If not, more work. We'll need add stuff to buffer _quadBuffer[0] = q1; return addName(_quadBuffer, 1, lastQuadBytes); }
return BytesToNameCanonicalizer.getEmptyName(); Name name = _symbols.findName(quads, qlen); if (name == null) { name = addName(quads, qlen, currQuadBytes);
/** * Method called when not even first 8 bytes are guaranteed * to come consecutively. Happens rarely, so this is off-lined; * plus we'll also do full checks for escaping etc. */ protected Name slowParseName() throws IOException { if (_inputPtr >= _inputEnd) { if (!loadMore()) { _reportInvalidEOF(": was expecting closing '\"' for name"); } } int i = _inputBuffer[_inputPtr++] & 0xFF; if (i == INT_QUOTE) { // special case, "" return BytesToNameCanonicalizer.getEmptyName(); } return parseEscapedName(_quadBuffer, 0, 0, i, 0); }
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, BytesToNameCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, boolean canonicalize, boolean intern) throws IOException, JsonParseException { JsonEncoding enc = detectEncoding(); 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 UTF8StreamJsonParser(_context, parserFeatures, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(_context, parserFeatures, constructReader(), codec, rootCharSymbols.makeChild(canonicalize, intern)); }
quads[qlen-1] = lastQuad; return _symbols.addName(baseName, quads, qlen);
nukeSymbols(); return; expandCollision(); bucket = findBestBucket();
private final Name findName(int q1, int q2, int lastQuadBytes) throws JsonParseException { // Usually we'll find it from the canonical symbol table already Name name = _symbols.findName(q1, q2); if (name != null) { return name; } // If not, more work. We'll need add stuff to buffer _quadBuffer[0] = q1; _quadBuffer[1] = q2; return addName(_quadBuffer, 2, lastQuadBytes); }
return BytesToNameCanonicalizer.getEmptyName(); Name name = _symbols.findName(quads, qlen); if (name == null) { name = addName(quads, qlen, currQuadBytes);
/** * Method called when not even first 8 bytes are guaranteed * to come consequtively. Happens rarely, so this is offlined; * plus we'll also do full checks for escaping etc. */ protected Name slowParseFieldName() throws IOException, JsonParseException { if (_inputPtr >= _inputEnd) { if (!loadMore()) { _reportInvalidEOF(": was expecting closing '\"' for name"); } } int i = _inputBuffer[_inputPtr++] & 0xFF; if (i == INT_QUOTE) { // special case, "" return BytesToNameCanonicalizer.getEmptyName(); } return parseEscapedFieldName(_quadBuffer, 0, 0, i, 0); }
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, BytesToNameCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, boolean canonicalize, boolean intern) throws IOException, JsonParseException { JsonEncoding enc = detectEncoding(); 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 UTF8StreamJsonParser(_context, parserFeatures, _in, codec, can, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable); } } return new ReaderBasedJsonParser(_context, parserFeatures, constructReader(), codec, rootCharSymbols.makeChild(canonicalize, intern)); }
quads[qlen-1] = lastQuad; return _symbols.addName(baseName, quads, qlen);
private void _addSymbol(int hash, Name symbol) unshareMain(); rehash(); _hash[ix] = (hash << 8); if (_namesShared) { unshareNames(); unshareCollision(); // also allocates if list was null expandCollision(); bucket = findBestBucket(); _handleSpillOverflow(bucket, newB); } else { _collList[bucket] = newB;