Search in sources :

Example 11 with EntryList

use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.

the class StandardJanusGraphTx method executeMultiQuery.

public void executeMultiQuery(final Collection<InternalVertex> vertices, final SliceQuery sq, final QueryProfiler profiler) {
    LongArrayList vertexIds = new LongArrayList(vertices.size());
    for (InternalVertex v : vertices) {
        if (!v.isNew() && v.hasId() && (v instanceof CacheVertex) && !v.hasLoadedRelations(sq))
            vertexIds.add(v.longId());
    }
    if (!vertexIds.isEmpty()) {
        List<EntryList> results = QueryProfiler.profile(profiler, sq, true, q -> graph.edgeMultiQuery(vertexIds, q, txHandle));
        int pos = 0;
        for (JanusGraphVertex v : vertices) {
            if (pos < vertexIds.size() && vertexIds.get(pos) == v.longId()) {
                final EntryList vresults = results.get(pos);
                ((CacheVertex) v).loadRelations(sq, query -> vresults);
                pos++;
            }
        }
    }
}
Also used : LongArrayList(com.carrotsearch.hppc.LongArrayList) EntryList(org.janusgraph.diskstorage.EntryList) CacheVertex(org.janusgraph.graphdb.vertices.CacheVertex)

Example 12 with EntryList

use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.

the class PartitionedVertexProgramExecutor method run.

public void run(int numThreads, ScanMetrics metrics) {
    StandardJanusGraphTx tx = null;
    Map<Long, EntryList> pVertexAggregates = vertexMemory.retrievePartitionAggregates();
    // Nothing to do here
    if (pVertexAggregates.isEmpty())
        return;
    try (WorkerPool workers = new WorkerPool(numThreads)) {
        tx = VertexJobConverter.startTransaction(graph);
        for (Map.Entry<Long, EntryList> partitionedVertices : pVertexAggregates.entrySet()) {
            if (partitionedVertices.getValue() == null) {
                metrics.incrementCustom(GHOST_PARTITION_VERTEX);
                continue;
            }
            workers.submit(new PartitionedVertexProcessor(partitionedVertices.getKey(), partitionedVertices.getValue(), tx, metrics));
        }
    } catch (Throwable ex) {
        log.error("Could not post-process partitioned vertices", ex);
        metrics.incrementCustom(PARTITION_VERTEX_POSTFAIL);
    } finally {
        if (tx != null && tx.isOpen())
            tx.rollback();
    }
}
Also used : WorkerPool(org.janusgraph.graphdb.util.WorkerPool) StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) EntryList(org.janusgraph.diskstorage.EntryList) Map(java.util.Map)

Example 13 with EntryList

use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.

the class VertexProgramScanJob method process.

@Override
public void process(JanusGraphVertex vertex, ScanMetrics metrics) {
    PreloadedVertex v = (PreloadedVertex) vertex;
    long vertexId = v.longId();
    VertexMemoryHandler<M> vh = new VertexMemoryHandler(vertexMemory, v);
    vh.setInExecute(true);
    v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
    if (idManager.isPartitionedVertex(vertexId)) {
        if (idManager.isCanonicalVertexId(vertexId)) {
            EntryList results = v.getFromCache(SYSTEM_PROPS_QUERY);
            if (results == null)
                results = EntryList.EMPTY_LIST;
            vertexMemory.setLoadedProperties(vertexId, results);
        }
        for (MessageScope scope : vertexMemory.getPreviousScopes()) {
            if (scope instanceof MessageScope.Local) {
                M combinedMsg = null;
                for (Iterator<M> messageIterator = vh.receiveMessages(scope).iterator(); messageIterator.hasNext(); ) {
                    M msg = messageIterator.next();
                    if (combinedMsg == null)
                        combinedMsg = msg;
                    else
                        combinedMsg = combiner.combine(combinedMsg, msg);
                }
                if (combinedMsg != null)
                    vertexMemory.aggregateMessage(vertexId, combinedMsg, scope);
            }
        }
    } else {
        v.setPropertyMixing(vh);
        try {
            vertexProgram.execute(v, vh, memory);
        } catch (ReadOnlyTransactionException e) {
        // Ignore read-only transaction errors in FulgoraGraphComputer. In testing these errors are associated
        // with cleanup of TraversalVertexProgram.HALTED_TRAVERSALS properties which can safely remain in graph.
        }
    }
    vh.setInExecute(false);
}
Also used : PreloadedVertex(org.janusgraph.graphdb.vertices.PreloadedVertex) ReadOnlyTransactionException(org.janusgraph.core.ReadOnlyTransactionException) EntryList(org.janusgraph.diskstorage.EntryList) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope)

