private void dropPartitionsNoTxn(String catName, String dbName, String tblName, List<String> partNames) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(catName, dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setClass(MPartition.class); long deleted = query.deletePersistentAll(queryWithParams.getSecond()); LOG.debug("Deleted {} partition from store", deleted); query.closeAll(); }
query.setClass(MSchemaVersion.class); List<MSchemaVersion> mSchemaVersions = query.setNamedParameters(parameters).executeList(); if (mSchemaVersions == null || mSchemaVersions.isEmpty()) {
/** * Gets partition names from the table via ORM (JDOQL) name filter. * @param dbName Database name. * @param tblName Table name. * @param partNames Partition names to get the objects for. * @return Resulting partitions. */ private List<Partition> getPartitionsViaOrmFilter(String catName, String dbName, String tblName, List<String> partNames) throws MetaException { if (partNames.isEmpty()) { return new ArrayList<>(); } ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(catName, dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setResultClass(MPartition.class); query.setClass(MPartition.class); query.setOrdering("partitionName ascending"); @SuppressWarnings("unchecked") List<MPartition> mparts = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond()); List<Partition> partitions = convertToParts(catName, dbName, tblName, mparts); if (query != null) { query.closeAll(); } return partitions; }
/** * Detaches column descriptors from storage descriptors; returns the set of unique CDs * thus detached. This is done before dropping partitions because CDs are reused between * SDs; so, we remove the links to delete SDs and then check the returned CDs to see if * they are referenced by other SDs. */ private HashSet<MColumnDescriptor> detachCdsFromSdsNoTxn( String catName, String dbName, String tblName, List<String> partNames) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(catName, dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setClass(MPartition.class); query.setResult("sd"); @SuppressWarnings("unchecked") List<MStorageDescriptor> sds = (List<MStorageDescriptor>)query.executeWithMap( queryWithParams.getSecond()); HashSet<MColumnDescriptor> candidateCds = new HashSet<>(); for (MStorageDescriptor sd : sds) { if (sd != null && sd.getCD() != null) { candidateCds.add(sd.getCD()); sd.setCD(null); } } if (query != null) { query.closeAll(); } return candidateCds; }
/** * Construct a query instance with the candidate class specified. * @param cls The class to query * @return The query */ public synchronized Query newQuery(Class cls) { Query query = newQuery(); query.setClass(cls); return query; }
/** * Construct a query instance with the candidate class specified. * @param cls The class to query * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Class<T> cls) { Query query = newQuery(); query.setClass(cls); return query; }
/** * Construct a query instance with the candidate class and filter specified. * @param cls The class to query * @param filter A filter to apply * @return The query */ public synchronized Query newQuery(Class cls, String filter) { Query query = newQuery(); query.setClass(cls); query.setFilter(filter); return query; }
/** * Construct a query instance with the candidate class and candidate * Collection specified. * @param cls The class to query * @param cln The collection * @return The query */ public synchronized Query newQuery(Class cls, Collection cln) { Query query = newQuery(); query.setClass(cls); query.setCandidates(cln); return query; }
/** * Construct a query instance with the candidate class and filter specified. * @param cls The class to query * @param filter A filter to apply * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Class<T> cls, String filter) { Query query = newQuery(); query.setClass(cls); query.setFilter(filter); return query; }
/** * Construct a query instance with the candidate class and candidate * Collection specified. * @param cls The class to query * @param cln The collection * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Class<T> cls, Collection<T> cln) { Query query = newQuery(); query.setClass(cls); query.setCandidates(cln); return query; }
/** * Construct a query instance with the candidate Extent specified; the * candidate class is taken from the Extent. * @param cln The extent to query * @return The query */ public synchronized Query newQuery(Extent cln) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); return query; }
/** * Construct a query instance with the candidate Extent specified; the * candidate class is taken from the Extent. * @param cln The extent to query * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Extent<T> cln) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); return query; }
private void dropPartitionsNoTxn(String dbName, String tblName, List<String> partNames) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setClass(MPartition.class); long deleted = query.deletePersistentAll(queryWithParams.getSecond()); LOG.debug("Deleted " + deleted + " partition from store"); query.closeAll(); }
private void dropPartitionsNoTxn(String catName, String dbName, String tblName, List<String> partNames) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(catName, dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setClass(MPartition.class); long deleted = query.deletePersistentAll(queryWithParams.getSecond()); LOG.debug("Deleted {} partition from store", deleted); query.closeAll(); }
/** * Construct a query instance with the candidate Extent and filter * specified. The candidate class is taken from the Extent. * @param cln The extent to query * @param filter A filter to apply * @return The query */ public synchronized Query newQuery(Extent cln, String filter) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); query.setFilter(filter); return query; }
/** * Construct a query instance with the candidate Extent and filter * specified. The candidate class is taken from the Extent. * @param cln The extent to query * @param filter A filter to apply * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Extent<T> cln, String filter) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); query.setFilter(filter); return query; }
private void dropPartitionsNoTxn(String dbName, String tblName, List<String> partNames) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(dbName, tblName, partNames); Query query = queryWithParams.getFirst(); query.setClass(MPartition.class); long deleted = query.deletePersistentAll(queryWithParams.getSecond()); LOG.debug("Deleted " + deleted + " partition from store"); query.closeAll(); }
private List<MPartition> getMPartitionsViaOrmFilter(String dbName, String tblName, List<String> partNames, Out<Query> out) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(dbName, tblName, partNames); Query query = out.val = queryWithParams.getFirst(); query.setResultClass(MPartition.class); query.setClass(MPartition.class); query.setOrdering("partitionName ascending"); @SuppressWarnings("unchecked") List<MPartition> result = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond()); return result; }
private List<MPartition> getMPartitionsViaOrmFilter(String dbName, String tblName, List<String> partNames, Out<Query> out) { ObjectPair<Query, Map<String, String>> queryWithParams = getPartQueryWithParams(dbName, tblName, partNames); Query query = out.val = queryWithParams.getFirst(); query.setResultClass(MPartition.class); query.setClass(MPartition.class); query.setOrdering("partitionName ascending"); @SuppressWarnings("unchecked") List<MPartition> result = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond()); return result; }
@Test public void testQuery() { PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); Query q = pm.newQuery(); assertEquals(pm, q.getPersistenceManager()); assertFalse(q.isUnmodifiable()); q.setClass(TestClass.class); testDeclarative(q); testString(q); TestTools.closePM(pm); }