private static IndexReference findMatchingIndex( KernelTransaction transaction, int labelId, int[] propertyIds ) { IndexReference index = transaction.schemaRead().index( labelId, propertyIds ); if ( index != IndexReference.NO_INDEX ) { // index found with property order matching the query return index; } else { // attempt to find matching index with different property order Arrays.sort( propertyIds ); assertNoDuplicates( propertyIds, transaction.tokenRead() ); int[] workingCopy = new int[propertyIds.length]; Iterator<IndexReference> indexes = transaction.schemaRead().indexesGetForLabel( labelId ); while ( indexes.hasNext() ) { index = indexes.next(); int[] original = index.properties(); if ( hasSamePropertyIds( original, workingCopy, propertyIds ) ) { // Ha! We found an index with the same properties in another order return index; } } return IndexReference.NO_INDEX; } }
private static IndexReference findMatchingIndex( KernelTransaction transaction, int labelId, int[] propertyIds ) { IndexReference index = transaction.schemaRead().index( labelId, propertyIds ); if ( index != IndexReference.NO_INDEX ) { // index found with property order matching the query return index; } else { // attempt to find matching index with different property order Arrays.sort( propertyIds ); assertNoDuplicates( propertyIds, transaction.tokenRead() ); int[] workingCopy = new int[propertyIds.length]; Iterator<IndexReference> indexes = transaction.schemaRead().indexesGetForLabel( labelId ); while ( indexes.hasNext() ) { index = indexes.next(); int[] original = index.properties(); if ( hasSamePropertyIds( original, workingCopy, propertyIds ) ) { // Ha! We found an index with the same properties in another order return index; } } return IndexReference.NO_INDEX; } }