shadybones / hypergraphdb

Automatically exported from code.google.com/p/hypergraphdb
0 stars 0 forks source link

by part indexing on interfaces #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following code:

HGHandle worldObjectType =
hyperGraph.getTypeSystem().getTypeHandle(WorldObject.class);
 hyperGraph.getIndexManager().register(new
ByPartIndexer(worldObjectType, new String[] {"UUID"}));

breaks with a NullPointerException if WorldObject is an interface.
Make it an abstract class and all of sudden everything works.

Original issue reported on code.google.com by borislav...@gmail.com on 28 Feb 2011 at 4:05

GoogleCodeExporter commented 9 years ago
In ByPartIndexer class
There is loss of logic to check type.
the first loop only check out if a CompositeType, but JavaInterfaceBinding not 
subclass of CompositeType, so fly away.
I not dig deep into hgdb self so:)

    private synchronized HGProjection [] getProjections(HyperGraph graph)
    {
        if (projections == null)
        {
            HGAtomType type = graph.getTypeSystem().getType(getType());
            if (type == null)
                throw new HGException("Could not find type with handle " + getType());
            projections = new HGProjection[dimensionPath.length];
            for (int j = 0; j < dimensionPath.length; j++)
            {
                if (! (type instanceof HGCompositeType))
                    return null;//fly away if javainterfacebinding
                projections[j] = ((HGCompositeType)type).getProjection(dimensionPath[j]);
                if (projections[j] == null)
                    throw new HGException("There's no projection '" + 
                                          dimensionPath[j] + 
                                          "' in type '" + type + "'");
                type = (HGAtomType)graph.get(projections[j].getType());
            }   

Original comment by saintof...@gmail.com on 13 Mar 2011 at 8:21