use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class GraphDbStructureGuide method showLabels.
private void showLabels(ReadOperations read, DbStructureVisitor visitor) {
for (Label label : db.getAllLabels()) {
int labelId = read.labelGetForName(label.name());
visitor.visitLabel(labelId, label.name());
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class GraphDbStructureGuide method showNodeCounts.
private void showNodeCounts(ReadOperations read, DbStructureVisitor visitor) {
visitor.visitAllNodesCount(read.countsForNode(ANY_LABEL));
for (Label label : db.getAllLabels()) {
int labelId = read.labelGetForName(label.name());
visitor.visitNodeCount(labelId, label.name(), read.countsForNode(labelId));
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class RecoveryIT method shouldRecoverIdsCorrectlyWhenWeCreateAndDeleteANodeInTheSameRecoveryRun.
@Test
public void shouldRecoverIdsCorrectlyWhenWeCreateAndDeleteANodeInTheSameRecoveryRun() throws IOException {
GraphDatabaseService database = startDatabase(directory.graphDbDir());
Label testLabel = Label.label("testLabel");
final String propertyToDelete = "propertyToDelete";
final String validPropertyName = "validProperty";
try (Transaction transaction = database.beginTx()) {
Node node = database.createNode();
node.addLabel(testLabel);
transaction.success();
}
try (Transaction transaction = database.beginTx()) {
Node node = findNodeByLabel(database, testLabel);
node.setProperty(propertyToDelete, createLongString());
node.setProperty(validPropertyName, createLongString());
transaction.success();
}
try (Transaction transaction = database.beginTx()) {
Node node = findNodeByLabel(database, testLabel);
node.removeProperty(propertyToDelete);
transaction.success();
}
// copying only transaction log simulate non clean shutdown db that should be able to recover just from logs
File restoreDbStoreDir = copyTransactionLogs();
// database should be restored and node should have expected properties
GraphDatabaseService recoveredDatabase = startDatabase(restoreDbStoreDir);
try (Transaction ignored = recoveredDatabase.beginTx()) {
Node node = findNodeByLabel(recoveredDatabase, testLabel);
assertFalse(node.hasProperty(propertyToDelete));
assertTrue(node.hasProperty(validPropertyName));
}
database.shutdown();
recoveredDatabase.shutdown();
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class Neo4jPackTest method shouldBeAbleToPackAndUnpackListStream.
@SuppressWarnings("unchecked")
@Test
public void shouldBeAbleToPackAndUnpackListStream() throws IOException {
// Given
PackedOutputArray output = new PackedOutputArray();
Neo4jPack.Packer packer = new Neo4jPack.Packer(output);
packer.packListStreamHeader();
List<String> expected = new ArrayList<>();
for (Label label : ALICE.getLabels()) {
String labelName = label.name();
packer.pack(labelName);
expected.add(labelName);
}
packer.packEndOfStream();
Object unpacked = unpacked(output.bytes());
// Then
assertThat(unpacked, instanceOf(List.class));
List<String> unpackedList = (List<String>) unpacked;
assertThat(unpackedList, equalTo(expected));
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class ConsistencyCheckServiceIntegrationTest method shouldNotReportDuplicateForHugeLongValues.
@Test
public void shouldNotReportDuplicateForHugeLongValues() throws Exception {
// given
ConsistencyCheckService service = new ConsistencyCheckService();
Config configuration = Config.embeddedDefaults(settings());
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(testDirectory.graphDbDir()).setConfig(GraphDatabaseSettings.record_format, getRecordFormatName()).newGraphDatabase();
String propertyKey = "itemId";
Label label = Label.label("Item");
try (Transaction tx = db.beginTx()) {
db.schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create();
tx.success();
}
try (Transaction tx = db.beginTx()) {
set(db.createNode(label), property(propertyKey, 973305894188596880L));
set(db.createNode(label), property(propertyKey, 973305894188596864L));
tx.success();
}
db.shutdown();
// when
Result result = runFullConsistencyCheck(service, configuration);
// then
assertTrue(result.isSuccessful());
}
Aggregations