use of org.neo4j.kernel.impl.api.index.NodePropertyCommandsExtractor in project neo4j by neo4j.
the class TransactionRecordStateTest method shouldCreateEqualNodePropertyUpdatesOnRecoveryOfCreatedNode.
@Test
public void shouldCreateEqualNodePropertyUpdatesOnRecoveryOfCreatedNode() throws Exception {
/* There was an issue where recovering a tx where a node with a label and a property
* was created resulted in two exact copies of NodePropertyUpdates. */
// GIVEN
NeoStores neoStores = neoStoresRule.open();
long nodeId = 0;
int labelId = 5, propertyKeyId = 7;
// -- an index
long ruleId = 0;
TransactionRecordState recordState = newTransactionRecordState(neoStores);
SchemaRule rule = indexRule(ruleId, forLabel(labelId, propertyKeyId), PROVIDER_DESCRIPTOR);
recordState.createSchemaRule(rule);
apply(neoStores, recordState);
// -- and a tx creating a node with that label and property key
recordState = newTransactionRecordState(neoStores);
recordState.nodeCreate(nodeId);
recordState.addLabelToNode(labelId, nodeId);
recordState.nodeAddProperty(nodeId, propertyKeyId, "Neo");
// WHEN
PhysicalTransactionRepresentation transaction = transactionRepresentationOf(recordState);
NodePropertyCommandsExtractor extractor = new NodePropertyCommandsExtractor();
transaction.accept(extractor);
// THEN
// -- later recovering that tx, there should be only one update
assertTrue(extractor.containsAnyNodeOrPropertyUpdate());
PrimitiveLongSet recoveredNodeIds = Primitive.longSet();
recoveredNodeIds.addAll(extractor.nodeCommandsById().iterator());
recoveredNodeIds.addAll(extractor.propertyCommandsByNodeIds().iterator());
assertEquals(1, recoveredNodeIds.size());
assertEquals(nodeId, recoveredNodeIds.iterator().next());
}
use of org.neo4j.kernel.impl.api.index.NodePropertyCommandsExtractor in project neo4j by neo4j.
the class TransactionRecordStateTest method indexUpdatesOf.
private Iterable<NodeUpdates> indexUpdatesOf(NeoStores neoStores, TransactionRepresentation transaction) throws IOException {
NodePropertyCommandsExtractor extractor = new NodePropertyCommandsExtractor();
transaction.accept(extractor);
OnlineIndexUpdates lazyIndexUpdates = new OnlineIndexUpdates(neoStores.getNodeStore(), new PropertyLoader(neoStores), new PropertyPhysicalToLogicalConverter(neoStores.getPropertyStore()));
lazyIndexUpdates.feed(extractor.propertyCommandsByNodeIds(), extractor.nodeCommandsById());
return lazyIndexUpdates;
}
Aggregations