[teiid-commits] teiid SVN: r3453 - in branches/7.4.x/engine/src/main/java/org/teiid/common/buffer: impl and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Sep 6 16:27:28 EDT 2011


Author: shawkins
Date: 2011-09-06 16:27:27 -0400 (Tue, 06 Sep 2011)
New Revision: 3453

Modified:
   branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/SPage.java
   branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-1742 using longs instead of integers for page ids

Modified: branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/SPage.java	2011-09-06 20:08:58 UTC (rev 3452)
+++ branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/SPage.java	2011-09-06 20:27:27 UTC (rev 3453)
@@ -27,7 +27,6 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.teiid.common.buffer.BatchManager.ManagedBatch;
 import org.teiid.core.TeiidComponentException;
@@ -54,8 +53,6 @@
 		}
 	}
 	
-	private static AtomicInteger counter = new AtomicInteger();
-
 	STree stree;
 	
 	protected SPage next;
@@ -66,7 +63,7 @@
 	
 	SPage(STree stree, boolean leaf) {
 		this.stree = stree;
-		this.values = new TupleBatch(counter.getAndIncrement(), new ArrayList(stree.pageSize/4));
+		this.values = new TupleBatch(0, new ArrayList(stree.pageSize/4));
 		if (!leaf) {
 			children = new ArrayList<SPage>(stree.pageSize/4);
 		}

Modified: branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java	2011-09-06 20:08:58 UTC (rev 3452)
+++ branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java	2011-09-06 20:27:27 UTC (rev 3453)
@@ -163,7 +163,9 @@
 				store = newStore;
 				long oldOffset = offset;
 				offset = store.getLength();
-				LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+					LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				}
 				return offset;
 			} finally {
 				this.compactionLock.writeLock().unlock();
@@ -180,10 +182,10 @@
 	 * Holder for active batches
 	 */
 	private class TupleBufferInfo {
-		TreeMap<Integer, ManagedBatchImpl> batches = new TreeMap<Integer, ManagedBatchImpl>();
-		Integer lastUsed = null;
+		TreeMap<Long, ManagedBatchImpl> batches = new TreeMap<Long, ManagedBatchImpl>();
+		Long lastUsed = null;
 		
-		ManagedBatchImpl removeBatch(int row) {
+		ManagedBatchImpl removeBatch(long row) {
 			ManagedBatchImpl result = batches.remove(row);
 			if (result != null) {
 				activeBatchKB -= result.sizeEstimate;
@@ -213,7 +215,9 @@
 				this.lobManager = new LobManager();
 			}
 			sizeEstimate = (int) Math.max(1, manager.sizeUtility.getBatchSize(batch) / 1024);
-            LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+				LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+			}
 		}
 		
 		@Override
@@ -242,26 +246,28 @@
 				if (update) {
 					activeBatches.put(batchManager.id, tbi);
 				}
-				Assertion.isNull(tbi.batches.put(this.beginRow, this));
+				tbi.batches.put(this.id, this);
 			}
 		}
 
 		@Override
 		public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
 			long reads = readAttempts.incrementAndGet();
-			LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+				LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+			}
 			synchronized (activeBatches) {
 				TupleBufferInfo tbi = activeBatches.remove(batchManager.id);
 				if (tbi != null) { 
 					boolean put = true;
 					if (!cache) {
-						tbi.removeBatch(this.beginRow);
+						tbi.removeBatch(this.id);
 						if (tbi.batches.isEmpty()) {
 							put = false;
 						}
 					}
 					if (put) {
-						tbi.lastUsed = this.beginRow;
+						tbi.lastUsed = this.id;
 						activeBatches.put(batchManager.id, tbi);
 					}
 				}
@@ -286,7 +292,9 @@
 					}
 				}
 				long count = readCount.incrementAndGet();
-				LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+				if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+					LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+				}
 				try {
 					this.batchManager.compactionLock.readLock().lock();
 					long[] info = batchManager.physicalMapping.get(this.id);
@@ -324,7 +332,9 @@
 				if (batch != null) {
 					if (!persistent) {
 						long count = writeCount.incrementAndGet();
-						LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+						if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+							LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+						}
 						long offset = 0;
 						if (lobManager != null) {
 							for (List<?> tuple : batch.getTuples()) {
@@ -341,7 +351,9 @@
 				            long[] info = new long[] {offset, size};
 				            batchManager.physicalMapping.put(this.id, info);
 						}
-						LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+						if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+							LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+						}
 					}
 					if (softCache) {
 						this.batchReference = new SoftReference<TupleBatch>(batch);
@@ -365,7 +377,7 @@
 		public void remove() {
 			synchronized (activeBatches) {
 				TupleBufferInfo tbi = activeBatches.get(batchManager.id);
-				if (tbi != null && tbi.removeBatch(this.beginRow) != null) {
+				if (tbi != null && tbi.removeBatch(this.id) != null) {
 					if (tbi.batches.isEmpty()) {
 						activeBatches.remove(batchManager.id);
 					}
@@ -381,7 +393,7 @@
 		
 		@Override
 		public String toString() {
-			return "ManagedBatch " + batchManager.id + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$
+			return "ManagedBatch " + batchManager.id + " " + this.id + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		}
 	}
 	
@@ -496,13 +508,17 @@
     	for (int i = 1; i < compareIndexes.length; i++) {
 			compareIndexes[i] = i;
 		}
-        LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$ 
+    	if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+    		LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+    	}
     	return new STree(keyManager, bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
     }
 
     @Override
     public FileStore createFileStore(String name) {
-        LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$ 
+    	if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+    		LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+    	}
     	return this.diskMgr.createFileStore(name);
     }
         
@@ -610,7 +626,7 @@
 				}
 				Iterator<TupleBufferInfo> iter = activeBatches.values().iterator();
 				TupleBufferInfo tbi = iter.next();
-				Map.Entry<Integer, ManagedBatchImpl> entry = null;
+				Map.Entry<Long, ManagedBatchImpl> entry = null;
 				if (tbi.lastUsed != null) {
 					entry = tbi.batches.floorEntry(tbi.lastUsed - 1);
 				}



More information about the teiid-commits mailing list