code: public int addNamespace(TableNamespace namespace, int did) {
          if (namespaces == null) {
              throw new InvalidArgument("namespace is null");
          }
  
          if (namespaces.add(namespace)) {
              int nextIndex = namespaces.size() - 1;
              namespaceIndex.put(namespace, nextIndex);
              indexNamespace.put(nextIndex, namespace);
          }
  
          Integer nsindex = namespaceIndex.get(namespace);
          List<Integer> nsi = documentNamespaces.get(did);
          if (nsi == null) {
              nsi = new ArrayList<Integer>();
              documentNamespaces.put(did, nsi);
          }
          nsi.add(nsindex);
  
          return nsindex;
      }
docs: Adds a namespace to the {@code namespaces} set. The insertion index is
  captured by {@code namespaceIndex}. The association of document to
  namespaces is also captured using the {@code documentNamespaces} map.
  
  @param namespace {@link TableNamespace}, the namespace to add, which
  cannot be null
  @param did {@code int}, the document id that this {@code namespace} is
  contained in
  @return {@code int}, the index of the added namespace ({@code > 0})
  @throws InvalidArgument Thrown if {@code namespace} is null