Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.neo4j.internal.collector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.neo4j.common.EntityType;
import org.neo4j.internal.helpers.collection.Iterators;
import org.neo4j.internal.kernel.api.Read;
import org.neo4j.internal.kernel.api.SchemaRead;
import org.neo4j.internal.kernel.api.TokenRead;
import org.neo4j.internal.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException;
import org.neo4j.internal.kernel.api.security.LoginContext;
import org.neo4j.internal.schema.ConstraintDescriptor;
import org.neo4j.internal.schema.IndexDescriptor;
import org.neo4j.internal.schema.IndexType;
import org.neo4j.kernel.api.Kernel;
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.token.api.NamedToken;
/**
* The Graph Counts section holds all data that is available form the counts store, plus metadata
* about the available indexes and constraints. This essentially captures all the knowledge the
* planner has when planning, meaning that the data from this section could be used to investigate
* planning problems.
*/
final class GraphCountsSection {
private GraphCountsSection() { // only static functionality
}
static Stream retrieve(Kernel kernel, Anonymizer anonymizer)
throws TransactionFailureException, IndexNotFoundKernelException {
try (KernelTransaction tx =
kernel.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
TokenRead tokens = tx.tokenRead();
Read read = tx.dataRead();
Map data = new HashMap<>();
data.put("nodes", nodeCounts(tokens, read, anonymizer));
data.put("relationships", relationshipCounts(tokens, read, anonymizer));
data.put("indexes", indexes(tokens, tx.schemaRead(), anonymizer));
data.put("constraints", constraints(tokens, tx.schemaRead(), anonymizer));
return Stream.of(new RetrieveResult(Sections.GRAPH_COUNTS, data));
}
}
private static List