asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [7/9] asterixdb git commit: Remove Append Only Flag
Date Fri, 16 Dec 2016 07:49:49 GMT
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/AbstractRTreeOperatorTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/AbstractRTreeOperatorTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/AbstractRTreeOperatorTest.java
index a07c4ae..6d90d07 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/AbstractRTreeOperatorTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/AbstractRTreeOperatorTest.java
@@ -52,6 +52,7 @@ import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
 import org.apache.hyracks.storage.am.btree.dataflow.BTreeDataflowHelperFactory;
 import org.apache.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescriptor;
 import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
+import org.apache.hyracks.storage.am.common.api.IPageManagerFactory;
 import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
 import org.apache.hyracks.storage.am.common.api.TreeIndexException;
 import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
@@ -59,6 +60,7 @@ import org.apache.hyracks.storage.am.common.dataflow.IndexDropOperatorDescriptor
 import org.apache.hyracks.storage.am.common.dataflow.TreeIndexBulkLoadOperatorDescriptor;
 import org.apache.hyracks.storage.am.common.dataflow.TreeIndexCreateOperatorDescriptor;
 import org.apache.hyracks.storage.am.common.dataflow.TreeIndexInsertUpdateDeleteOperatorDescriptor;
+import org.apache.hyracks.storage.am.common.freepage.LinkedMetadataPageManagerFactory;
 import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallbackFactory;
 import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation;
 import org.apache.hyracks.storage.am.lsm.rtree.utils.LSMRTreeUtils;
@@ -89,6 +91,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
 
     protected final IStorageManagerInterface storageManager = new TestStorageManagerInterface();
     protected final IIndexLifecycleManagerProvider lcManagerProvider = new TestIndexLifecycleManagerProvider();
+    protected final IPageManagerFactory pageManagerFactory = new LinkedMetadataPageManagerFactory();
     protected IIndexDataflowHelperFactory rtreeDataflowHelperFactory;
     protected IIndexDataflowHelperFactory btreeDataflowHelperFactory = new BTreeDataflowHelperFactory(true);
 
@@ -206,7 +209,8 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TransientLocalResourceFactoryProvider localResourceFactoryProvider = new TransientLocalResourceFactoryProvider();
         TreeIndexCreateOperatorDescriptor primaryCreateOp = new TreeIndexCreateOperatorDescriptor(spec, storageManager,
                 lcManagerProvider, primarySplitProvider, primaryTypeTraits, primaryComparatorFactories, null,
-                btreeDataflowHelperFactory, localResourceFactoryProvider, NoOpOperationCallbackFactory.INSTANCE);
+                btreeDataflowHelperFactory, localResourceFactoryProvider, NoOpOperationCallbackFactory.INSTANCE,
+                pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primaryCreateOp, NC1_ID);
         spec.addRoot(primaryCreateOp);
         runTest(spec);
@@ -246,7 +250,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TreeIndexBulkLoadOperatorDescriptor primaryBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
                 primaryRecDesc, storageManager, lcManagerProvider, primarySplitProvider, primaryTypeTraits,
                 primaryComparatorFactories, null, fieldPermutation, 0.7f, false, 1000L, true,
-                btreeDataflowHelperFactory);
+                btreeDataflowHelperFactory, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primaryBulkLoad, NC1_ID);
 
         NullSinkOperatorDescriptor nsOpDesc = new NullSinkOperatorDescriptor(spec);
@@ -268,7 +272,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TreeIndexCreateOperatorDescriptor secondaryCreateOp = new TreeIndexCreateOperatorDescriptor(spec,
                 storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, null, rtreeDataflowHelperFactory, localResourceFactoryProvider,
-                NoOpOperationCallbackFactory.INSTANCE);
+                NoOpOperationCallbackFactory.INSTANCE, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondaryCreateOp, NC1_ID);
         spec.addRoot(secondaryCreateOp);
         runTest(spec);
@@ -300,7 +304,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         BTreeSearchOperatorDescriptor primarySearchOp = new BTreeSearchOperatorDescriptor(spec, primaryRecDesc,
                 storageManager, lcManagerProvider, primarySplitProvider, primaryTypeTraits, primaryComparatorFactories,
                 null, lowKeyFields, highKeyFields, true, true, btreeDataflowHelperFactory, false, false, null,
-                NoOpOperationCallbackFactory.INSTANCE, null, null);
+                NoOpOperationCallbackFactory.INSTANCE, null, null, new LinkedMetadataPageManagerFactory());
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primarySearchOp, NC1_ID);
 
         // load secondary index
@@ -308,7 +312,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TreeIndexBulkLoadOperatorDescriptor secondaryBulkLoad = new TreeIndexBulkLoadOperatorDescriptor(spec,
                 secondaryRecDesc, storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, null, fieldPermutation, 0.7f, false, 1000L, true,
-                rtreeDataflowHelperFactory);
+                rtreeDataflowHelperFactory, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondaryBulkLoad, NC1_ID);
 
         NullSinkOperatorDescriptor nsOpDesc = new NullSinkOperatorDescriptor(spec);
@@ -353,7 +357,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TreeIndexInsertUpdateDeleteOperatorDescriptor primaryInsertOp = new TreeIndexInsertUpdateDeleteOperatorDescriptor(
                 spec, ordersDesc, storageManager, lcManagerProvider, primarySplitProvider, primaryTypeTraits,
                 primaryComparatorFactories, null, primaryFieldPermutation, IndexOperation.INSERT,
-                btreeDataflowHelperFactory, null, NoOpOperationCallbackFactory.INSTANCE);
+                btreeDataflowHelperFactory, null, NoOpOperationCallbackFactory.INSTANCE, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primaryInsertOp, NC1_ID);
 
         // secondary index
@@ -361,7 +365,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
         TreeIndexInsertUpdateDeleteOperatorDescriptor secondaryInsertOp = new TreeIndexInsertUpdateDeleteOperatorDescriptor(
                 spec, ordersDesc, storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, null, secondaryFieldPermutation, IndexOperation.INSERT,
-                rtreeDataflowHelperFactory, null, NoOpOperationCallbackFactory.INSTANCE);
+                rtreeDataflowHelperFactory, null, NoOpOperationCallbackFactory.INSTANCE, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondaryInsertOp, NC1_ID);
 
         NullSinkOperatorDescriptor nullSink = new NullSinkOperatorDescriptor(spec);
@@ -380,7 +384,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
     protected void destroyPrimaryIndex() throws Exception {
         JobSpecification spec = new JobSpecification();
         IndexDropOperatorDescriptor primaryDropOp = new IndexDropOperatorDescriptor(spec, storageManager,
-                lcManagerProvider, primarySplitProvider, btreeDataflowHelperFactory);
+                lcManagerProvider, primarySplitProvider, btreeDataflowHelperFactory, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primaryDropOp, NC1_ID);
         spec.addRoot(primaryDropOp);
         runTest(spec);
