]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntSet.java
DB query swapping to file system
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / IntSet.java
index 3ef19b8f335ec9dbf60aeaf1df6bf818251d67a2..3f2e0140bda6f0a2da13dea02e7e24b7a77e8230 100644 (file)
@@ -32,8 +32,7 @@ final public class IntSet implements ResourceSet {
 
     public int[] data;
 
-    /** the index after the last entry in the list */
-    public int sizeOrData;
+    private int sizeOrData;
 
     /** the default capacity for new lists */
     protected static final int DEFAULT_CAPACITY = 3;
@@ -46,6 +45,8 @@ final public class IntSet implements ResourceSet {
 
     private IntSet() {
         support = null;
+        data = null;
+        sizeOrData = NO_DATA;
     }
 
     public IntSet(QuerySupport support) {
@@ -299,5 +300,26 @@ final public class IntSet implements ResourceSet {
         }
         procedure.finished(graph);
     }
+    
+    public void serialize(QuerySerializer serializer) {
+        serializer.writeLE(size());
+        forEach(new TIntProcedure() {
+            
+            @Override
+            public boolean execute(int value) {
+                serializer.addResource(value);
+                return true;
+            }
+        });
+    }
+    
+    public static IntSet deserialize(QueryDeserializer deserializer) throws DatabaseException {
+        int size = deserializer.readLE4();
+        IntSet result = new IntSet();
+        for(int i=0;i<size;i++) {
+            result.add(deserializer.readResource());
+        }
+        return result;
+    }
 
 }
\ No newline at end of file