Example 14 with EntryList

use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.

the class MetricInstrumentedStore method getSlice.

@Override
public EntryList getSlice(final KeySliceQuery query, final StoreTransaction txh) throws BackendException {
    return runWithMetrics(txh, metricsStoreName, M_GET_SLICE, () -> {
        final EntryList result = backend.getSlice(query, txh);
        recordSliceMetrics(txh, result);
        return result;
    });
}
Also used : EntryList(org.janusgraph.diskstorage.EntryList)

Example 15 with EntryList

use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.

the class StandardSchemaCache method expireSchemaElement.

// @Override
// public void expireSchemaName(final String name) {
// ConcurrentMap<String,Long> types = typeNames;
// if (types!=null) types.remove(name);
// typeNamesBackup.invalidate(name);
// }
@Override
public void expireSchemaElement(final long schemaId) {
    // 1) expire relations
    final long cutTypeId = (schemaId >>> SCHEMAID_BACK_SHIFT);
    ConcurrentMap<Long, EntryList> types = schemaRelations;
    if (types != null) {
        types.keySet().removeIf(key -> (key >>> SCHEMAID_TOTALFORW_SHIFT) == cutTypeId);
    }
    for (Long key : schemaRelationsBackup.asMap().keySet()) {
        if ((key >>> SCHEMAID_TOTALFORW_SHIFT) == cutTypeId)
            schemaRelationsBackup.invalidate(key);
    }
    // 2) expire names
    ConcurrentMap<String, Long> names = typeNames;
    if (names != null) {
        names.entrySet().removeIf(next -> next.getValue().equals(schemaId));
    }
    for (Map.Entry<String, Long> entry : typeNamesBackup.asMap().entrySet()) {
        if (entry.getValue().equals(schemaId))
            typeNamesBackup.invalidate(entry.getKey());
    }
}
Also used : NonBlockingHashMapLong(org.cliffc.high_scale_lib.NonBlockingHashMapLong) EntryList(org.janusgraph.diskstorage.EntryList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Aggregations

EntryList (org.janusgraph.diskstorage.EntryList)18 Map (java.util.Map)4 Entry (org.janusgraph.diskstorage.Entry)4 Test (org.junit.Test)4 Instant (java.time.Instant)3 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)3 SliceQuery (org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)3 StandardLockCleanerRunnable (org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable)3 LongArrayList (com.carrotsearch.hppc.LongArrayList)2 ArrayList (java.util.ArrayList)2 NonBlockingHashMapLong (org.cliffc.high_scale_lib.NonBlockingHashMapLong)2 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)2 KeySliceQuery (org.janusgraph.diskstorage.keycolumnvalue.KeySliceQuery)2 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)2 CacheTransaction (org.janusgraph.diskstorage.keycolumnvalue.cache.CacheTransaction)2 CacheVertex (org.janusgraph.graphdb.vertices.CacheVertex)2 PreloadedVertex (org.janusgraph.graphdb.vertices.PreloadedVertex)2 ImmutableList (com.google.common.collect.ImmutableList)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 Column (com.netflix.astyanax.model.Column)1