Beispiel #1
0
  /**
   * The base class implementation calls {@link #load(Object)} for this, we can do better because we
   * keep all keys in memory.
   */
  @Override
  public boolean contains(Object _key) {
    try {
      final TreeNodeKey key = (TreeNodeKey) _key;
      if (key.getType().isStructure()) return true;

      String id = key.getFqn().toString();
      return central.newSearcher().createRequestByKey(id).findOne() != null;
    } catch (IOException e) {
      return false;
    } catch (ParseException e) {
      return false;
    }
  }
Beispiel #2
0
  private MarshalledEntry _load(Object _key, boolean fetchValue, boolean fetchMetaValue) {
    try {
      TreeNodeKey key = (TreeNodeKey) _key;
      if (key.action() == Action.RESET || key.action() == Action.CREATE)
        return null; // if log, return

      if (key.getType().isStructure()) {
        List<ReadDocument> docs =
            central
                .newSearcher()
                .createRequest(new TermQuery(new Term(EntryKey.PARENT, key.fqnString())))
                .selections(IKeywordField.DocKey)
                .offset(1000000)
                .find()
                .getDocument();
        AtomicHashMap<String, Fqn> values = new AtomicHashMap<String, Fqn>();
        for (ReadDocument doc : docs) {
          Fqn fqn = Fqn.fromString(doc.idValue());
          values.put(fqn.name(), fqn);
        }
        InternalMetadata metadataBb = null;
        return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, values, metadataBb);
      }

      ReadDocument findDoc =
          central
              .newSearcher()
              .createRequestByKey(key.idString())
              .selections(EntryKey.VALUE)
              .findOne();
      if (findDoc == null) {
        return null;
      }
      return entryFromDoc(key, findDoc);
    } catch (IOException e) {
      return null;
    } catch (ParseException ex) {
      return null;
    }
  }