private StorageStatement storeStatement() { return storageStatement == null ? storageStatement = storeLayer.newStatement() : storageStatement; } }
static PropertyExistenceEnforcer getOrCreatePropertyExistenceEnforcerFrom( StoreReadLayer storeLayer ) { return storeLayer.getOrCreateSchemaDependantState( PropertyExistenceEnforcer.class, FACTORY ); }
private SimpleIndexReader getLuceneIndexReader(String label, String key) throws IndexNotFoundKernelException { try (KernelStatement stmt = (KernelStatement) tx.acquireStatement()) { TokenRead tokenRead = tx.tokenRead(); LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel(tokenRead.nodeLabel(label), tokenRead.propertyKey(key)); RecordStorageEngine recordStorageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class); SchemaIndexDescriptor descriptor = recordStorageEngine.storeReadLayer().indexGetForSchema(labelSchemaDescriptor); IndexReader indexReader = stmt.getStoreStatement().getIndexReader(descriptor); if (indexReader instanceof FusionIndexBase) { try { Field selectorField = FusionIndexBase.class.getDeclaredField("instanceSelector"); selectorField.setAccessible(true); Object instanceSelector = selectorField.get(indexReader); Field instancesField = getDeclaredField(instanceSelector, "instances"); instancesField.setAccessible(true); IndexReader[] instances = (IndexReader[]) instancesField.get(instanceSelector); for (IndexReader instance : instances) { if (instance instanceof SimpleIndexReader) { return (SimpleIndexReader)instance; } } throw new IllegalStateException("No Lucene Index Reader found"); } catch (Exception e) { throw new RuntimeException("Error accessing index reader",e); } } return (SimpleIndexReader)indexReader; } }
public void triggerIndexSampling( String labelKey, String propertyKey, boolean forceSample ) { int labelKeyId = -1; int propertyKeyId = -1; State state = this.state; if ( state != null ) { labelKeyId = state.storeLayer.labelGetForName( labelKey ); propertyKeyId = state.storeLayer.propertyKeyGetForName( propertyKey ); } if ( state == null || labelKeyId == -1 || propertyKeyId == -1 ) { throw new IllegalArgumentException( "No property or label key was found associated with " + propertyKey + " and " + labelKey ); } try { state.indexingService.triggerIndexSampling( SchemaDescriptorFactory.forLabel( labelKeyId, propertyKeyId ), getIndexSamplingMode( forceSample ) ); } catch ( IndexNotFoundKernelException e ) { throw new IllegalArgumentException( e.getMessage() ); } }
private byte[] createCommands( String tokenName ) { StorageEngine storageEngine = dependencies.resolveDependency( StorageEngine.class ); Collection<StorageCommand> commands = new ArrayList<>(); TransactionState txState = new TxState(); int tokenId = Math.toIntExact( idGeneratorFactory.get( tokenIdType ).nextId() ); createToken( txState, tokenName, tokenId ); try ( StorageStatement statement = storageEngine.storeReadLayer().newStatement() ) { storageEngine.createCommands( commands, txState, statement, ResourceLocker.NONE, Long.MAX_VALUE ); } catch ( CreateConstraintFailureException | TransactionFailureException | ConstraintValidationKernelException e ) { throw new RuntimeException( "Unable to create token '" + tokenName + "'", e ); } return ReplicatedTokenRequestSerializer.commandBytes( commands ); }
private byte[] createCommands( String tokenName ) { StorageEngine storageEngine = dependencies.resolveDependency( StorageEngine.class ); Collection<StorageCommand> commands = new ArrayList<>(); TransactionState txState = new TxState(); int tokenId = Math.toIntExact( idGeneratorFactory.get( tokenIdType ).nextId() ); createToken( txState, tokenName, tokenId ); try ( StorageStatement statement = storageEngine.storeReadLayer().newStatement() ) { storageEngine.createCommands( commands, txState, statement, ResourceLocker.NONE, Long.MAX_VALUE ); } catch ( CreateConstraintFailureException | TransactionFailureException | ConstraintValidationException e ) { throw new RuntimeException( "Unable to create token '" + tokenName + "'", e ); } return ReplicatedTokenRequestSerializer.commandBytes( commands ); }