atris commented on code in PR #8636: URL: https://github.com/apache/pinot/pull/8636#discussion_r867751836
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/invertedindex/NativeMutableTextIndex.java: ########## @@ -0,0 +1,121 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.pinot.segment.local.realtime.impl.invertedindex; + +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +import org.apache.pinot.segment.local.segment.creator.impl.text.LuceneTextIndexCreator; +import org.apache.pinot.segment.local.utils.nativefst.mutablefst.MutableFST; +import org.apache.pinot.segment.local.utils.nativefst.mutablefst.MutableFSTImpl; +import org.apache.pinot.segment.local.utils.nativefst.utils.RealTimeRegexpMatcher; +import org.apache.pinot.segment.spi.index.mutable.MutableTextIndex; +import org.roaringbitmap.buffer.ImmutableRoaringBitmap; +import org.roaringbitmap.buffer.MutableRoaringBitmap; + + +public class NativeMutableTextIndex implements MutableTextIndex { + private final String _column; + private final MutableFST _mutableFST; + private final RealtimeInvertedIndex _invertedIndex; + //TODO: Move to mutable dictionary + private final Object2IntOpenHashMap<String> _termToDictIdMapping; + private final ReentrantReadWriteLock.ReadLock _readLock; + private final ReentrantReadWriteLock.WriteLock _writeLock; + + private int _nextDocId = 0; + private int _nextDictId = 0; + + public NativeMutableTextIndex(String column) { + _column = column; + _mutableFST = new MutableFSTImpl(); + _termToDictIdMapping = new Object2IntOpenHashMap<>(); + _invertedIndex = new RealtimeInvertedIndex(); + + ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); + _readLock = readWriteLock.readLock(); + _writeLock = readWriteLock.writeLock(); + } + + @Override + public void add(String document) { + List<String> tokens; + try { + tokens = analyze(document, new StandardAnalyzer(LuceneTextIndexCreator.ENGLISH_STOP_WORDS_SET)); Review Comment: I dont think so -- since StandardAnalyzer uses a parser that is JavaCC based. I tried the same and ran into issues. However, the snippet @kkrugler shared above has legs. I reused the same (refactored it a bit) and it gives the required results. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
