Returns the set of terms. This method will perform a late-decoding of the encoded terms, and will release the
byte array. This method needs to be synchronized as each segment thread will call it concurrently.
491294
protected synchronized NumericTermsSet getTermsSet() {
    if (encodedTerms != null) { // late decoding of the encoded terms
      long start = System.nanoTime();
      termsSet = (NumericTermsSet) TermsSet.readFrom(new BytesRef(encodedTerms));
      logger.debug("{}: Deserialized {} terms - took {} ms", new Object[] { Thread.currentThread().getName(), termsSet.size(), (System.nanoTime() - start) / 1000000 });
      encodedTerms = null; // release reference to the byte array to be able to reclaim memory
    }
    return termsSet;
  }
533405
public static TermsSet newTermsSet(long expectedElements, TermsByQueryRequest.TermsEncoding termsEncoding, CircuitBreaker breaker) {
    switch (termsEncoding) {
      case LONG:
        return new LongTermsSet(expectedElements, breaker);
      case INTEGER:
        return new IntegerTermsSet(expectedElements, breaker);
      case BLOOM:
        return new BloomFilterTermsSet(expectedElements, breaker);
      case BYTES:
        return new BytesRefTermsSet(breaker);
      default:
        throw new IllegalArgumentException("[termsByQuery] Invalid terms encoding: " + termsEncoding.name());
    }
  }
514198
@SuppressWarnings("unchecked")
  private void readNext() {
    // Compute the index of the next entry in the segment.
    final long index = getNextIndex();

    try {
      // Read more bytes from the segment if necessary.
      if (memory.remaining() < maxEntrySize) {
        long position = channel.position() + memory.position();
        channel.position(position);
        memory.clear();
        channel.read(memory);
        channel.position(position);
        memory.flip();
      }

      // Mark the buffer so it can be reset if necessary.
      memory.mark();

      try {
        // Read the length of the entry.
        final int length = memory.getInt();

        // If the buffer length is zero then return.
        if (length <= 0 || length > maxEntrySize) {
          memory.reset().limit(memory.position());
          nextEntry = null;
          return;
        }

        // Read the checksum of the entry.
        long checksum = memory.getInt() & 0xFFFFFFFFL;

        // Compute the checksum for the entry bytes.
        final Checksum crc32 = new CRC32();
        crc32.update(memory.array(), memory.position(), length);

        // If the stored checksum equals the computed checksum, return the entry.
        if (checksum == crc32.getValue()) {
          int limit = memory.limit();
          memory.limit(memory.position() + length);
          E entry = namespace.deserialize(memory);
          memory.limit(limit);
          nextEntry = new Indexed<>(index, entry, length);
        } else {
          memory.reset().limit(memory.position());
          nextEntry = null;
        }
      } catch (BufferUnderflowException e) {
        memory.reset().limit(memory.position());
        nextEntry = null;
      }
    } catch (IOException e) {
      throw new StorageException(e);
    }
  }
1022723
def update_tracking_terms(self):
        
        import codecs
        with codecs.open(self.filename,"r", encoding='utf8') as input:
            # read all the lines
            lines = input.readlines()

            # build a set of terms
            new_terms = set()
            for line in lines:
                line = line.strip()
                if len(line):
                    new_terms.add(line)

            return set(new_terms)
695231
def _output_terms(self):
        
        terms = list(six.itervalues(self._columns))
        screen = self.screen
        if screen is not None:
            terms.append(screen)
        return terms
399859
private int parseKeywords() {
        int oldBlen = buffer.length();
        Map<String, String> m = getKeywordMap();
        if (!m.isEmpty()) {
            boolean first = true;
            for (Map.Entry<String, String> e : m.entrySet()) {
                append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
                first = false;
                append(e.getKey());
                append(KEYWORD_ASSIGN);
                append(e.getValue());
            }
            if (first == false) {
                ++oldBlen;
            }
        }
        return oldBlen;
    }
644212
protected List<String> extractWords() throws IOException
    {
        while( true ) {
            lineNumber++;
            String line = in.readLine();
            if( line == null ) {
                return null;
            }

            // skip comment lines
            if( hasComment ) {
                if( line.charAt(0) == comment )
                    continue;
            }

            // extract the words, which are the variables encoded
            return parseWords(line);
        }
    }
