本文整理汇总了Java中org.hypergraphdb.type.HGAtomType类的典型用法代码示例。如果您正苦于以下问题:Java HGAtomType类的具体用法?Java HGAtomType怎么用?Java HGAtomType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HGAtomType类属于org.hypergraphdb.type包,在下文中一共展示了HGAtomType类的31个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDirLinks
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
private static Set<HGAtomType> getDirLinks(HyperGraph hg)
{
if (dir_links != null) return dir_links;
dir_links = new HashSet<HGAtomType>();
/* HGHandle sHandle = hg.getTypeSystem().getTypeHandle(HGTypeStructuralInfo.class);
AtomTypeCondition cond = new AtomTypeCondition(hg.getPersistentHandle(sHandle)); */
HGHandle sHandle = hg.getHandle(HGTypeStructuralInfo.class);
//TODO: ??? after last major HG changes this throws NPE
if(sHandle == null || sHandle.equals(hg.getHandleFactory().nullHandle()))
return dir_links;
AtomTypeCondition cond = new AtomTypeCondition(hg.getPersistentHandle(sHandle));
HGQuery query = HGQuery.make(hg, cond);
HGSearchResult it = query.execute();
while (it.hasNext())
{
it.next();
HGTypeStructuralInfo info =
(HGTypeStructuralInfo) hg.get((HGHandle)it.current());
if(info != null && info.isOrdered() && info.getArity() == 2)
{
dir_links.add(hg.getTypeSystem().getType(info.getTypeHandle()));
}
}
it.close();
return dir_links;
}
开发者ID:hypergraphdb,
项目名称:viewer,
代码行数:27,
代码来源:HGVUtils.java
示例2: testFieldAdded
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@Test
public void testFieldAdded()
{
for (Bean x : (List<Bean>)(List)graph.getAll(hg.type(Bean.class)))
System.out.println(x);
graph.getTransactionManager().ensureTransaction(new Callable<Object>(){
public Object call()
{
HGHandle typeHandle = graph.getTypeSystem().getTypeHandle(Bean.class);
HGHandle dummyType = graph.getHandleFactory().makeHandle();
URI typeUri = graph.getTypeSystem().getSchema().toTypeURI(Bean.class);
graph.getTypeSystem().getSchema().defineType(typeUri, dummyType);
HGAtomType newType = graph.get(dummyType);
graph.replace(typeHandle, newType);
graph.remove(dummyType);
return null;
}
});
this.reopenDb();
// for (Bean x : (List<Bean>)(List)graph.getAll(hg.type(Bean.class)))
// x.setName2("Another " + x.getName());
listThem("After type change and new atoms added...");
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:26,
代码来源:ChangingRecordTypes.java
示例3: readAtom
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public static Object readAtom(HGHandle handle,
HyperGraph graph,
RefResolver<HGHandle, HGAtomType> typeResolver,
StorageGraph subgraph)
{
Object object = null;
HGPersistentHandle [] layout = subgraph.getLink(handle.getPersistent());
graph.getStore().attachOverlayGraph(subgraph);
try
{
HGHandle [] targetSet = new HGHandle[layout.length-2];
System.arraycopy(layout, 2, targetSet, 0, layout.length-2);
HGAtomType type = typeResolver.resolve(layout[0]);
object = type.make(layout[1],
new ReadyRef<HGHandle[]>(targetSet),
null);
}
finally
{
graph.getStore().detachOverlayGraph();
}
return object;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:24,
代码来源:SubgraphManager.java
示例4: getRemoteTypes
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
private void getRemoteTypes(final HGPeerIdentity from,
final StorageGraph subgraph,
final Set<HGHandle> types,
final Map<HGHandle, HGHandle> typeMap)
{
GetAtom getTypeActivity = new GetAtom(getThisPeer(), types, from);
ActivityListener continuation = new ActivityListener()
{
@SuppressWarnings("unchecked")
public void activityFinished(ActivityResult result)
{
if (result.getActivity().getState().isCompleted())
readAtoms(subgraph,
typeMap,
(Map<HGHandle, HGAtomType>)(Map<?,?>)((GetAtom)result.getActivity()).atomMap);
else
GetAtom.this.getState().assign(result.getActivity().getState().getConst());
}
};
getThisPeer().getActivityManager().initiateActivity(getTypeActivity, this, continuation);
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:22,
代码来源:GetAtom.java
示例5: maybeIndex
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
/**
* <p>
* Called when an atom is being added to hypergraph to check and possibly
* add index entries for the indexed dimensions of the atom's type.
* </p>
*
* @param typeHandle
* @param type
* @param atomHandle
* @param atom
*/
public void maybeIndex(HGPersistentHandle typeHandle,
HGAtomType type,
HGPersistentHandle atomHandle,
Object atom)
{
List<HGIndexer> indList = (List)indexers.get(typeHandle);
if (indList == null)
return;
for (HGIndexer indexer : indList)
{
HGIndex<Object, Object> idx = getOrCreateIndex(indexer);
indexer.index(graph, atomHandle, atom, idx);
// Object key = indexer.getKey(graph, atom);
// Object value = (indexer instanceof HGValueIndexer) ?
// ((HGValueIndexer)indexer).getValue(graph, atom)
// : atomHandle;
// idx.addEntry(key, value);
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:31,
代码来源:HGIndexManager.java
示例6: maybeUnindex
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
/**
* <p>
* Called when an atom is being added to hypergraph to check and possibly
* add index entries for the indexed dimensions of the atom's type.
* </p>
*
* @param typeHandle
* @param type
* @param atom
* @param atomHandle
*/
public void maybeUnindex(HGPersistentHandle typeHandle,
HGAtomType type,
HGPersistentHandle atomHandle,
Object atom)
{
List<HGIndexer> indList = (List)indexers.get(typeHandle);
if (indList == null)
return;
for (HGIndexer indexer : indList)
{
HGIndex<Object, Object> idx = getOrCreateIndex(indexer);
indexer.unindex(graph, atomHandle, atom, idx);
// Object key = indexer.getKey(graph, atom);
// Object value = (indexer instanceof HGValueIndexer) ? ((HGValueIndexer)indexer).getValue(graph, atom)
// : atomHandle;
// idx.removeEntry(key, value);
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:30,
代码来源:HGIndexManager.java
示例7: satisfies
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public boolean satisfies(HyperGraph graph, HGHandle general)
{
HGHandle generalType = graph.getType(general);
if (specificValue.get() == null)
{
return ((HGAtomType)graph.get(graph.getType(general))).subsumes(graph.get(general), null);
}
else
{
HGHandle h = graph.getHandle(specificValue.get());
HGHandle specificType;
if (h == null)
specificType = graph.getTypeSystem().getTypeHandle(specificValue.get().getClass());
else
{
specificType = graph.getType(h);
if (declaredSubsumption(graph, general, h))
return true;
}
if (!specificType.equals(generalType))
return false;
else
return ((HGAtomType)graph.get(graph.getType(general))).subsumes(graph.get(general), specificValue.get());
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:27,
代码来源:SubsumesCondition.java
示例8: getMetaData
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public QueryMetaData getMetaData(HyperGraph graph, HGQueryCondition c)
{
TypedValueCondition vc = (TypedValueCondition) c;
HGHandle typeHandle = vc.getTypeHandle(graph);
HGAtomType type = graph.get(typeHandle);
if (type == null)
throw new HGException("Cannot search by value"
+ " of unknown HGAtomType with handle " + typeHandle);
QueryMetaData qmd;
if (!hg.isVar(vc.getTypeReference()) &&
(type instanceof HGSearchable && vc.getOperator() == ComparisonOperator.EQ
|| type instanceof HGOrderedSearchable))
{
qmd = QueryMetaData.ORDERED.clone(c);
}
else
{
qmd = QueryMetaData.MISTERY.clone(c);
}
qmd.predicateCost = 2.5;
return qmd;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:23,
代码来源:TypedValueToQuery.java
示例9: satisfies
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public boolean satisfies(HyperGraph hg, HGHandle specific)
{
HGHandle specificType = hg.getType(specific);
if (generalValue.get() == null)
{
return ((HGAtomType)hg.get(hg.getType(specific))).subsumes(null, hg.get(specific));
}
else
{
HGHandle h = hg.getHandle(generalValue.get());
HGHandle generalType;
if (h == null)
generalType = hg.getTypeSystem().getTypeHandle(generalValue.get().getClass());
else
{
generalType = hg.getType(h);
if (declaredSubsumption(hg, h, specific))
return true;
}
if (!generalType.equals(specificType))
return false;
else
return ((HGAtomType)hg.get(hg.getType(specific))).subsumes(generalValue.get(), hg.get(specific));
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:27,
代码来源:SubsumedCondition.java
示例10: subsumes
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
/**
* <p>
* A <code>HGRelType</code> <em>X</em> subsumes a <code>HGRelType</code> <em>Y</em>
* iff both have the same name and arity and each target atom of <em>X</em> subsumes
* the corresponding target atom of <em>Y</em>.
* </p>
* <p>
* In plain language this reflects the logical requirement that each instance
* relationship with type <em>Y</em> be also an instance (logically) of <em>X</em>.
* </p>
*
*/
public boolean subsumes(Object general, Object specific)
{
HGRelType grel = (HGRelType)general;
HGRelType srel = (HGRelType)specific;
if (general == null || specific == null)
return general == specific;
if (!grel.getName().equals(srel.getName()) || grel.getArity() != srel.getArity())
return false;
for (int i = 0; i < grel.getArity(); i++)
{
HGHandle g = grel.getTargetAt(i);
HGHandle s = srel.getTargetAt(i);
if (g.equals(s))
continue;
else
{
HGAtomType gt = graph.getTypeSystem().getAtomType(g);
HGAtomType st = graph.getTypeSystem().getAtomType(s);
if (!gt.equals(st) || !gt.subsumes(graph.get(g), graph.get(s)))
return false;
}
}
return true;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:37,
代码来源:HGRelTypeConstructor.java
示例11: store
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public HGPersistentHandle store(Object instance)
{
EnumType et = (EnumType)instance;
if (!et.getEnumType().isEnum())
throw new HGException("Attempting to store non Enum class " +
et.getEnumType().getClass() + " as an enum.");
HGPersistentHandle [] layout = new HGPersistentHandle[1 + et.getEnumType().getEnumConstants().length];
HGAtomType stringType = graph.getTypeSystem().getAtomType(String.class);
layout[0] = stringType.store(et.getEnumType().getName());
Enum<?> [] constants =(Enum[])et.getEnumType().getEnumConstants();
for (int i = 0; i < constants.length; i++ )
{
layout[i + 1] = stringType.store(constants[i].name());
}
return graph.getStore().store(layout);
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:17,
代码来源:EnumTypeConstructor.java
示例12: store
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@Override
public HGPersistentHandle store(Object instance) {
HGAtomType type = graph.getTypeSystem().getAtomType( Long.class );
Random rand = ( (DefaultPrimitiveRandom) instance ).getRand();
try {
Field field = Random.class.getDeclaredField("seed");
boolean acc = field.isAccessible();
field.setAccessible(true);
AtomicLong rnda = (AtomicLong)( field.get( rand ) );
Long rnd = rnda.get();
field.setAccessible( acc );
return( type.store( rnd ) );
} catch (Throwable ex) {
ex.printStackTrace(System.out);
}
return( null );
}
开发者ID:viridian1138,
项目名称:SimpleAlgebra_V2,
代码行数:18,
代码来源:DefaultPrimitiveRandomType.java
示例13: define
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
/**
* <p>
* A version of <code>define</code> allowing one to pass a specific type to use when
* storing the atom.
* </p>
*
* @param atomHandle The atom handle.
* @param typeHandle The handle of the type to use.
* @param instance The atom instance.
* @param flags System flags.
*/
public void define(final HGHandle atomHandle,
final HGHandle typeHandle,
final Object instance,
final int flags)
{
getTransactionManager().ensureTransaction(new Callable<Object>()
{ public Object call() {
HGAtomType type = typeSystem.getType(typeHandle);
HGLink link = null;
Object payload = instance;
if (instance instanceof HGLink)
{
link = (HGLink)instance;
if (instance instanceof HGValueLink)
payload = ((HGValueLink)instance).getValue();
}
HGPersistentHandle valueHandle = TypeUtils.storeValue(HyperGraph.this, payload, type);
define(atomHandle, typeHandle, valueHandle, link, instance);
HyperGraph.this.atomAdded(atomHandle.getPersistent(), instance, flags);
if (instance instanceof HGTypeHolder)
((HGTypeHolder<HGAtomType>)instance).setAtomType(type);
return null;
}});
}
开发者ID:armatys,
项目名称:hypergraphdb-android,
代码行数:36,
代码来源:HyperGraph.java
示例14: addNode
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
private HGLiveHandle addNode(final Object payload, final HGHandle typeHandle, final byte flags)
{
return getTransactionManager().ensureTransaction(new Callable<HGLiveHandle>()
{ public HGLiveHandle call() {
HGAtomType type = typeSystem.getType(typeHandle);
HGPersistentHandle pTypeHandle = getPersistentHandle(typeHandle);
HGPersistentHandle valueHandle = TypeUtils.storeValue(HyperGraph.this, payload, type);
HGPersistentHandle [] layout = new HGPersistentHandle[2];
layout[0] = pTypeHandle;
layout[1] = valueHandle;
final HGLiveHandle lHandle = atomAdded(store.store(layout), payload, flags);
if (payload instanceof HGTypeHolder)
((HGTypeHolder<HGAtomType>)payload).setAtomType(type);
indexByType.addEntry(pTypeHandle, lHandle.getPersistent());
indexByValue.addEntry(valueHandle, lHandle.getPersistent());
idx_manager.maybeIndex(pTypeHandle, type, lHandle.getPersistent(), payload);
return lHandle;
} });
}
开发者ID:armatys,
项目名称:hypergraphdb-android,
代码行数:21,
代码来源:HyperGraph.java
示例15: rawMake
点赞 3
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
/**
* Make a run-time instance given a layout and a type. Ignore caching,
* incidence set management etc.
*
* @param layout
* @param type
* @return
*/
private Object rawMake(HGPersistentHandle [] layout, HGAtomType type, HGPersistentHandle atomHandle)
{
HGPersistentHandle [] targetSet = EMPTY_PERSISTENT_HANDLE_SET;
if (layout.length > 2)
{
targetSet = new HGPersistentHandle[layout.length - 2];
for (int i = 2; i < layout.length; i++)
targetSet[i - 2] = layout[i];
}
// TypeUtils.initiateAtomConstruction(HyperGraph.this, layout[1]);
Object result = type.make(layout[1],
new ReadyRef<HGHandle[]>(targetSet),
new IncidenceSetRef(atomHandle, this));
// TypeUtils.atomConstructionComplete(HyperGraph.this, layout[1]);
if (targetSet.length > 0 && ! (result instanceof HGLink))
result = new HGValueLink(result, targetSet);
if (result instanceof HGAtomType)
result = typeSystem.toRuntimeInstance(atomHandle, (HGAtomType)result);
return result;
}
开发者ID:armatys,
项目名称:hypergraphdb-android,
代码行数:29,
代码来源:HyperGraph.java
示例16: getListCellRendererComponent
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
setComponentOrientation(list.getComponentOrientation());
if (isSelected)
{
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
else
{
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setIcon(null);
if (hg != null)
{
HGHandle h = (HGHandle) list.getModel().getElementAt(index); // (HGHandle)value
HGAtomType cls = hg.getTypeSystem().getType(h);
if (cls != null)
{
if (cls instanceof JavaBeanBinding) setText(cls.toString());
else
setText(cls.getClass().getName());
}
}
else
setText((value == null) ? "" : value.toString());
setEnabled(list.isEnabled());
setFont(list.getFont());
setBorder((cellHasFocus) ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
return this;
}
开发者ID:hypergraphdb,
项目名称:viewer,
代码行数:38,
代码来源:PaintersPanel.java
示例17: make
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object make(HGPersistentHandle valueHandle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet)
{
HGPersistentHandle [] layout = graph.getStore().getLink(valueHandle);
HGAtomType stype = graph.getTypeSystem().getAtomType(String.class);
HGAtomType collType = graph.getTypeSystem().getAtomType(ArrayList.class);
HyperGraph db = HGEnvironment.get((String) stype.make(layout[0], null, null));
Collection<FNode> nodes = (Collection<FNode>)collType.make(layout[1], null, null);
Collection<FEdge> edges = (Collection<FEdge>)collType.make(layout[2], null, null);
return new HGViewer(db, nodes, edges);
}
开发者ID:hypergraphdb,
项目名称:viewer,
代码行数:13,
代码来源:HGViewerType.java
示例18: release
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public void release(HGPersistentHandle handle)
{
HGPersistentHandle [] layout = graph.getStore().getLink(handle);
HGAtomType stype = graph.getTypeSystem().getAtomType(String.class);
HGAtomType collType = graph.getTypeSystem().getAtomType(ArrayList.class);
stype.release(layout[0]);
collType.release(layout[1]);
collType.release(layout[2]);
}
开发者ID:hypergraphdb,
项目名称:viewer,
代码行数:10,
代码来源:HGViewerType.java
示例19: getAllAtomTypes
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public static Set<HGAtomType> getAllAtomTypes(HyperGraph graph)
{
Set<HGAtomType> types = new HashSet<HGAtomType>();
HGSearchResult it = graph.find(hg.all()); //ind.scanValues();
while (it.hasNext())
{
Object obj = graph.get((HGHandle) it.next());
HGAtomType type = graph.getTypeSystem().getAtomType(obj);
types.add(type);
}
it.close();
return types;
}
开发者ID:hypergraphdb,
项目名称:viewer,
代码行数:14,
代码来源:HGVUtils.java
示例20: getComparator
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public Comparator<?> getComparator(HyperGraph graph)
{
HGAtomType type = graph.get(propertyType);
if (type instanceof Comparator)
return (Comparator<?>)type;
else if (type instanceof HGPrimitiveType)
return ((HGPrimitiveType)type).getComparator();
else
return null;
}
开发者ID:hypergraphdb,
项目名称:mjson,
代码行数:11,
代码来源:ByJsonPropertyIndexer.java
示例21: main
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public static void main(String [] argv)
{
System.out.println(byte[][][].class.getName());
String tmpdir = System.getProperty("java.io.tmpdir");
System.out.println("Using tmp dir " + tmpdir);
String location = tmpdir + "/hgpredefined";
HGUtils.dropHyperGraphInstance(location);
HyperGraph graph = new HyperGraph(location);
try
{
HGPersistentHandle TYPEHANDLE = graph.getHandleFactory().makeHandle("7023c8e3-3ae4-11dc-872e-b08ac7fa685c");
HGAtomType type = new APredefinedType();
graph.getTypeSystem().addPredefinedType(TYPEHANDLE, type, (URI)null);
HGHandle h = graph.add(new TestPredefined(), TYPEHANDLE);
HGSearchResult rs = graph.find(hg.type(TYPEHANDLE));
try
{
while (rs.hasNext())
{
HGHandle hh = (HGHandle)rs.next();
System.out.println("atom " + graph.get(hh));
}
}
finally
{
rs.close();
}
}
finally
{
graph.close();
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:34,
代码来源:TestPredefined.java
示例22: testReplacePredefinedType
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@Test
public void testReplacePredefinedType()
{
HGHandle h0 = graph.add(new Integer(1));
HGHandle originalTypeHandle = graph.getTypeSystem().getTypeHandle(Integer.class);
HGPersistentHandle myTypeHandle = graph.getHandleFactory().makeHandle();
graph.getTypeSystem().addPredefinedType(myTypeHandle, new MyIntType(),
Integer.class);
List<HGHandle> L = hg.findAll(graph, hg.type(originalTypeHandle));
for (HGHandle x : L)
{
System.out.println("Replacing value " + graph.get(x) + " with new type.");
graph.replace(x, graph.get(x), myTypeHandle);
}
super.reopenDb();
Assert.assertEquals(graph.getTypeSystem().getTypeHandle(Integer.class),
myTypeHandle);
HGAtomType intType = graph.getTypeSystem().getAtomType(Integer.class);
Assert.assertEquals(intType.getClass(), MyIntType.class);
HGHandle h1 = graph.add(8573);
HGHandle h2 = graph.add(0);
HGHandle h3 = graph.add(Integer.MAX_VALUE);
super.reopenDb();
Assert.assertEquals(graph.getType(h0), myTypeHandle);
Assert.assertEquals((Object)graph.get(h0), new Integer(1));
Assert.assertEquals((Object)graph.get(h1), new Integer(8573));
Assert.assertEquals((Object)graph.get(h2), new Integer(0));
Assert.assertEquals((Object)graph.get(h3), Integer.MAX_VALUE);
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:30,
代码来源:PredefinedReplacement.java
示例23: onAddAtom
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@FromState("Started")
@OnMessage(performative="Request")
@PossibleOutcome("Completed")
public WorkflowStateConstant onAddAtom(Json msg) throws Throwable
{
HyperGraph graph = getThisPeer().getGraph();
Json content = msg.at(CONTENT);
final RAMStorageGraph subgraph = SubgraphManager.decodeSubgraph(content.at("storage-graph").asString());
final Map<String, String> typeClasses = Messages.fromJson(content.at("type-classes"));
final HGHandle typeHandle = Messages.fromJson(content.at("type-handle"));
final HGHandle [] targets = Messages.fromJson(content.at("targets"));
Map<HGHandle, HGHandle> localTypes = SubgraphManager.getLocalTypes(graph, typeClasses);
subgraph.translateHandles(localTypes);
HGHandle ltype = localTypes.get(typeHandle);
if (ltype == null)
ltype = typeHandle;
graph.getStore().attachOverlayGraph(subgraph);
try
{
HGAtomType type = graph.get(ltype);
atom = type.make(subgraph.getRoots().iterator().next(),
new ReadyRef<HGHandle[]>(targets),
null);
}
finally
{
graph.getStore().detachOverlayGraph();
}
this.atomHandle = graph.add(atom, ltype);
reply(msg, Performative.Agree, Json.object("atom-handle", atomHandle));
return WorkflowStateConstant.Completed;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:33,
代码来源:AddAtom.java
示例24: onResponse
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@FromState("Started")
@OnMessage(performative = "InformRef")
public WorkflowStateConstant onResponse(Json msg)
{
HyperGraph graph = getThisPeer().getGraph();
Json L = msg.at(CONTENT);
result = new ArrayList<Object>();
for (Json j : L.asJsonList())
{
Object x = Messages.fromJson(j);
if (x instanceof HGHandle)
result.add(x);
else if (j.has("atom-handle"))
{
HGHandle handle = Messages.fromJson(j.at("atom-handle"));
StorageGraph sgraph = SubgraphManager.decodeSubgraph(j.at("atom").at("storage-graph").asString());
Map<String, String> typeClasses = Messages.fromJson(j.at("atom").at("type-classes"));
final Map<HGHandle, HGHandle> typeMap =
SubgraphManager.getLocalTypes(graph, typeClasses);
if (handle != null)
{
result.add(new Pair<HGHandle, Object>(handle,
SubgraphManager.readAtom(handle,
graph,
new KeyMapResolver<HGHandle, HGAtomType>
(new MapResolver<HGHandle, HGHandle>(typeMap),
new HGAtomResolver<HGAtomType>(graph)),
sgraph)));
}
else
result.add(x);
}
else
result.add(x);
}
return WorkflowState.Completed;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:38,
代码来源:RunRemoteQuery.java
示例25: onReplaceAtom
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@FromState("Started")
@OnMessage(performative="Request")
@PossibleOutcome("Completed")
public WorkflowStateConstant onReplaceAtom(Json msg) throws Throwable
{
HyperGraph graph = getThisPeer().getGraph();
Json A = msg.at(CONTENT);
this.atomHandle = Messages.fromJson(A.at("atom-handle"));
final RAMStorageGraph subgraph = SubgraphManager.decodeSubgraph(A.at("storage-graph").asString());
final Map<String, String> typeClasses = Messages.fromJson(A.at("type-classes"));
this.typeHandle = Messages.fromJson(A.at("type-handle"));
final HGHandle [] targets = Messages.fromJson(A.at("targets"));
Map<HGHandle, HGHandle> localTypes = SubgraphManager.getLocalTypes(graph, typeClasses);
subgraph.translateHandles(localTypes);
HGHandle ltype = localTypes.get(typeHandle);
if (ltype == null)
ltype = typeHandle;
graph.getStore().attachOverlayGraph(subgraph);
try
{
HGAtomType type = graph.get(ltype);
value = type.make(subgraph.getRoots().iterator().next(),
new ReadyRef<HGHandle[]>(targets),
null);
}
finally
{
graph.getStore().detachOverlayGraph();
}
replaced = graph.replace(atomHandle, value, ltype);
reply(msg, Performative.Agree, replaced);
return WorkflowStateConstant.Completed;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:34,
代码来源:ReplaceAtom.java
示例26: readAtoms
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
private void readAtoms(StorageGraph sgraph, Map<HGHandle, HGHandle> typeMap, Map<HGHandle, HGAtomType> types)
{
atomMap = new HashMap<HGHandle, Object>();
for (HGPersistentHandle handle : sgraph.getRoots())
atomMap.put(handle, SubgraphManager.readAtom(
handle,
getThisPeer().getGraph(),
types == null ? new HGAtomResolver<HGAtomType>(getThisPeer().getGraph())
:
new ChainResolver<HGHandle, HGAtomType>(
new MapResolver<HGHandle, HGAtomType>(types),
new HGAtomResolver<HGAtomType>(getThisPeer().getGraph())),
sgraph));
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:15,
代码来源:GetAtom.java
示例27: satisfies
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public boolean satisfies(HyperGraph graph, HGHandle handle)
{
if (baseSet == null)
{
baseSet = new HashMap<HGHandle, HGHandle>();
HGSearchResult<HGHandle> rs = null;
try
{
rs = graph.find(baseSetCondition);
while (rs.hasNext())
{
HGHandle h = rs.next();
HGAtomType ot = graph.getTypeSystem().getAtomType(h);
HGProjection proj = TypeUtils.getProjection(graph, ot, dimensionPath);
if (proj != null)
{
Object part = proj.project(graph.get(h));
if (part != null)
baseSet.put(graph.getHandle(part), h);
}
}
}
finally
{
HGUtils.closeNoException(rs);
}
}
return baseSet.containsKey(handle);
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:30,
代码来源:AtomProjectionCondition.java
示例28: execute
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public HGSearchResult<T> execute()
{
//
// TODO: how to we deal with null values? For the String
// primitive type at least, nulls are possible.
//
HGHandle typeHandle = vc.getTypeHandle(graph);
HGAtomType type = graph.get(typeHandle);
if (type == null)
throw new HGException("Cannot search by value " + vc.getValue()
+ " of unknown HGAtomType with handle " + typeHandle);
Object value = vc.getValue();
if (type instanceof HGSearchable
&& vc.getOperator() == ComparisonOperator.EQ
|| type instanceof HGOrderedSearchable)
//
// Find value handle by value and pipe into 'indexByValue' search,
// then filter
// by the expected type to make sure that it matches the actual type
// of the atoms
// so far obtained.
//
return new PredicateBasedFilter(graph, new PipeQuery(
new SearchableBasedQuery((HGSearchable<?, ?>) type, value,
vc.getOperator()), new SearchableBasedQuery(graph
.getIndexManager().getIndexByValue(), null,
ComparisonOperator.EQ)), new AtomTypeCondition(
typeHandle)).execute();
else
// else, we need to scan all atoms of the given type
return new PredicateBasedFilter(graph, new IndexBasedQuery(graph
.getIndexManager().getIndexByType(),
typeHandle.getPersistent()),
new AtomValueCondition(vc.getValue(), vc.getOperator())).execute();
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:38,
代码来源:TypedValueToQuery.java
示例29: count
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public long count(HyperGraph graph, HGQueryCondition x)
{
TypedValueCondition cond = (TypedValueCondition)x;
HGHandle typeHandle = cond.getTypeHandle();
if (typeHandle == null)
typeHandle = graph.getTypeSystem().getTypeHandleIfDefined(cond.getJavaClass());
if (typeHandle == null)
return 0;
HGAtomType type = graph.getTypeSystem().getType(typeHandle);
if (type instanceof HGSearchable && cond.getOperator() == ComparisonOperator.EQ)
{
@SuppressWarnings("rawtypes")
HGSearchResult<HGPersistentHandle> rs = ((HGSearchable)type).find(cond.getValue());
try
{
long result = 0;
while (rs.hasNext())
result += graph.indexByValue.stats().valuesOfKey(rs.next(), 1, true).value();
return result;
}
finally
{
try { rs.close(); } catch (Throwable t) { }
}
}
else
{
return countResultSet(graph, x);
}
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:31,
代码来源:ResultSizeEstimation.java
示例30: cost
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public long cost(HyperGraph graph, HGQueryCondition x)
{
TypedValueCondition cond = (TypedValueCondition)x;
HGHandle typeHandle = cond.getTypeHandle();
if (typeHandle == null)
typeHandle = graph.getTypeSystem().getTypeHandle(cond.getJavaClass());
if (typeHandle == null)
return 0;
HGAtomType type = graph.getTypeSystem().getType(typeHandle);
if (type instanceof HGSearchable && cond.getOperator() == ComparisonOperator.EQ)
return 2;
else
return Integer.MAX_VALUE;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:15,
代码来源:ResultSizeEstimation.java
示例31: store
点赞 2
import org.hypergraphdb.type.HGAtomType; //导入依赖的package包/类
public HGPersistentHandle store(Object instance)
{
HGRelType relType = (HGRelType)instance;
HGAtomType sType = graph.getTypeSystem().getAtomType(String.class);
HGPersistentHandle result = sType.store(relType.getName());
if (getIndex().findFirst(relType.getName().getBytes()) == null)
getIndex().addEntry(relType.getName().getBytes(), result);
return result;
}
开发者ID:hypergraphdb,
项目名称:hypergraphdb,
代码行数:10,
代码来源:HGRelTypeConstructor.java