Exemplo n.º 1
0
 @Override
 protected void indexDelete(final int pre, final int size) {
   final boolean textI = meta.textindex, attrI = meta.attrindex;
   if (textI || attrI) {
     // collect all keys and ids
     indexBegin();
     final int l = pre + size;
     for (int p = pre; p < l; ++p) {
       final int k = kind(p);
       // consider nodes which are attribute, text, comment, or proc. instruction
       final boolean text = k == TEXT || k == COMM || k == PI;
       if (textI && text || attrI && k == ATTR) {
         final byte[] key = text(p, text);
         if (key.length <= meta.maxlen) {
           final TokenObjMap<IntList> m = text ? txtBuffer : atvBuffer;
           IntList ids = m.get(key);
           if (ids == null) {
             ids = new IntList(1);
             m.put(key, ids);
           }
           ids.add(id(p));
         }
       }
     }
     indexDelete();
   }
 }
Exemplo n.º 2
0
  @Override
  protected long index(final int pre, final int id, final byte[] value, final int kind) {
    final DataAccess store;
    final TokenObjMap<IntList> map;
    if (kind == ATTR) {
      store = values;
      map = meta.attrindex ? atvBuffer : null;
    } else {
      store = texts;
      // don't index document names
      map = meta.textindex && kind != DOC ? txtBuffer : null;
    }

    // add text to map to index later
    if (meta.updindex && map != null && value.length <= meta.maxlen) {
      IntList ids = map.get(value);
      if (ids == null) {
        ids = new IntList(1);
        map.put(value, ids);
      }
      ids.add(id);
    }

    // add text to text file
    // inline integer value...
    final long v = toSimpleInt(value);
    if (v != Integer.MIN_VALUE) return v | IO.OFFNUM;

    // store text
    final long off = store.length();
    final byte[] val = COMP.get().pack(value);
    store.writeToken(off, val);
    return val == value ? off : off | IO.OFFCOMP;
  }
Exemplo n.º 3
0
 /**
  * Returns a node for the specified term.
  *
  * @param term term
  * @return node
  */
 private ThesNode node(final byte[] term) {
   ThesNode node = nodes.get(term);
   if (node == null) {
     node = new ThesNode();
     node.term = term;
     nodes.put(term, node);
   }
   return node;
 }
Exemplo n.º 4
0
 /**
  * Returns a value for the specified parameter or {@code null}.
  *
  * @param doc documentation
  * @param name parameter name
  * @return documentation of specified variable
  */
 public static byte[] doc(final TokenObjMap<TokenList> doc, final byte[] name) {
   final TokenList params = doc != null ? doc.get(DOC_PARAM) : null;
   if (params != null) {
     for (final byte[] param : params) {
       final int vl = param.length;
       final int s = startsWith(param, '$') ? 1 : 0;
       for (int v = s; v < vl; v++) {
         if (!ws(param[v])) continue;
         if (!eq(substring(param, s, v), name)) break;
         return trim(substring(param, v + 1, vl));
       }
     }
   }
   return null;
 }
Exemplo n.º 5
0
 /**
  * Finds a thesaurus term.
  *
  * @param ii input info
  * @param list result list
  * @param token token
  * @throws QueryException query exception
  */
 void find(final InputInfo ii, final TokenList list, final byte[] token) throws QueryException {
   if (nodes.isEmpty()) init(ii);
   find(list, nodes.get(token), 1);
 }
Exemplo n.º 6
0
 /**
  * Creates a comment sub element.
  *
  * @param tags map with tags
  * @param parent parent element
  */
 final void comment(final TokenObjMap<TokenList> tags, final FElem parent) {
   for (final byte[] tag : tags) {
     for (final byte[] name : tags.get(tag)) add(name, elem(tag, parent));
   }
 }
Exemplo n.º 7
0
 @Override
 void indexDelete() {
   if (!txtBuffer.isEmpty()) ((DiskValues) textIndex).delete(txtBuffer);
   if (!atvBuffer.isEmpty()) ((DiskValues) attrIndex).delete(atvBuffer);
 }
Exemplo n.º 8
0
 @Override
 protected void indexAdd() {
   if (!txtBuffer.isEmpty()) ((DiskValues) textIndex).add(txtBuffer);
   if (!atvBuffer.isEmpty()) ((DiskValues) attrIndex).add(atvBuffer);
 }