Do not cache results, fixes: 3122
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 17 Feb 2010 11:25:54 +0000 (12:25 +0100)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 17 Feb 2010 11:25:54 +0000 (12:25 +0100)
src/main/java/org/yaz4j/Connection.java
src/main/java/org/yaz4j/ResultSet.java
src/main/java/org/yaz4j/Yaz4jMain.java

index 613e3ce..537a4c9 100644 (file)
@@ -37,6 +37,7 @@ public class Connection {
         options = new ConnectionOptionsCollection();
         zoomConnection = yaz4jlib.ZOOM_connection_create(options.zoomOptions);
 
+        //remove
         SWIGTYPE_p_p_char cp = null;
         SWIGTYPE_p_p_char addinfo = null;
         int errorCode = yaz4jlib.ZOOM_connection_error(zoomConnection, cp, addinfo);
index fad095c..74903c9 100644 (file)
@@ -10,18 +10,17 @@ public class ResultSet {
     private SWIGTYPE_p_ZOOM_resultset_p resultSet;
     private SWIGTYPE_p_ZOOM_connection_p connection;
     private long size = 0;
-    private Record[] records = null;
     private boolean disposed = false;
 
     ResultSet(SWIGTYPE_p_ZOOM_resultset_p resultSet, SWIGTYPE_p_ZOOM_connection_p connection) {
         this.resultSet = resultSet;
         this.connection = connection;
         size = yaz4jlib.ZOOM_resultset_size(this.resultSet);
-        records = new Record[(int) size];
     }
 
+    @Override
     public void finalize() {
-        this.dispose();
+        this._dispose();
     }
 
     ResultSetOptionsCollection getResultSetOptions() {
@@ -29,25 +28,16 @@ public class ResultSet {
     }
 
     public Record getRecord(int index) {
-        if (records[index] == null) {
-            SWIGTYPE_p_ZOOM_record_p recordTemp = yaz4jlib.ZOOM_resultset_record(resultSet, index);
-            records[index] = new Record(recordTemp, this);
-        }
-
-        return this.records[index];
+      SWIGTYPE_p_ZOOM_record_p recordTemp = yaz4jlib.ZOOM_resultset_record(resultSet, index);
+      return new Record(recordTemp, this);
     }
 
-    public int getSize() {
-        return (int) size;
+    public long getSize() {
+        return size;
     }
 
-    public void dispose() {
+    void _dispose() {
         if (!disposed) {
-            for (int i = 0; i < records.length; i++) {
-                if (records[i] != null) {
-                    records[i].dispose();
-                }
-            }
             yaz4jlib.ZOOM_resultset_destroy(resultSet);
             connection = null;
             resultSet = null;
index ca895c6..3964682 100644 (file)
@@ -16,7 +16,7 @@ public class Yaz4jMain {
         PrefixQuery query = new PrefixQuery("@attr 1=4 \"pottering\"");
         ResultSet results = conn.search(query);
 
-        int resultsSize = results.getSize();
+        long resultsSize = results.getSize();
         System.out.println("Found " + resultsSize + " records");
 
         for (int i = 0; i < resultsSize; i++) {