Example #1
0
  private MarshalledEntry entryFromDoc(TreeNodeKey key, ReadDocument findDoc) {
    InternalMetadata metadataBb = null;
    AtomicHashMap<PropertyId, PropertyValue> nodeValue =
        new AtomicHashMap<PropertyId, PropertyValue>();
    JsonObject raw = JsonObject.fromString(findDoc.asString(EntryKey.VALUE));
    JsonObject props = raw.asJsonObject(EntryKey.PROPS);
    for (Entry<String, JsonElement> entry : props.entrySet()) {
      String pkey = entry.getKey();
      JsonElement pvalue = entry.getValue();
      PropertyId propId = PropertyId.fromIdString(pkey);
      nodeValue.put(propId, PropertyValue.loadFrom(key, propId, pvalue));
    }

    return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, nodeValue, metadataBb);
  }
Example #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;
    }
  }