@@ -389,7 +393,7 @@ public abstract class AbstractRTreeOperatorTest extends AbstractIntegrationTest
     protected void destroySecondaryIndex() throws Exception {
         JobSpecification spec = new JobSpecification();
         IndexDropOperatorDescriptor secondaryDropOp = new IndexDropOperatorDescriptor(spec, storageManager,
-                lcManagerProvider, secondarySplitProvider, rtreeDataflowHelperFactory);
+                lcManagerProvider, secondarySplitProvider, rtreeDataflowHelperFactory, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondaryDropOp, NC1_ID);
         spec.addRoot(secondaryDropOp);
         runTest(spec);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexInsertOperatorTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexInsertOperatorTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexInsertOperatorTest.java
index 13a00f5..83318ce 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexInsertOperatorTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexInsertOperatorTest.java
@@ -40,6 +40,7 @@ import org.apache.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescripto
 import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
 import org.apache.hyracks.storage.am.common.api.TreeIndexException;
 import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
+import org.apache.hyracks.storage.am.common.freepage.LinkedMetadataPageManagerFactory;
 import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallbackFactory;
 import org.apache.hyracks.storage.am.rtree.dataflow.RTreeSearchOperatorDescriptor;
 import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
@@ -89,7 +90,7 @@ public class RTreeSecondaryIndexInsertOperatorTest extends AbstractRTreeOperator
         RTreeSearchOperatorDescriptor secondarySearchOp = new RTreeSearchOperatorDescriptor(spec, secondaryRecDesc,
                 storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, keyFields, rtreeDataflowHelperFactory, false, false, null,
-                NoOpOperationCallbackFactory.INSTANCE, null, null);
+                NoOpOperationCallbackFactory.INSTANCE, null, null, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondarySearchOp, NC1_ID);
         // fifth field from the tuples coming from secondary index
         int[] primaryLowKeyFields = { 4 };
@@ -99,7 +100,7 @@ public class RTreeSecondaryIndexInsertOperatorTest extends AbstractRTreeOperator
         BTreeSearchOperatorDescriptor primarySearchOp = new BTreeSearchOperatorDescriptor(spec, primaryRecDesc,
                 storageManager, lcManagerProvider, primarySplitProvider, primaryTypeTraits, primaryComparatorFactories,
                 null, primaryLowKeyFields, primaryHighKeyFields, true, true, btreeDataflowHelperFactory, false, false,
-                null, NoOpOperationCallbackFactory.INSTANCE, null, null);
+                null, NoOpOperationCallbackFactory.INSTANCE, null, null, new LinkedMetadataPageManagerFactory());
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primarySearchOp, NC1_ID);
         IFileSplitProvider outSplits = new ConstantFileSplitProvider(new FileSplit[] { createFile(nc1) });
         IOperatorDescriptor printer = new PlainFileWriterOperatorDescriptor(spec, outSplits, ",");

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexScanOperatorTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexScanOperatorTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexScanOperatorTest.java
index 2890b0b..3b42f55 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexScanOperatorTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexScanOperatorTest.java
@@ -86,7 +86,7 @@ public class RTreeSecondaryIndexScanOperatorTest extends AbstractRTreeOperatorTe
         RTreeSearchOperatorDescriptor secondarySearchOp = new RTreeSearchOperatorDescriptor(spec, secondaryRecDesc,
                 storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, keyFields, rtreeDataflowHelperFactory, false, false, null,
-                NoOpOperationCallbackFactory.INSTANCE, null, null);
+                NoOpOperationCallbackFactory.INSTANCE, null, null, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondarySearchOp, NC1_ID);
         IFileSplitProvider outSplits = new ConstantFileSplitProvider(new FileSplit[] { createFile(nc1) });
         IOperatorDescriptor printer = new PlainFileWriterOperatorDescriptor(spec, outSplits, ",");

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexSearchOperatorTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexSearchOperatorTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexSearchOperatorTest.java
index 9e40588..7c2676d 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexSearchOperatorTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexSearchOperatorTest.java
@@ -40,6 +40,7 @@ import org.apache.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescripto
 import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
 import org.apache.hyracks.storage.am.common.api.TreeIndexException;
 import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
+import org.apache.hyracks.storage.am.common.freepage.LinkedMetadataPageManagerFactory;
 import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallbackFactory;
 import org.apache.hyracks.storage.am.rtree.dataflow.RTreeSearchOperatorDescriptor;
 import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
@@ -87,7 +88,7 @@ public class RTreeSecondaryIndexSearchOperatorTest extends AbstractRTreeOperator
         RTreeSearchOperatorDescriptor secondarySearchOp = new RTreeSearchOperatorDescriptor(spec, secondaryRecDesc,
                 storageManager, lcManagerProvider, secondarySplitProvider, secondaryTypeTraits,
                 secondaryComparatorFactories, keyFields, rtreeDataflowHelperFactory, false, false, null,
-                NoOpOperationCallbackFactory.INSTANCE, null, null);
+                NoOpOperationCallbackFactory.INSTANCE, null, null, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondarySearchOp, NC1_ID);
         // fifth field from the tuples coming from secondary index
         int[] primaryLowKeyFields = { 4 };
