I have an in memory database class that can be used to store any java objects. When the…
- User
I have an in memory database class that can be used to store any java objects. When the class is created, it is told what classes are stored in the db. Like so:
public class RelatableAutoGraph implements AutoGraph {
codeprivate final Map<Class<?>, AutographTable<?>> tables; private final Map<SelectionKey, AutographTable<?>> selectorsToTables; public RelatableAutoGraph(Class<?>... entityTypes) { tables = new HashMap<>(); selectorsToTables = new HashMap<>(); for (Class<?> entityType : entityTypes) { tables.put(entityType, new AutographTable<>(this, entityType)); } }objects can be added with an addAll(Collection<?>) method or add(Object o) method. These methods look like:
@Override public void addAll(Collection table = null; Class<?> prev = null; for (Object o : objects) { if (prev == null || !prev.equals(o.getClass())) { table = findTableFor(o.getClass()); prev = o.getClass(); } table.addObject(o); } }
codepublic void add(Object o) { AutographTable<?> table = findTableFor(o.getClass()); if (table != null) { table.addObject(o); } } private AutographTable<?> findTableFor(Class<?> clzz) { AutographTable<?> t = tables.get(clzz); if (t != null) { return t; } else { System.out.println("Looking for table for " + clzz); for (Class<?> intface : clzz.getInterfaces()) { t = findTableFor(intface); if (t != null) { tables.put(clzz, t); return t; } } t = findTableFor(clzz.getSuperclass()); if (t != null) { tables.put(clzz, t); return t; } } return null; }As you can see, the class has to do some work to find the right table object to hold each incoming object. Now, in addition, incoming objects might have references to other objects we want stored in the database, so consider this db:
Assistant
- User
Can you update to handle circular/cyclic references so that the code doesn't infinite loop
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.