You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/06/30 08:58:31 UTC

[GitHub] [ignite] ololo3000 commented on a diff in pull request #10116: IGNITE-17236 Inline statistics added to index-reader

ololo3000 commented on code in PR #10116:
URL: https://github.com/apache/ignite/pull/10116#discussion_r910762876


##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/indexreader/IgniteIndexReader.java:
##########
@@ -229,7 +283,18 @@ public IgniteIndexReader(
         partStores = new FilePageStore[partCnt];
 
         for (int i = 0; i < partCnt; i++)
-            partStores[i] = filePageStoreFactory.createFilePageStore(i, FLAG_DATA);
+            partStores[i] = filePageStore(i, FLAG_DATA, storeFactory);
+
+        Arrays.stream(root.listFiles(f -> f.getName().endsWith(CACHE_DATA_FILENAME))).forEach(f -> {
+            try (ObjectInputStream stream = new ObjectInputStream(Files.newInputStream(f.toPath()))) {

Review Comment:
   Can we use here JdkMarshaller?



##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/indexreader/IgniteIndexReader.java:
##########
@@ -640,25 +701,87 @@ private void doWithoutErrors(RunnableX x, ScanContext ctx, long pageId) {
      * @param name Index name.
      * @return Pair of cache id and type id.
      */
-    public IgnitePair<Integer> cacheAndTypeId(String name) {
+    public GridTuple3<Integer, Integer, String> cacheAndTypeId(String name) {
         return cacheTypeIds.computeIfAbsent(name, k -> {
+            Matcher xId = CACHE_TYPE_ID_INDEX_SEARCH_PATTERN.matcher(k);
+
+            if (xId.find())
+                return new GridTuple3<>(parseInt(xId.group("id")), parseInt(xId.group("typeId")), xId.group("indexName"));
+
             Matcher mId = CACHE_TYPE_ID_SEARCH_PATTERN.matcher(k);
 
             if (mId.find())
-                return new IgnitePair<>(parseInt(mId.group("id")), parseInt(mId.group("typeId")));
+                return new GridTuple3<>(parseInt(mId.group("id")), parseInt(mId.group("typeId")), null);
 
             Matcher cId = CACHE_ID_SEARCH_PATTERN.matcher(k);
 
             if (cId.find())
-                return new IgnitePair<>(parseInt(cId.group("id")), 0);
+                return new GridTuple3<>(parseInt(cId.group("id")), 0, null);
 
-            return new IgnitePair<>(0, 0);
+            return new GridTuple3<>(0, 0, null);
         });
     }
 
     /** */
-    ScanContext createContext(int cacheId, FilePageStore store, ItemStorage items) {
-        return new ScanContext(cacheId, store, items);
+    ScanContext createContext(String idxName, FilePageStore store, ItemStorage items) {
+        GridTuple3<Integer, Integer, String> parsed;
+
+        if (idxName != null)
+            parsed = cacheAndTypeId(idxName);
+        else
+            parsed = new GridTuple3<>(UNKNOWN_CACHE, 0, null);
+
+        return new ScanContext(parsed.get1(), inlineFieldsCount(parsed), store, items);
+    }
+
+    /**
+     * Seach index definition inside cache query entities.

Review Comment:
   Typo.



##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/indexreader/IgniteIndexReader.java:
##########
@@ -263,19 +328,15 @@ public static void main(String[] args) {
 
         p.parse(asList(args).iterator());
 
-        IgniteIndexReaderFilePageStoreFactory filePageStoreFactory = new IgniteIndexReaderFilePageStoreFactory(
-            new File(p.<String>get(DIR_ARG)),
-            p.get(PAGE_SIZE_ARG),
-            p.get(PART_CNT_ARG),
-            p.get(PAGE_STORE_VER_ARG)
-        );
-
         Set<String> idxs = new HashSet<>(asList(p.get(INDEXES_ARG)));
 
         try (IgniteIndexReader reader = new IgniteIndexReader(
+            p.<Integer>get(PAGE_SIZE_ARG),

Review Comment:
   It seems we can omit \<Integer\> here and below.



##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/indexreader/IgniteIndexReader.java:
##########
@@ -1040,6 +1186,33 @@ private void printIoStat(String prefix, String caption, Map<Class<? extends Page
         );
     }
 
+    /**
+     * Creating new {@link FilePageStore} and initializing it.
+     * It can return {@code null} if partition file were not found, for example: node should not contain it by affinity.
+     *
+     * @param partId Partition ID.
+     * @param type Data type, can be {@link PageIdAllocator#FLAG_IDX} or {@link PageIdAllocator#FLAG_DATA}.
+     * @param storeFactory Store factory.
+     * @return New instance of {@link FilePageStore} or {@code null}.
+     * @throws IgniteCheckedException If there are errors when creating or initializing {@link FilePageStore}.
+     */
+    @Nullable FilePageStore filePageStore(

Review Comment:
   Can we make it private?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org