910649
public Set tokens() {
        if (tokenSet == null) {
            tokenSet = new AbstractSetView() {
                public long size() {
                    return inMemoryManagedObjects.size();
                }

                public Iterator iterator() {
                    final java.util.Iterator tokenIterator = inMemoryTokens.values().iterator();
                    return new Iterator() {

                        public boolean hasNext()
                        {
                            return tokenIterator.hasNext();
                        } // hasNext().

                        public Object next()
                        {
                            return tokenIterator.next();
                        } // next().

                        public boolean hasNext(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // hasNext().

                        public Object next(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // next().

                        public Object remove(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // remove().               
                    }; // new Iterator().
                } // iterator().  
            }; // new AbstractSetView().
        } // if (tokenSet == null). 
        return tokenSet;
    }
166669
public String[][] toWordTagArray()
    {
        List<Word> wordList = toSimpleWordList();
        String[][] pair = new String[2][wordList.size()];
        Iterator<Word> iterator = wordList.iterator();
        for (int i = 0; i < pair[0].length; i++)
        {
            Word word = iterator.next();
            pair[0][i] = word.value;
            pair[1][i] = word.label;
        }
        return pair;
    }
427862
public byte[] getEncodedInternal() throws IOException {
        if (encoded == null) {
            DerOutputStream     out = new DerOutputStream();
            DerOutputStream     tmp = new DerOutputStream();
            for (int i = 0; i < names.length; i++) {
                names[i].encode(tmp);
            }
            out.write(DerValue.tag_Sequence, tmp);
            encoded = out.toByteArray();
        }
        return encoded;
    }
814989
def members(self):
        
        if self.serialized:
            return set(map(
                self._loads, self._client.smembers(self.key_prefix)))
        else:
            return set(map(
                self._decode, self._client.smembers(self.key_prefix)))
454050
def readQword(self):
        
        qword = unpack(self.endianness + ('Q' if not self.signed else 'b'),  self.readAt(self.offset, 8))[0]
        self.offset += 8
        return qword
1032628
private List<SequenceState<S, O, D>> retrieveMostLikelySequence() {
        // Otherwise an HMM break would have occurred and message would be null.
        assert !message.isEmpty();

        final S lastState = mostLikelyState();

        // Retrieve most likely state sequence in reverse order
        final List<SequenceState<S, O, D>> result = new ArrayList<>();
        ExtendedState<S, O, D> es = lastExtendedStates.get(lastState);
        while(es != null) {
            final SequenceState<S, O, D> ss = new SequenceState<>(es.state, es.observation,
                    es.transitionDescriptor);
            result.add(ss);
            es = es.backPointer;
        }

        Collections.reverse(result);
        return result;
    }
1156621
public long[] toLongArray() {
    long[] answer = new long[bitmap.limit()];
    bitmap.rewind();
    bitmap.get(answer);
    return answer;
  }
162859
private byte[] toBytes() {
        ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));
        buf.putInt(m_tokenCount);
        int lastToken = Integer.MIN_VALUE;
        for (int ii = 0; ii < m_tokenCount; ii++) {
            final long ptr = m_tokens + (ii * 8);
            final int token = Bits.unsafe.getInt(ptr);
            Preconditions.checkArgument(token >= lastToken);
            lastToken = token;
            final int pid = Bits.unsafe.getInt(ptr + 4);
            buf.putInt(token);
            buf.putInt(pid);
        }
        return buf.array();
    }
549909
private function cacheTermsForContent()
    {
        $term_container = (new TermContainer)->getTable();
        $terms = $this->taxonomies()
            ->select("$term_container.id", "$term_container.vocabulary_id")
            ->get();

        if (!count($terms)) {
            return [];
        }

        $results = [];
        foreach ($terms as $term) {
            $results[$term->vocabulary_id][] = $term->id;
        }

        // a whole week, because it's automatically recached
        Cache::put($this->getTaxonomyCacheKey(), $results, 60 * 24 * 7);

        return $results;
    }
1095612
def decode(self, encoded):
        
        encoded = super().decode(encoded)
        return self.tokenizer.decode([self.itos[index] for index in encoded])