@Test public void testTraceRecordAtomic() { AtomicSupport store = getStore(); try { setupGraph(store); AtomicOperation atomic = store.startAtomicOperation(); Map<String, Set<Long>> incoming = Operations.traceRecordAtomic(2, Time.NONE, atomic); Assert.assertEquals( ImmutableMap.of("foo", ImmutableSet.of(1L, 4L), "bar", ImmutableSet.of(3L), "baz", ImmutableSet.of(3L)), incoming); } finally { store.stop(); } }
public static Map<String, Set<Long>> traceRecordAtomic(long record, long timestamp, AtomicOperation atomic) { Map<String, Set<Long>> incoming = Maps.newLinkedHashMap(); for (long source : atomic.getAllRecords()) { if(record != source) { Map<String, Set<TObject>> data = timestamp == Time.NONE ? atomic.select(source) : atomic.select(source, timestamp); data.forEach((key, values) -> { boolean isSource = values.stream() .filter(value -> value.getType() == Type.LINK) .map(Convert::thriftToJava).map(Link.class::cast) .map(Link::longValue) .filter(destination -> destination == record) .limit(1).count() > 0; if(isSource) { MultimapViews.put(incoming, key, source); } }); } } return incoming; }
Operations { public static Map<String, Set<Long>> traceRecordAtomic(long record, long timestamp, AtomicOperation atomic) { Map<String, Set<Long>> incoming = Maps.newLinkedHashMap(); for (long source : atomic.getAllRecords()) { if(record != source) { Map<String, Set<TObject>> data = timestamp == Time.NONE ? atomic.select(source) : atomic.select(source, timestamp); data.forEach((key, values) -> { boolean isSource = values.stream() .filter(value -> value.getType() == Type.LINK) .map(Convert::thriftToJava).map(Link.class::cast) .map(Link::longValue) .filter(destination -> destination == record) .limit(1).count() > 0; if(isSource) { MultimapViews.put(incoming, key, source); } }); } } return incoming; } }
Operations { public static Map<String, Set<Long>> traceRecordAtomic(long record, long timestamp, AtomicOperation atomic) { Map<String, Set<Long>> incoming = Maps.newLinkedHashMap(); for (long source : atomic.getAllRecords()) { if(record != source) { Map<String, Set<TObject>> data = timestamp == Time.NONE ? atomic.select(source) : atomic.select(source, timestamp); data.forEach((key, values) -> { boolean isSource = values.stream() .filter(value -> value.getType() == Type.LINK) .map(Convert::thriftToJava).map(Link.class::cast) .map(Link::longValue) .filter(destination -> destination == record) .limit(1).count() > 0; if(isSource) { MultimapViews.put(incoming, key, source); } }); } } return incoming; } private  Operations(); }
Operations { public static Map<String, Set<Long>> traceRecordAtomic(long record, long timestamp, AtomicOperation atomic) { Map<String, Set<Long>> incoming = Maps.newLinkedHashMap(); for (long source : atomic.getAllRecords()) { if(record != source) { Map<String, Set<TObject>> data = timestamp == Time.NONE ? atomic.select(source) : atomic.select(source, timestamp); data.forEach((key, values) -> { boolean isSource = values.stream() .filter(value -> value.getType() == Type.LINK) .map(Convert::thriftToJava).map(Link.class::cast) .map(Link::longValue) .filter(destination -> destination == record) .limit(1).count() > 0; if(isSource) { MultimapViews.put(incoming, key, source); } }); } } return incoming; } private  Operations(); static void addIfEmptyAtomic(String key, TObject value, long record,
            AtomicOperation atomic); static Number avgKeyAtomic(String key, long timestamp, Store store); static Number avgKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number avgKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Map<TObject, Set<Long>> browseNavigationKeyOptionalAtomic(
            String key, long timestamp, Store store); static void clearKeyRecordAtomic(String key, long record,
            AtomicOperation atomic); static void clearRecordAtomic(long record, AtomicOperation atomic); static long countKeyAtomic(String key, long timestamp, Store store); static long countKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static long countKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static void findOrInsertAtomic(Set<Long> records,
            List<Multimap<String, Object>> objects, AbstractSyntaxTree ast,
            AtomicOperation atomic); static void getAstAtomic(
            AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyAstAtomic(
            String key, AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyRecordsAtomic(
            String key, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void getKeysAstAtomic(
            Collection<String> keys, AbstractSyntaxTree ast, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeysRecordsOptionalAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void getRecordsAtomic(
            Set<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getRecordsOptionalAtomic(
            Set<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static boolean insertAtomic(Multimap<String, Object> data,
            long record, AtomicOperation atomic, List<DeferredWrite> deferred); static boolean insertDeferredAtomic(List<DeferredWrite> deferred,
            AtomicOperation atomic); static String jsonify(List<Long> records, long timestamp,
            boolean includeId, Store store); static Number maxKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number maxKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Number minKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number minKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); @Deprecated static Map<Long, Set<TObject>> navigateKeyRecordAtomic(String key,
            long record, long timestamp, AtomicOperation atomic); @Deprecated static Map<Long, Set<TObject>> navigateKeyRecordsAtomic(String key,
            Set<Long> records, long timestamp, AtomicOperation atomic); @Deprecated static Map<Long, Map<String, Set<TObject>>> navigateKeysRecordAtomic(
            List<String> keys, long record, long timestamp,
            AtomicOperation atomic); @Deprecated static Map<Long, Map<String, Set<TObject>>> navigateKeysRecordsAtomic(
            List<String> keys, Set<Long> records, long timestamp,
            AtomicOperation atomic); static boolean ping(long record, Store store); static void revertAtomic(String key, long record, long timestamp,
            AtomicOperation atomic); static void selectAstAtomic(
            AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyAstAtomic(
            String key, AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyRecordsAtomic(
            String key, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void selectKeysAstAtomic(
            Collection<String> keys, AbstractSyntaxTree ast, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeysRecordsOptionalAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void selectRecordsAtomic(
            Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectRecordsOptionalAtomic(
            Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static Number sumKeyAtomic(String key, long timestamp, Store store); static Number sumKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number sumKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Map<String, Set<Long>> traceRecordAtomic(long record,
            long timestamp, AtomicOperation atomic); static Map<Long, Map<String, Set<Long>>> traceRecordsAtomic(
            Collection<Long> records, long timestamp, AtomicOperation atomic); static Set<TObject> traverseKeyRecordOptionalAtomic(String key,
            long record, long timestamp, Store store); static Map<Long, Set<TObject>> traverseKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, Store store); static Map<String, Set<TObject>> traverseKeysRecordOptionalAtomic(
            Collection<String> keys, long record, long timestamp, Store store); static Map<Long, Map<String, Set<TObject>>> traverseKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            Store store); }
Operations { public static Map<String, Set<Long>> traceRecordAtomic(long record, long timestamp, AtomicOperation atomic) { Map<String, Set<Long>> incoming = Maps.newLinkedHashMap(); for (long source : atomic.getAllRecords()) { if(record != source) { Map<String, Set<TObject>> data = timestamp == Time.NONE ? atomic.select(source) : atomic.select(source, timestamp); data.forEach((key, values) -> { boolean isSource = values.stream() .filter(value -> value.getType() == Type.LINK) .map(Convert::thriftToJava).map(Link.class::cast) .map(Link::longValue) .filter(destination -> destination == record) .limit(1).count() > 0; if(isSource) { MultimapViews.put(incoming, key, source); } }); } } return incoming; } private  Operations(); static void addIfEmptyAtomic(String key, TObject value, long record,
            AtomicOperation atomic); static Number avgKeyAtomic(String key, long timestamp, Store store); static Number avgKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number avgKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Map<TObject, Set<Long>> browseNavigationKeyOptionalAtomic(
            String key, long timestamp, Store store); static void clearKeyRecordAtomic(String key, long record,
            AtomicOperation atomic); static void clearRecordAtomic(long record, AtomicOperation atomic); static long countKeyAtomic(String key, long timestamp, Store store); static long countKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static long countKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static void findOrInsertAtomic(Set<Long> records,
            List<Multimap<String, Object>> objects, AbstractSyntaxTree ast,
            AtomicOperation atomic); static void getAstAtomic(
            AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyAstAtomic(
            String key, AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyRecordsAtomic(
            String key, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void getKeysAstAtomic(
            Collection<String> keys, AbstractSyntaxTree ast, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getKeysRecordsOptionalAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void getRecordsAtomic(
            Set<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void getRecordsOptionalAtomic(
            Set<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static boolean insertAtomic(Multimap<String, Object> data,
            long record, AtomicOperation atomic, List<DeferredWrite> deferred); static boolean insertDeferredAtomic(List<DeferredWrite> deferred,
            AtomicOperation atomic); static String jsonify(List<Long> records, long timestamp,
            boolean includeId, Store store); static Number maxKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number maxKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Number minKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number minKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); @Deprecated static Map<Long, Set<TObject>> navigateKeyRecordAtomic(String key,
            long record, long timestamp, AtomicOperation atomic); @Deprecated static Map<Long, Set<TObject>> navigateKeyRecordsAtomic(String key,
            Set<Long> records, long timestamp, AtomicOperation atomic); @Deprecated static Map<Long, Map<String, Set<TObject>>> navigateKeysRecordAtomic(
            List<String> keys, long record, long timestamp,
            AtomicOperation atomic); @Deprecated static Map<Long, Map<String, Set<TObject>>> navigateKeysRecordsAtomic(
            List<String> keys, Set<Long> records, long timestamp,
            AtomicOperation atomic); static boolean ping(long record, Store store); static void revertAtomic(String key, long record, long timestamp,
            AtomicOperation atomic); static void selectAstAtomic(
            AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyAstAtomic(
            String key, AbstractSyntaxTree ast, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyRecordsAtomic(
            String key, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void selectKeysAstAtomic(
            Collection<String> keys, AbstractSyntaxTree ast, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectKeysRecordsOptionalAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static void selectRecordsAtomic(
            Collection<Long> records, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, AtomicOperation atomic); static void selectRecordsOptionalAtomic(
            Collection<Long> records, long timestamp, M result,
            @Nullable Function<Iterable<Long>, Iterable<Long>> streamer,
            @Nullable Consumer<M> consumer, Store store); static Number sumKeyAtomic(String key, long timestamp, Store store); static Number sumKeyRecordAtomic(String key, long record,
            long timestamp, Store store); static Number sumKeyRecordsAtomic(String key,
            Collection<Long> records, long timestamp, Store store); static Map<String, Set<Long>> traceRecordAtomic(long record,
            long timestamp, AtomicOperation atomic); static Map<Long, Map<String, Set<Long>>> traceRecordsAtomic(
            Collection<Long> records, long timestamp, AtomicOperation atomic); static Set<TObject> traverseKeyRecordOptionalAtomic(String key,
            long record, long timestamp, Store store); static Map<Long, Set<TObject>> traverseKeyRecordsOptionalAtomic(
            String key, Collection<Long> records, long timestamp, Store store); static Map<String, Set<TObject>> traverseKeysRecordOptionalAtomic(
            Collection<String> keys, long record, long timestamp, Store store); static Map<Long, Map<String, Set<TObject>>> traverseKeysRecordsAtomic(
            Collection<String> keys, Collection<Long> records, long timestamp,
            Store store);  }