@@ -97,7 +98,7 @@ public class RTreeSecondaryIndexSearchOperatorTest extends AbstractRTreeOperator
         BTreeSearchOperatorDescriptor primarySearchOp = new BTreeSearchOperatorDescriptor(spec, primaryRecDesc,
                 storageManager, lcManagerProvider, primarySplitProvider, primaryTypeTraits, primaryComparatorFactories,
                 null, primaryLowKeyFields, primaryHighKeyFields, true, true, btreeDataflowHelperFactory, false, false,
-                null, NoOpOperationCallbackFactory.INSTANCE, null, null);
+                null, NoOpOperationCallbackFactory.INSTANCE, null, null, new LinkedMetadataPageManagerFactory());
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, primarySearchOp, NC1_ID);
         IFileSplitProvider outSplits = new ConstantFileSplitProvider(new FileSplit[] { createFile(nc1) });
         IOperatorDescriptor printer = new PlainFileWriterOperatorDescriptor(spec, outSplits, ",");

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexStatsOperatorTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexStatsOperatorTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexStatsOperatorTest.java
index 9d4b16d..a9e2997 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexStatsOperatorTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/am/rtree/RTreeSecondaryIndexStatsOperatorTest.java
@@ -57,7 +57,7 @@ public class RTreeSecondaryIndexStatsOperatorTest extends AbstractRTreeOperatorT
         JobSpecification spec = new JobSpecification();
         TreeIndexStatsOperatorDescriptor secondaryStatsOp = new TreeIndexStatsOperatorDescriptor(spec, storageManager,
                 lcManagerProvider, secondarySplitProvider, secondaryTypeTraits, secondaryComparatorFactories, null,
-                rtreeDataflowHelperFactory, NoOpOperationCallbackFactory.INSTANCE);
+                rtreeDataflowHelperFactory, NoOpOperationCallbackFactory.INSTANCE, pageManagerFactory);
         PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, secondaryStatsOp, NC1_ID);
         IFileSplitProvider outSplits = new ConstantFileSplitProvider(new FileSplit[] { createFile(nc1) });
         IOperatorDescriptor printer = new PlainFileWriterOperatorDescriptor(spec, outSplits, ",");

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java b/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
index ed65902..80c3628 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
@@ -149,7 +149,6 @@ public class BloomFilter {
         if (isActivated) {
             return;
         }
-
         prepareFile();
         readBloomFilterMetaData();
         isActivated = true;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
index 72734d3..82333a9 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
@@ -30,6 +30,7 @@ import org.apache.hyracks.storage.am.common.dataflow.AbstractTreeIndexOperatorDe
 import org.apache.hyracks.storage.am.common.dataflow.IIndexOperatorDescriptor;
 import org.apache.hyracks.storage.am.common.dataflow.TreeIndexDataflowHelper;
 import org.apache.hyracks.storage.am.common.util.IndexFileNameUtil;
+import org.apache.hyracks.storage.common.buffercache.IBufferCache;
 
 public class BTreeDataflowHelper extends TreeIndexDataflowHelper {
 
@@ -44,9 +45,11 @@ public class BTreeDataflowHelper extends TreeIndexDataflowHelper {
         try {
             FileReference fileRef = IndexFileNameUtil.getIndexAbsoluteFileRef(treeOpDesc, ctx.getTaskAttemptId()
                     .getTaskId().getPartition(), ctx.getIOManager());
-            return BTreeUtils.createBTree(opDesc.getStorageManager().getBufferCache(ctx), opDesc.getStorageManager()
+            IBufferCache bufferCache = opDesc.getStorageManager().getBufferCache(ctx);
+            return BTreeUtils.createBTree(bufferCache, opDesc.getStorageManager()
                     .getFileMapProvider(ctx), treeOpDesc.getTreeIndexTypeTraits(), treeOpDesc
-                            .getTreeIndexComparatorFactories(), BTreeLeafFrameType.REGULAR_NSM, fileRef);
+                            .getTreeIndexComparatorFactories(), BTreeLeafFrameType.REGULAR_NSM, fileRef,
+                    pageManagerFactory.createPageManager(bufferCache));
         } catch (BTreeException e) {
             throw new HyracksDataException(e);
         }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
index 9721097..1c815bf 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
@@ -30,6 +30,7 @@ import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
 import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
 import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
+import org.apache.hyracks.storage.am.common.api.IPageManagerFactory;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
 import org.apache.hyracks.storage.am.common.dataflow.AbstractTreeIndexOperatorDescriptor;
 import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
@@ -55,11 +56,11 @@ public class BTreeSearchOperatorDescriptor extends AbstractTreeIndexOperatorDesc
             int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
             IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainMissing,
             IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchOpCallbackProvider,
-            int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes) {
+            int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes, IPageManagerFactory pageManagerFactory) {
         super(spec, 1, 1, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
                 comparatorFactories, bloomFilterKeyFields, dataflowHelperFactory, null, retainInput, retainMissing,
                 missingWriterFactory, NoOpLocalResourceFactoryProvider.INSTANCE, searchOpCallbackProvider,
-                NoOpOperationCallbackFactory.INSTANCE);
+                NoOpOperationCallbackFactory.INSTANCE, pageManagerFactory);
         this.lowKeyFields = lowKeyFields;
         this.highKeyFields = highKeyFields;
         this.lowKeyInclusive = lowKeyInclusive;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeUpdateSearchOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeUpdateSearchOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeUpdateSearchOperatorDescriptor.java
index bd64174..00cf356 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeUpdateSearchOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeUpdateSearchOperatorDescriptor.java
@@ -29,6 +29,7 @@ import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
 import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
 import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
+import org.apache.hyracks.storage.am.common.api.IPageManagerFactory;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
 import org.apache.hyracks.storage.am.common.api.ITupleUpdaterFactory;
 import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
@@ -46,10 +47,12 @@ public class BTreeUpdateSearchOperatorDescriptor extends BTreeSearchOperatorDesc
             IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] lowKeyFields,
             int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
             IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput,
-            ISearchOperationCallbackFactory searchOpCallbackProvider, ITupleUpdaterFactory tupleUpdaterFactory) {
+            ISearchOperationCallbackFactory searchOpCallbackProvider, ITupleUpdaterFactory tupleUpdaterFactory,
+            IPageManagerFactory pageManagerFactory) {
         super(spec, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
                 comparatorFactories, bloomFilterKeyFields, lowKeyFields, highKeyFields, lowKeyInclusive,
-                highKeyInclusive, dataflowHelperFactory, retainInput, false, null, searchOpCallbackProvider, null, null);
+                highKeyInclusive, dataflowHelperFactory, retainInput, false, null, searchOpCallbackProvider, null,
+                null, pageManagerFactory);
         this.tupleUpdaterFactory = tupleUpdaterFactory;
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
index 258a5d6..73447dd 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
@@ -145,8 +145,9 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
                 framePrefixTuple.resetByTupleIndex(this, i);
                 int end = framePrefixTuple.getFieldStart(framePrefixTuple.getFieldCount() - 1)
                         + framePrefixTuple.getFieldLength(framePrefixTuple.getFieldCount() - 1);
-                if (end > max)
+                if (end > max) {
                     max = end;
+                }
             }
 
             framePrefixTuple.resetByTupleIndex(this, prefixTupleCount - 1);
@@ -154,7 +155,7 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
                     + framePrefixTuple.getFieldLength(framePrefixTuple.getFieldCount() - 1);
         }
 
-        ArrayList<SlotOffTupleOff> sortedTupleOffs = new ArrayList<SlotOffTupleOff>();
+        ArrayList<SlotOffTupleOff> sortedTupleOffs = new ArrayList<>();
         sortedTupleOffs.ensureCapacity(tupleCount);
         for (int i = 0; i < tupleCount; i++) {
             int tupleSlotOff = slotManager.getTupleSlotOff(i);
@@ -226,12 +227,14 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
         int bytesRequired = tupleWriter.bytesRequired(tuple);
 
         // See if the tuple would fit uncompressed.
-        if (bytesRequired + slotManager.getSlotSize() <= freeContiguous)
+        if (bytesRequired + slotManager.getSlotSize() <= freeContiguous) {
             return FrameOpSpaceStatus.SUFFICIENT_CONTIGUOUS_SPACE;
+        }
 
         // See if tuple would fit into remaining space after compaction.
-        if (bytesRequired + slotManager.getSlotSize() <= buf.getInt(totalFreeSpaceOff))
+        if (bytesRequired + slotManager.getSlotSize() <= buf.getInt(totalFreeSpaceOff)) {
             return FrameOpSpaceStatus.SUFFICIENT_SPACE;
+        }
 
         // See if the tuple matches a prefix and will fit after truncating the prefix.
         int prefixSlotNum = slotManager.findPrefix(tuple, framePrefixTuple);
@@ -242,8 +245,9 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
 
             int compressedSize = tupleWriter.bytesRequired(tuple, numPrefixFields, tuple.getFieldCount()
                     - numPrefixFields);
-            if (compressedSize + slotManager.getSlotSize() <= freeContiguous)
+            if (compressedSize + slotManager.getSlotSize() <= freeContiguous) {
                 return FrameOpSpaceStatus.SUFFICIENT_CONTIGUOUS_SPACE;
+            }
         }
 
         return FrameOpSpaceStatus.INSUFFICIENT_SPACE;
@@ -475,6 +479,7 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
         return buf.getInt(tupleCountOff);
     }
 
+    @Override
     public IPrefixSlotManager getSlotManager() {
         return slotManager;
     }
