use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSamplingWhenProvidingOnlyProperty.
@Test
public void failSamplingWhenProvidingOnlyProperty() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
try {
executeCommand("schema sample -p name");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("Provide both the property and the label, or run with -a to sample all indexes"));
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canListIndexesWhenNoOptionGiven.
@Test
public void canListIndexesWhenNoOptionGiven() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
executeCommand("schema", label.name(), property);
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canSampleSpecificIndex.
@Test
public void canSampleSpecificIndex() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
executeCommand("schema sample -l Person -p name");
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canForceSampleIndexes.
@Test
public void canForceSampleIndexes() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
executeCommand("schema sample -a -f");
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class SchemaImpl method awaitIndexesOnline.
@Override
public void awaitIndexesOnline(long duration, TimeUnit unit) {
actions.assertInOpenTransaction();
long millisLeft = TimeUnit.MILLISECONDS.convert(duration, unit);
Collection<IndexDefinition> onlineIndexes = new ArrayList<>();
for (Iterator<IndexDefinition> iter = getIndexes().iterator(); iter.hasNext(); ) {
if (millisLeft < 0) {
throw new IllegalStateException("Expected all indexes to come online within a reasonable time." + "Indexes brought online: " + onlineIndexes + ". Indexes not guaranteed to be online: " + asCollection(iter));
}
IndexDefinition index = iter.next();
long millisBefore = System.currentTimeMillis();
awaitIndexOnline(index, millisLeft, TimeUnit.MILLISECONDS);
millisLeft -= System.currentTimeMillis() - millisBefore;
onlineIndexes.add(index);
}
}
Aggregations