@Override public Set<String> getMissing( final Location location ) { logger.debug( "[NFC] getMissing for {} start", location ); Set<String> paths = new HashSet<>(); Query query = queryFactory.from( NfcConcreteResourceWrapper.class ) .maxResults( maxResultSetSize ) .having( "location" ) .eq( ( (KeyedLocation) location ).getKey().toString() ) .toBuilder() .build(); List<NfcConcreteResourceWrapper> matches = query.list(); matches.forEach( resource -> paths.add( resource.getPath() )); logger.debug( "[NFC] getMissing complete, count: {}", matches.size() ); return paths; }
/** * Get missing entries via pagination. * @param location * @param pageIndex starts from 0 * @param pageSize how many entries in each page * @return */ @Override public Set<String> getMissing( Location location, int pageIndex, int pageSize ) { logger.debug( "[NFC] getMissing for {} start, pageIndex: {}, pageSize: {}", location, pageIndex, pageSize ); Set<String> paths = new HashSet<>(); pageSize = getProperPageSize(pageSize); long offset = pageIndex * pageSize; Query query = queryFactory.from( NfcConcreteResourceWrapper.class ) .startOffset( offset ) .maxResults( pageSize ) .orderBy( "path" ) .having( "location" ) .eq( ( (KeyedLocation) location ).getKey().toString() ) .toBuilder() .build(); List<NfcConcreteResourceWrapper> matches = query.list(); matches.forEach( resource -> paths.add( resource.getPath() ) ); logger.debug( "[NFC] getMissing complete, count: {}", matches.size() ); return paths; }
@Override public long getSize( StoreKey storeKey ) { Query query = queryFactory.from( NfcConcreteResourceWrapper.class ) .select( Expression.count( "path" ) ) .having( "location" ) .eq( storeKey.toString() ) .toBuilder() .build(); List<Object> result = query.list(); Object[] count = (Object[]) result.get( 0 ); return (Long) count[0]; }
Query query = bqEnd.toBuilder().build(); Map<RowKey,Map<String, Object>> resultsCollector = new HashMap<>(); try ( CloseableIterator<Entry<Object,Object>> iterator = c.retrieveEntriesByQuery( query, null, 100 ) ) {
@Override @Measure public void clearAllIndexedPathWithOriginalStore( ArtifactStore originalStore ) { StoreKey osk = originalStore.getKey(); long total = iterateRemove( () -> queryFactory.from( IndexedStorePath.class ) .maxResults( ITERATE_RESULT_SIZE ) .having( "packageType" ) .eq( osk.getPackageType() ) .and() .having( "originStoreType" ) .eq( osk.getType().name() ) .and() .having( "originStoreName" ) .eq( osk.getName() ) .toBuilder() .build() ); logger.trace( "Cleared all indices with origin: {}, size: {}", osk, total ); }
@Override @Measure public void clearAllIndexedPathInStore( ArtifactStore store ) { StoreKey sk = store.getKey(); long total = iterateRemove( () -> queryFactory.from( IndexedStorePath.class ) .maxResults( ITERATE_RESULT_SIZE ) .having( "packageType" ) .eq( sk.getPackageType() ) .and() .having( "storeType" ) .eq( sk.getType().name() ) .and() .having( "storeName" ) .eq( sk.getName() ) .toBuilder() .build() ); logger.trace( "Cleared all indices with group: {}, size: {}", sk, total ); }
public static void main(String[] args) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.indexing().index(Index.ALL) .addProperty("default.directory_provider", "ram") .addProperty("lucene_version", "LUCENE_CURRENT"); // Construct a simple local cache manager with default configuration DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build()); // Obtain the default cache Cache<String, Person> cache = cacheManager.getCache(); // Store some entries cache.put("person1", new Person("William", "Shakespeare")); cache.put("person2", new Person("William", "Wordsworth")); cache.put("person3", new Person("John", "Milton")); // Obtain a query factory for the cache QueryFactory queryFactory = Search.getQueryFactory(cache); // Construct a query Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build(); // Execute the query List<Person> matches = query.list(); // List the results matches.forEach(person -> System.out.printf("Match: %s", person)); // Stop the cache manager and release all resources cacheManager.stop(); }
@Override @Measure public void clearAllIndexedPathInStoreWithOriginal( ArtifactStore store, ArtifactStore originalStore ) { StoreKey sk = store.getKey(); StoreKey osk = originalStore.getKey(); long total = iterateRemove( () -> queryFactory.from( IndexedStorePath.class ) .maxResults( ITERATE_RESULT_SIZE ) .having( "packageType" ) .eq( osk.getPackageType() ) .and() .having( "storeType" ) .eq( sk.getType().name() ) .and() .having( "storeName" ) .eq( sk.getName() ) .and() .having( "originStoreType" ) .eq( osk.getType().name() ) .and() .having( "originStoreName" ) .eq( osk.getName() ) .toBuilder() .build() ); logger.trace( "Cleared all indices with origin: {} and group: {}, size: {}", osk, sk, total ); }