@Override public HGPersistentHandle store(Object instance) { EinsteinTensorElem<Z, R, S> oid = (EinsteinTensorElem<Z, R, S>) (instance); HGHandle contravarHandle = graph.add( oid.getContravariantIndices()); // hg.assertAtom(graph, oid.getContravariantIndices() // ); !!!!!!!!!!!!!!!!!!!!! HGHandle covarHandle = graph.add(oid.getCovariantIndices()); // hg.assertAtom(graph, oid.getCovariantIndices() ); // !!!!!!!!!!!!!!!!!!!!!!!!!! HGHandle facHandle = hg.assertAtom(graph, oid.getFac().getFac()); final HashMap<ArrayList<BigInteger>, R> map = new HashMap<ArrayList<BigInteger>, R>(); for (final Entry<ArrayList<BigInteger>, R> ii : oid.getEntrySet()) { ArrayList<BigInteger> key = ii.getKey(); R val = ii.getValue(); map.put(key, val); } HGHandle mapHandle = hg.assertAtom(graph, map); HGPersistentHandle[] hn = { contravarHandle.getPersistent(), covarHandle.getPersistent(), facHandle.getPersistent(), mapHandle.getPersistent() }; return (graph.getStore().store(hn)); }
@Override public Object make( HGPersistentHandle handle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet) { HGHandle[] layout = graph.getStore().getLink(handle); ArrayList<Z> contravar = graph.get(layout[0]); ArrayList<Z> covar = graph.get(layout[1]); S fac = graph.get(layout[2]); Map<ArrayList<BigInteger>, R> map = graph.get(layout[3]); if (contravar == null) throw (new RuntimeException("Failed")); if (covar == null) throw (new RuntimeException("Failed")); if (fac == null) throw (new RuntimeException("Failed")); if (map == null) throw (new RuntimeException("Failed")); final EinsteinTensorElem<Z, R, S> et = new EinsteinTensorElem<Z, R, S>(fac, contravar, covar); for (final Entry<ArrayList<BigInteger>, R> ii : map.entrySet()) { ArrayList<BigInteger> key = ii.getKey(); R val = ii.getValue(); et.setVal(key, val); } return (et); }