@@ -528,10 +533,11 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
 
     @Override
     public void setSmFlag(boolean smFlag) {
-        if (smFlag)
+        if (smFlag) {
             buf.put(smFlagOff, (byte) 1);
-        else
+        } else {
             buf.put(smFlagOff, (byte) 0);
+        }
     }
 
     @Override
@@ -570,10 +576,11 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
 
         // insert slot
         int prefixSlotNum = FieldPrefixSlotManager.TUPLE_UNCOMPRESSED;
-        if (fieldsToTruncate > 0)
+        if (fieldsToTruncate > 0) {
             prefixSlotNum = buf.getInt(prefixTupleCountOff) - 1;
-        else
+        } else {
             buf.putInt(uncompressedTupleCountOff, buf.getInt(uncompressedTupleCountOff) + 1);
+        }
         int insSlot = slotManager.encodeSlotFields(prefixSlotNum, FieldPrefixSlotManager.GREATEST_KEY_INDICATOR);
         slotManager.insertSlot(insSlot, freeSpace);
 
@@ -754,6 +761,7 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
         return slotManager.getSlotSize();
     }
 
+    @Override
     public ITreeIndexTupleWriter getTupleWriter() {
         return tupleWriter;
     }
@@ -770,10 +778,11 @@ public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
         int tupleIndex = slotManager.decodeSecondSlotField(slot);
         // TODO: Revisit this one. Maybe there is a cleaner way to solve this in the RangeSearchCursor.
         if (tupleIndex == FieldPrefixSlotManager.GREATEST_KEY_INDICATOR
-                || tupleIndex == FieldPrefixSlotManager.ERROR_INDICATOR)
+                || tupleIndex == FieldPrefixSlotManager.ERROR_INDICATOR) {
             return -1;
-        else
+        } else {
             return tupleIndex;
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
index 5995004..b6a64fa 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
@@ -43,8 +43,8 @@ import org.apache.hyracks.storage.am.btree.impls.BTreeOpContext.PageValidationIn
 import org.apache.hyracks.storage.am.common.api.IIndexAccessor;
 import org.apache.hyracks.storage.am.common.api.IIndexBulkLoader;
 import org.apache.hyracks.storage.am.common.api.IIndexCursor;
-import org.apache.hyracks.storage.am.common.api.IMetaDataPageManager;
 import org.apache.hyracks.storage.am.common.api.IModificationOperationCallback;
+import org.apache.hyracks.storage.am.common.api.IPageManager;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallback;
 import org.apache.hyracks.storage.am.common.api.ISearchPredicate;
 import org.apache.hyracks.storage.am.common.api.ISplitKey;
@@ -83,7 +83,7 @@ public class BTree extends AbstractTreeIndex {
     private final ReadWriteLock treeLatch;
     private final int maxTupleSize;
 
-    public BTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider, IMetaDataPageManager freePageManager,
+    public BTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider, IPageManager freePageManager,
             ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory leafFrameFactory,
             IBinaryComparatorFactory[] cmpFactories, int fieldCount, FileReference file) {
         super(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory, cmpFactories,
@@ -100,7 +100,7 @@ public class BTree extends AbstractTreeIndex {
         TreeIndexDiskOrderScanCursor cursor = (TreeIndexDiskOrderScanCursor) icursor;
         ctx.reset();
         RangePredicate diskOrderScanPred = new RangePredicate(null, null, true, true, ctx.cmp, ctx.cmp);
-        int maxPageId = freePageManager.getMaxPage(ctx.metaFrame);
+        int maxPageId = freePageManager.getMaxPageId(ctx.metaFrame);
         int currentPageId = bulkloadLeafStart;
         ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId), false);
         page.acquireReadLatch();
@@ -120,6 +120,7 @@ public class BTree extends AbstractTreeIndex {
         }
     }
 
+    @Override
     public void validate() throws HyracksDataException {
         // Stack validation protocol:
         //      * parent pushes the validation information onto the stack before validation
@@ -246,7 +247,7 @@ public class BTree extends AbstractTreeIndex {
                 false);
         leftNode.acquireWriteLatch();
         try {
-            int newLeftId = freePageManager.getFreePage(ctx.metaFrame);
+            int newLeftId = freePageManager.takePage(ctx.metaFrame);
             ICachedPage newLeftNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, newLeftId), true);
             newLeftNode.acquireWriteLatch();
             try {
@@ -371,7 +372,7 @@ public class BTree extends AbstractTreeIndex {
                 // TODO: avoid repeated calculation of tuple size
                 ctx.leafFrame.ensureCapacity(bufferCache, tuple, ctx);
             }
-                // fall-through
+            // fall-through
             case SUFFICIENT_CONTIGUOUS_SPACE: {
                 ctx.modificationCallback.found(null, tuple);
                 ctx.leafFrame.insert(tuple, targetTupleIndex);
@@ -428,7 +429,7 @@ public class BTree extends AbstractTreeIndex {
                 return true;
             }
         }
-        int rightPageId = freePageManager.getFreePage(ctx.metaFrame);
+        int rightPageId = freePageManager.takePage(ctx.metaFrame);
         ICachedPage rightNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rightPageId), true);
         rightNode.acquireWriteLatch();
         try {
@@ -545,13 +546,13 @@ public class BTree extends AbstractTreeIndex {
         FrameOpSpaceStatus spaceStatus = ctx.interiorFrame.hasSpaceInsert(tuple);
         switch (spaceStatus) {
             case INSUFFICIENT_SPACE: {
-                int rightPageId = freePageManager.getFreePage(ctx.metaFrame);
+                int rightPageId = freePageManager.takePage(ctx.metaFrame);
                 ICachedPage rightNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rightPageId), true);
                 rightNode.acquireWriteLatch();
                 try {
                     IBTreeFrame rightFrame = ctx.createInteriorFrame();
                     rightFrame.setPage(rightNode);
-                    rightFrame.initBuffer((byte) ctx.interiorFrame.getLevel());
+                    rightFrame.initBuffer(ctx.interiorFrame.getLevel());
                     rightFrame.setMultiComparator(ctx.cmp);
                     // instead of creating a new split key, use the existing
                     // splitKey
@@ -815,7 +816,6 @@ public class BTree extends AbstractTreeIndex {
             }
             throw e;
         } catch (Exception e) {
-            e.printStackTrace();
             if (node != null) {
                 if (isReadLatched) {
                     node.releaseReadLatch();
@@ -887,7 +887,6 @@ public class BTree extends AbstractTreeIndex {
         } catch (Exception e) {
             node.releaseReadLatch();
             bufferCache.unpin(node);
-            e.printStackTrace();
         }
     }
 
@@ -994,13 +993,8 @@ public class BTree extends AbstractTreeIndex {
     @Override
     public IIndexBulkLoader createBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
             boolean checkIfEmptyIndex) throws TreeIndexException {
-        return createBulkLoader(fillFactor, verifyInput, numElementsHint, checkIfEmptyIndex, false);
-    }
-
-    public IIndexBulkLoader createBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
-            boolean checkIfEmptyIndex, boolean appendOnly) throws TreeIndexException {
         try {
-            return new BTreeBulkLoader(fillFactor, verifyInput, appendOnly);
+            return new BTreeBulkLoader(fillFactor, verifyInput);
         } catch (HyracksDataException e) {
             throw new TreeIndexException(e);
         }
@@ -1010,9 +1004,9 @@ public class BTree extends AbstractTreeIndex {
         protected final ISplitKey splitKey;
         protected final boolean verifyInput;
 
-        public BTreeBulkLoader(float fillFactor, boolean verifyInput, boolean appendOnly)
+        public BTreeBulkLoader(float fillFactor, boolean verifyInput)
                 throws TreeIndexException, HyracksDataException {
-            super(fillFactor, appendOnly);
+            super(fillFactor);
             this.verifyInput = verifyInput;
             splitKey = new BTreeSplitKey(leafFrame.getTupleWriter().createTupleReference());
             splitKey.getTuple().setFieldCount(cmp.getKeyFieldCount());
@@ -1052,7 +1046,7 @@ public class BTree extends AbstractTreeIndex {
 
                         propagateBulk(1, pagesToWrite);
 
-                        leafFrontier.pageId = freePageManager.getFreePage(metaFrame);
+                        leafFrontier.pageId = freePageManager.takePage(metaFrame);
 
                         ((IBTreeLeafFrame) leafFrame).setNextLeaf(leafFrontier.pageId);
 
@@ -1072,7 +1066,7 @@ public class BTree extends AbstractTreeIndex {
                                 .ceil((double) tupleSize / (bufferCache.getPageSize() - headerSize));
                         if (multiplier > 1) {
                             leafFrontier.page = bufferCache.confiscateLargePage(dpid, multiplier,
-                                    freePageManager.getFreePageBlock(metaFrame, multiplier - 1));
+                                    freePageManager.takeBlock(metaFrame, multiplier - 1));
                         } else {
                             leafFrontier.page = bufferCache.confiscatePage(dpid);
                         }
@@ -1112,11 +1106,13 @@ public class BTree extends AbstractTreeIndex {
 
         protected void propagateBulk(int level, List<ICachedPage> pagesToWrite)
                 throws HyracksDataException, TreeIndexException {
-            if (splitKey.getBuffer() == null)
+            if (splitKey.getBuffer() == null) {
                 return;
+            }
 
-            if (level >= nodeFrontiers.size())
+            if (level >= nodeFrontiers.size()) {
                 addLevel();
+            }
 
             NodeFrontier frontier = nodeFrontiers.get(level);
             interiorFrame.setPage(frontier.page);
@@ -1144,7 +1140,7 @@ public class BTree extends AbstractTreeIndex {
                 splitKey.getTuple().resetByTupleOffset(splitKey.getBuffer(), 0);
 
                 ((IBTreeInteriorFrame) interiorFrame).deleteGreatest();
-                int finalPageId = freePageManager.getFreePage(metaFrame);
+                int finalPageId = freePageManager.takePage(metaFrame);
                 bufferCache.setPageDiskId(frontier.page, BufferedFileHandle.getDiskPageId(fileId, finalPageId));
                 pagesToWrite.add(frontier.page);
                 splitKey.setLeftPage(finalPageId);
@@ -1159,10 +1155,7 @@ public class BTree extends AbstractTreeIndex {
 
         private void persistFrontiers(int level, int rightPage) throws HyracksDataException {
             if (level >= nodeFrontiers.size()) {
-                //at root
-                if (appendOnly) {
-                    rootPage = nodeFrontiers.get(level - 1).pageId;
-                }
+                rootPage = nodeFrontiers.get(level - 1).pageId;
                 releasedLatches = true;
                 return;
             }
@@ -1183,7 +1176,7 @@ public class BTree extends AbstractTreeIndex {
                         "Error in index creation. Internal node appears to have no rightmost guide");
             }
             ((IBTreeInteriorFrame) interiorFrame).setRightmostChildPageId(rightPage);
-            int finalPageId = freePageManager.getFreePage(metaFrame);
+            int finalPageId = freePageManager.takePage(metaFrame);
             setPageDpid(frontier.page, finalPageId);
             queue.put(frontier.page);
             frontier.pageId = finalPageId;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeOpContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeOpContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeOpContext.java
index f894c70..3de9a0c 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeOpContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeOpContext.java
@@ -31,9 +31,9 @@ import org.apache.hyracks.dataflow.common.util.TupleUtils;
 import org.apache.hyracks.storage.am.btree.api.IBTreeInteriorFrame;
 import org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame;
 import org.apache.hyracks.storage.am.btree.api.ITupleAcceptor;
+import org.apache.hyracks.storage.am.common.api.IPageManager;
 import org.apache.hyracks.storage.am.common.api.IIndexAccessor;
 import org.apache.hyracks.storage.am.common.api.IIndexOperationContext;
-import org.apache.hyracks.storage.am.common.api.IMetaDataPageManager;
 import org.apache.hyracks.storage.am.common.api.IModificationOperationCallback;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallback;
 import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor;
@@ -55,7 +55,7 @@ public class BTreeOpContext implements IIndexOperationContext, IExtraPageBlockHe
     public ITreeIndexFrameFactory interiorFrameFactory;
     public IBTreeLeafFrame leafFrame;
     public IBTreeInteriorFrame interiorFrame;
-    public final IMetaDataPageManager freePageManager;
+    public final IPageManager freePageManager;
     public final ITreeIndexMetaDataFrame metaFrame;
     public IndexOperation op;
     public ITreeIndexCursor cursor;
@@ -78,7 +78,7 @@ public class BTreeOpContext implements IIndexOperationContext, IExtraPageBlockHe
     public final ITreeIndexTupleReference leafFrameTuple;
 
     public BTreeOpContext(IIndexAccessor accessor, ITreeIndexFrameFactory leafFrameFactory,
-                          ITreeIndexFrameFactory interiorFrameFactory, IMetaDataPageManager freePageManager,
+            ITreeIndexFrameFactory interiorFrameFactory, IPageManager freePageManager,
                           IBinaryComparatorFactory[] cmpFactories, IModificationOperationCallback modificationCallback,
                           ISearchOperationCallback searchCallback) {
         this.accessor = accessor;
@@ -101,25 +101,29 @@ public class BTreeOpContext implements IIndexOperationContext, IExtraPageBlockHe
             interiorFrame.setMultiComparator(cmp);
         }
         this.freePageManager = freePageManager;
-        this.metaFrame = freePageManager.getMetaDataFrameFactory().createFrame();
+        this.metaFrame = freePageManager.createMetadataFrame();
         this.pageLsns = new LongArrayList(INIT_ARRAYLIST_SIZE, INIT_ARRAYLIST_SIZE);
         this.smoCount = 0;
         this.modificationCallback = modificationCallback;
         this.searchCallback = searchCallback;
 
         // Debug
-        this.validationInfos = new ArrayDeque<PageValidationInfo>(INIT_ARRAYLIST_SIZE);
+        this.validationInfos = new ArrayDeque<>(INIT_ARRAYLIST_SIZE);
         this.interiorFrameTuple = interiorFrame.createTupleReference();
         this.leafFrameTuple = leafFrame.createTupleReference();
     }
 
+    @Override
     public void reset() {
-        if (pageLsns != null)
+        if (pageLsns != null) {
             pageLsns.clear();
-        if (freePages != null)
+        }
+        if (freePages != null) {
             freePages.clear();
-        if (smPages != null)
+        }
+        if (smPages != null) {
             smPages.clear();
+        }
         opRestarts = 0;
         smoCount = 0;
         exceptionHandled = false;
@@ -240,11 +244,11 @@ public class BTreeOpContext implements IIndexOperationContext, IExtraPageBlockHe
 
     @Override
     public int getFreeBlock(int size) throws HyracksDataException {
-        return freePageManager.getFreePageBlock(metaFrame, size);
+        return freePageManager.takeBlock(metaFrame, size);
     }
 
     @Override
     public void returnFreePageBlock(int blockPageId, int size) throws HyracksDataException {
-        freePageManager.addFreePageBlock(metaFrame, blockPageId, size);
+        freePageManager.releaseBlock(metaFrame, blockPageId, size);
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/util/BTreeUtils.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/util/BTreeUtils.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/util/BTreeUtils.java
index 7c2abb1..37e15b4 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/util/BTreeUtils.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/util/BTreeUtils.java
@@ -29,12 +29,9 @@ import org.apache.hyracks.storage.am.btree.frames.BTreeLeafFrameType;
 import org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory;
 import org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory;
 import org.apache.hyracks.storage.am.btree.impls.BTree;
-import org.apache.hyracks.storage.am.common.api.IMetaDataPageManager;
+import org.apache.hyracks.storage.am.common.api.IPageManager;
 import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexMetaDataFrameFactory;
 import org.apache.hyracks.storage.am.common.api.ITreeIndexTupleWriterFactory;
-import org.apache.hyracks.storage.am.common.frames.LIFOMetaDataFrameFactory;
-import org.apache.hyracks.storage.am.common.freepage.LinkedMetaDataPageManager;
 import org.apache.hyracks.storage.am.common.ophelpers.MultiComparator;
 import org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory;
 import org.apache.hyracks.storage.common.buffercache.IBufferCache;
@@ -43,19 +40,16 @@ import org.apache.hyracks.storage.common.file.IFileMapProvider;
 public class BTreeUtils {
     public static BTree createBTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
             ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories, BTreeLeafFrameType leafType,
-            FileReference file) throws BTreeException {
+            FileReference file, IPageManager freePageManager) throws BTreeException {
         TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(typeTraits);
         ITreeIndexFrameFactory leafFrameFactory = getLeafFrameFactory(tupleWriterFactory, leafType);
         ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
-        ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
-        IMetaDataPageManager freePageManager;
-        freePageManager = new LinkedMetaDataPageManager(bufferCache, metaFrameFactory);
         BTree btree = new BTree(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory,
                 cmpFactories, typeTraits.length, file);
         return btree;
     }
 
-    public static BTree createBTree(IBufferCache bufferCache, IMetaDataPageManager freePageManager,
+    public static BTree createBTree(IBufferCache bufferCache, IPageManager freePageManager,
             IFileMapProvider fileMapProvider, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
             BTreeLeafFrameType leafType, FileReference file) throws BTreeException {
         TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(typeTraits);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndex.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndex.java
index be68903..884318e 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndex.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndex.java
@@ -127,9 +127,6 @@ public interface IIndex {
     public IIndexBulkLoader createBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
             boolean checkIfEmptyIndex) throws IndexException;
 
-    public IIndexBulkLoader createBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
-            boolean checkIfEmptyIndex, boolean appendOnly) throws IndexException;
-
     /**
      * @return true if the index needs memory components
      */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetaDataPageManager.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetaDataPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetaDataPageManager.java
deleted file mode 100644
index 5d87f99..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetaDataPageManager.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.storage.am.common.api;
-
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.storage.common.buffercache.ICachedPage;
-
-public interface IMetaDataPageManager {
-    public static final long INVALID_LSN_OFFSET = -1;
-
-    /**
-     * This is the class through which one interfaces with index metadata.
-     * The index metadata contains information such as the LSN of the index, free page information,
-     * and filter page locations.
-     */
-    /**
-     * Open an index file's metadata
-     *
-     * @param fileId
-     *            The file which to open the metadata of
-     */
-    public void open(int fileId);
-
-    /**
-     * Close an index file's metadata.
-     *
-     * @throws HyracksDataException
-     */
-
-    public void close() throws HyracksDataException;
-
-    /**
-     * Get the location of a free page to use for index operations
-     *
-     * @param metaFrame
-     *            A metadata frame to use to wrap the raw page
-     * @return A page location, or -1 if no free page could be found or allocated
-     * @throws HyracksDataException
-     */
-
-    public int getFreePage(ITreeIndexMetaDataFrame metaFrame) throws HyracksDataException;
-
-    /**
-     * Get the location of a block of free pages to use for index operations
-     *
-     * @param metaFrame
-     *            A metadata frame to use to wrap the raw page
-     * @return The starting page location, or -1 if a block of free pages could be found or allocated
-     * @throws HyracksDataException
-     */
-
-    public int getFreePageBlock(ITreeIndexMetaDataFrame metaFrame, int count) throws HyracksDataException;
-
-    /**
-     * Add a page back to the pool of free pages within an index file
-     *
-     * @param metaFrame
-     *            A metadata frame to use to wrap the raw page
-     * @param freePage
-     *            The page which to return to the free space
-     * @throws HyracksDataException
-     */
-
-    public void addFreePage(ITreeIndexMetaDataFrame metaFrame, int freePage) throws HyracksDataException;
-
-    public void addFreePageBlock(ITreeIndexMetaDataFrame metaFrame, int startingPage, int count)
-            throws HyracksDataException;
-
-    /**
-     * Gets the highest page offset according to the metadata
-     *
-     * @param metaFrame
-     *            A metadata frame to use to wrap the raw page
-     * @return The locaiton of the highest offset page
-     * @throws HyracksDataException
-     */
-
-    public int getMaxPage(ITreeIndexMetaDataFrame metaFrame) throws HyracksDataException;
-
-    /**
-     * Initializes the index metadata
-     *
-     * @param metaFrame
-     *            A metadata farme to use to wrap the raw page
-     * @param currentMaxPage
-     *            The highest page offset to consider valid
-     * @throws HyracksDataException
-     */
-
-    public void init(ITreeIndexMetaDataFrame metaFrame, int currentMaxPage) throws HyracksDataException;
-
-    public ITreeIndexMetaDataFrameFactory getMetaDataFrameFactory();
-
-    // required to return negative values
-    public byte getMetaPageLevelIndicator();
-
-    public byte getFreePageLevelIndicator();
-
-    // determined by examining level indicator
-
-    public boolean isMetaPage(ITreeIndexMetaDataFrame metaFrame);
-
-    public boolean isFreePage(ITreeIndexMetaDataFrame metaFrame);
-
-    /**
-     * Determines where the metadata page is located in an index file
-     *
-     * @return The locaiton of the metadata page, or -1 if the file appears to be corrupt
-     * @throws HyracksDataException
-     */
-
-    public int getFirstMetadataPage() throws HyracksDataException;
-
-    /**
-     * Initializes the metadata manager on an open index file
-     *
-     * @param metaFrame
-     *            A metadata frame used to wrap the raw page
-     * @throws HyracksDataException
-     */
-
-    void init(ITreeIndexMetaDataFrame metaFrame) throws HyracksDataException;
-
-    /**
-     * Locate the filter page in an index file
-     *
-     * @return The offset of the filter page if it exists, or less than zero if no filter page exists yet
-     * @throws HyracksDataException
-     */
-
-    int getFilterPageId() throws HyracksDataException;
-
-    void setFilterPageId(int filterPageId) throws HyracksDataException;
-
-    long getLSN() throws HyracksDataException;
-
-    void setLSN(long lsn) throws HyracksDataException;
-
-    /**
-     * Set the cached page to manage for filter data
-     *
-     * @param page
-     *            The page to manage
-     */
-
-    void setFilterPage(ICachedPage page);
-
-    ICachedPage getFilterPage();
-
-    boolean appendOnlyMode();
-
-    /**
-     * @return The LSN byte offset in the LSM disk component if the index is valid, otherwise {@link #INVALID_LSN_OFFSET}.
-     * @throws HyracksDataException
-     */
-    long getLSNOffset() throws HyracksDataException;
-
-    public long getLastMarkerLSN() throws HyracksDataException;
-
-    void setRootPage(int rootPage) throws HyracksDataException;
-
-    int getRootPage() throws HyracksDataException;
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataManagerFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataManagerFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataManagerFactory.java
deleted file mode 100644
index e9dd674..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataManagerFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.storage.am.common.api;
-
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public interface IMetadataManagerFactory {
-    public IMetaDataPageManager createFreePageManager() throws HyracksDataException;
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManager.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManager.java
new file mode 100644
index 0000000..02390c8
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManager.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hyracks.storage.am.common.api;
+
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.storage.common.buffercache.ICachedPage;
+
+/**
+ * Used to read from and write to index metadata.
+ * The index metadata contains information such as:
+ * --The LSN of the index.
+ * --Free page information {Set of free pages}
+ * --Filter information.
+ * TODO: This interface needs to change to have calls to request memory space and write to those bytes
+ */
+public interface IMetadataPageManager extends IPageManager {
+    public static class Constants {
+        public static final long INVALID_LSN_OFFSET = -1;
+        private Constants() {
+        }
+    }
+
+    /**
+     * Locate the filter page in an index file
+     *
+     * @return The offset of the filter page if it exists, or less than zero if no filter page exists yet
+     * @throws HyracksDataException
+     */
+    int getFilterPageId() throws HyracksDataException;
+    void setFilterPageId(int filterPageId) throws HyracksDataException;
+    long getLSN() throws HyracksDataException;
+    void setLSN(long lsn) throws HyracksDataException;
+
+    /**
+     * Set the cached page to manage for filter data
+     *
+     * @param page
+     *            The page to manage
+     * @throws HyracksDataException
+     */
+    void setFilterPage(ICachedPage page) throws HyracksDataException;
+
+    /**
+     * Get filter page if exists, create and return a new one if it doesn't
+     * @return
+     * @throws HyracksDataException
+     */
+    ICachedPage getFilterPage() throws HyracksDataException;
+
+    /**
+     * @return The LSN byte offset in the LSM disk component if the index is valid,
+     *         otherwise {@link #INVALID_LSN_OFFSET}.
+     * @throws HyracksDataException
+     */
+    long getLSNOffset() throws HyracksDataException;
+    long getLastMarkerLSN() throws HyracksDataException;
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManagerFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManagerFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManagerFactory.java
new file mode 100644
index 0000000..78a80e7
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IMetadataPageManagerFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hyracks.storage.am.common.api;
+
+import org.apache.hyracks.storage.common.buffercache.IBufferCache;
+
+@FunctionalInterface
+public interface IMetadataPageManagerFactory extends IPageManagerFactory {
+    @Override
+    IMetadataPageManager createPageManager(IBufferCache bufferCache);
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManager.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManager.java
new file mode 100644
index 0000000..2aee403
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManager.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hyracks.storage.am.common.api;
+
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public interface IPageManager {
+
+    /**
+     * Open metadata of an index file
+     * Called on:
+     * 1. Index Create
+     * 2. Index Activate
+     *
+     * @param fileId
+     *            The index file id
+     * @throws HyracksDataException
+     */
+    void open(int fileId) throws HyracksDataException;
+
+    /**
+     * Close metadata of an index file. After this call returns, it is expected that the index pages have been written
+     * to disk. Called on:
+     * 1. Index Create
+     * 2. Index Deactivate
+     * 3. When we need to have a persisted state.
+     *
+     * Note: This method will not force indexes to disk driver using fsync
+     * @throws HyracksDataException
+     */
+    void close() throws HyracksDataException;
+
+    /**
+     * Create a metadata frame to be used for reading and writing to metadata pages
+     * @return a new metadata frame
+     */
+    ITreeIndexMetaDataFrame createMetadataFrame();
+
+    /**
+     * Determines where the main metadata page is located in an index file
+     *
+     * @return The locaiton of the metadata page, or -1 if the file appears to be corrupt
+     * @throws HyracksDataException
+     */
+    int getMetadataPageId() throws HyracksDataException;
+
+    /**
+     * Initializes the free page manager on an open index file.
+     * This method is only called once per an index file at the beginning of creating the index.
+     * It is expected that calling this method will initialize the state of an empty new index.
+     *
+     * @param leafFrameFactory
+     * @param interiorFrameFactory
+     * @param metaFrame
+     *            A metadata frame used to wrap the raw page
+     * @throws HyracksDataException
+     */
+    void init(ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory leafFrameFactory)
+            throws HyracksDataException;
+
+    /**
+     * Get the location of a free page to use for index operations
+     *
+     * @param frame
+     *            A metadata frame to use to wrap metadata pages
+     * @return A page location, or -1 if no free page could be found or allocated
+     * @throws HyracksDataException
+     */
+    int takePage(ITreeIndexMetaDataFrame frame) throws HyracksDataException;
+
+    /**
+     * Get the location of a block of free pages to use for index operations
+     * This is used for records that are larger than a normal page
+     * @param frame
+     *            A metadata frame to use to wrap metadata pages
+     * @return The starting page location, or -1 if a block of free pages could be found or allocated
+     * @throws HyracksDataException
+     */
+    int takeBlock(ITreeIndexMetaDataFrame frame, int count) throws HyracksDataException;
+
+    /**
+     * Add a page back to the pool of free pages within an index file
+     *
+     * @param frame
+     *            A metadata frame to use to wrap metadata pages
+     * @param page
+     *            The page to be returned to the set of free pages
+     * @throws HyracksDataException
+     */
+    void releasePage(ITreeIndexMetaDataFrame frame, int page) throws HyracksDataException;
+
+    /**
+     * Add a page back to the pool of free pages within an index file
+     * @param frame
+     *            A metadata frame to use to wrap metadata pages
+     * @param page
+     *            The start of the free pages block
+     * @param count
+     *            the number of regular sized pages in the free pages block
+     * @throws HyracksDataException
+     */
+    void releaseBlock(ITreeIndexMetaDataFrame frame, int page, int count) throws HyracksDataException;
+
+    /**
+     * Gets the highest page offset according to the metadata
+     *
+     * @param frame
+     *            A metadata frame to use to wrap metadata pages
+     * @return The locaiton of the highest offset page
+     * @throws HyracksDataException
+     */
+    int getMaxPageId(ITreeIndexMetaDataFrame frame) throws HyracksDataException;
+
+    /**
+     * Check whether the index is empty or not.
+     * @param frame
+     *            interior frame
+     * @param rootPage
+     *            the current root page
+     * @return true if empty, false otherwise
+     * @throws HyracksDataException
+     */
+    boolean isEmpty(ITreeIndexFrame frame, int rootPage) throws HyracksDataException;
+
+    /**
+     * Get the root page of the id
+     * @return the root page
+     * @throws HyracksDataException
+     */
+    int getRootPageId() throws HyracksDataException;
+
+    /**
+     * Get the first page to start the bulk load
+     * @return
+     * @throws HyracksDataException
+     */
+    int getBulkLoadLeaf() throws HyracksDataException;
+
+    /**
+     * Set the root page id and finalize the bulk load operation
+     * @param rootPage
+     * @throws HyracksDataException
+     */
+    void setRootPageId(int rootPage) throws HyracksDataException;
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManagerFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManagerFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManagerFactory.java
new file mode 100644
index 0000000..98fd4e5
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IPageManagerFactory.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hyracks.storage.am.common.api;
+
+import java.io.Serializable;
+
+import org.apache.hyracks.storage.common.buffercache.IBufferCache;
+
+@FunctionalInterface
+public interface IPageManagerFactory extends Serializable {
+    IPageManager createPageManager(IBufferCache bufferCache);
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndex.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndex.java
index a29f329..d1d5225 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndex.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndex.java
@@ -41,7 +41,7 @@ public interface ITreeIndex extends IIndex {
     /**
      * @return The index's free page manager.
      */
-    public IMetaDataPageManager getMetaManager();
+    public IPageManager getPageManager();
 
     /**
      * @return The number of fields tuples of this index have.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndexMetaDataFrame.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndexMetaDataFrame.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndexMetaDataFrame.java
index 653f6ae..f49972c 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndexMetaDataFrame.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/ITreeIndexMetaDataFrame.java
@@ -27,7 +27,7 @@ public interface ITreeIndexMetaDataFrame {
     // possible corruption from old versions reading new formats.
     int VERSION = 4;
 
-    public void initBuffer(byte level);
+    public void initBuffer();
 
     public void setPage(ICachedPage page);
 
@@ -37,7 +37,7 @@ public interface ITreeIndexMetaDataFrame {
 
     public void setLevel(byte level);
 
-    public int getNextPage();
+    public int getNextMetadataPage();
 
     public void setNextPage(int nextPage);
 
@@ -78,4 +78,8 @@ public interface ITreeIndexMetaDataFrame {
     void setRootPageNumber(int rootPage);
 
     int getRootPageNumber();
+
+    boolean isMetadataPage();
+
+    boolean isFreePage();
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IVirtualMetaDataPageManager.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IVirtualMetaDataPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IVirtualMetaDataPageManager.java
deleted file mode 100644
index 0073f59..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IVirtualMetaDataPageManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.storage.am.common.api;
-
-public interface IVirtualMetaDataPageManager extends IMetaDataPageManager {
-    public int getCapacity();
-
-    public void reset();
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
index ebe6383..d304883 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
@@ -26,6 +26,7 @@ import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescri
 import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
 import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
 import org.apache.hyracks.storage.am.common.api.IModificationOperationCallbackFactory;
+import org.apache.hyracks.storage.am.common.api.IPageManagerFactory;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
 import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
 import org.apache.hyracks.storage.common.IStorageManagerInterface;
@@ -41,6 +42,7 @@ public abstract class AbstractIndexOperatorDescriptor extends AbstractSingleActi
     protected final IIndexLifecycleManagerProvider lifecycleManagerProvider;
     protected final IIndexDataflowHelperFactory dataflowHelperFactory;
     protected final ITupleFilterFactory tupleFilterFactory;
+    protected final IPageManagerFactory pageManagerFactory;
     protected final boolean retainInput;
     protected final boolean retainNull;
     protected final IMissingWriterFactory nullWriterFactory;
@@ -55,7 +57,8 @@ public abstract class AbstractIndexOperatorDescriptor extends AbstractSingleActi
             boolean retainInput, boolean retainNull, IMissingWriterFactory nullWriterFactory,
             ILocalResourceFactoryProvider localResourceFactoryProvider,
             ISearchOperationCallbackFactory searchOpCallbackFactory,
-            IModificationOperationCallbackFactory modificationOpCallbackFactory) {
+            IModificationOperationCallbackFactory modificationOpCallbackFactory,
+            IPageManagerFactory pageManagerFactory) {
         super(spec, inputArity, outputArity);
         this.fileSplitProvider = fileSplitProvider;
         this.storageManager = storageManager;
@@ -68,6 +71,7 @@ public abstract class AbstractIndexOperatorDescriptor extends AbstractSingleActi
         this.localResourceFactoryProvider = localResourceFactoryProvider;
         this.searchOpCallbackFactory = searchOpCallbackFactory;
         this.modificationOpCallbackFactory = modificationOpCallbackFactory;
+        this.pageManagerFactory = pageManagerFactory;
         if (outputArity > 0) {
             recordDescriptors[0] = recDesc;
         }
@@ -132,4 +136,9 @@ public abstract class AbstractIndexOperatorDescriptor extends AbstractSingleActi
     public ILocalResourceFactoryProvider getLocalResourceFactoryProvider() {
         return localResourceFactoryProvider;
     }
+
+    @Override
+    public IPageManagerFactory getPageManagerFactory() {
+        return pageManagerFactory;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bc3d1b05/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
index 2020a15..9455d9e 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
@@ -27,6 +27,7 @@ import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
 import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
 import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
 import org.apache.hyracks.storage.am.common.api.IModificationOperationCallbackFactory;
+import org.apache.hyracks.storage.am.common.api.IPageManagerFactory;
 import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
 import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
 import org.apache.hyracks.storage.common.IStorageManagerInterface;
@@ -48,10 +49,12 @@ public abstract class AbstractTreeIndexOperatorDescriptor extends AbstractIndexO
             boolean retainInput, boolean retainNull, IMissingWriterFactory nullWriterFactory,
             ILocalResourceFactoryProvider localResourceFactoryProvider,
             ISearchOperationCallbackFactory searchOpCallbackFactory,
-            IModificationOperationCallbackFactory modificationOpCallbackFactory) {
+            IModificationOperationCallbackFactory modificationOpCallbackFactory,
+            IPageManagerFactory pageManagerFactory) {
         super(spec, inputArity, outputArity, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider,
                 dataflowHelperFactory, tupleFilterFactory, retainInput, retainNull, nullWriterFactory,
-                localResourceFactoryProvider, searchOpCallbackFactory, modificationOpCallbackFactory);
+                localResourceFactoryProvider, searchOpCallbackFactory, modificationOpCallbackFactory,
+                pageManagerFactory);
         this.typeTraits = typeTraits;
         this.comparatorFactories = comparatorFactories;
         this.bloomFilterKeyFields = bloomFilterKeyFields;


Mime
View raw message