[NO ISSUE][OTH] Remove external indexing runtime
- user model changes: no
- storage format changes: no
- interface changes: no
Change-Id: I6fb6cd6070329ac966cbe89c8e0ea9966f702947
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17445
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
index 82c70a3..077b657 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
@@ -105,8 +105,6 @@
import org.apache.hyracks.storage.am.common.data.PointablePrimitiveValueProviderFactory;
import org.apache.hyracks.storage.am.common.freepage.AppendOnlyLinkedMetadataPageManagerFactory;
import org.apache.hyracks.storage.am.lsm.btree.column.dataflow.LSMColumnBTreeLocalResource;
-import org.apache.hyracks.storage.am.lsm.btree.dataflow.ExternalBTreeLocalResource;
-import org.apache.hyracks.storage.am.lsm.btree.dataflow.ExternalBTreeWithBuddyLocalResource;
import org.apache.hyracks.storage.am.lsm.btree.dataflow.LSMBTreeLocalResource;
import org.apache.hyracks.storage.am.lsm.common.impls.ConcurrentMergePolicyFactory;
import org.apache.hyracks.storage.am.lsm.common.impls.ConstantMergePolicyFactory;
@@ -123,7 +121,6 @@
import org.apache.hyracks.storage.am.lsm.invertedindex.tokenizers.NGramUTF8StringBinaryTokenizerFactory;
import org.apache.hyracks.storage.am.lsm.invertedindex.tokenizers.UTF8NGramTokenFactory;
import org.apache.hyracks.storage.am.lsm.invertedindex.tokenizers.UTF8WordTokenFactory;
-import org.apache.hyracks.storage.am.lsm.rtree.dataflow.ExternalRTreeLocalResource;
import org.apache.hyracks.storage.am.lsm.rtree.dataflow.LSMRTreeLocalResource;
import org.apache.hyracks.storage.am.lsm.rtree.dataflow.LSMRTreeWithAntiMatterLocalResource;
import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
@@ -161,9 +158,6 @@
registeredClasses.put("LSMRTreeLocalResource", LSMRTreeLocalResource.class);
registeredClasses.put("LSMRTreeWithAntiMatterLocalResource", LSMRTreeWithAntiMatterLocalResource.class);
registeredClasses.put("LSMInvertedIndexLocalResource", LSMInvertedIndexLocalResource.class);
- registeredClasses.put("ExternalBTreeLocalResource", ExternalBTreeLocalResource.class);
- registeredClasses.put("ExternalBTreeWithBuddyLocalResource", ExternalBTreeWithBuddyLocalResource.class);
- registeredClasses.put("ExternalRTreeLocalResource", ExternalRTreeLocalResource.class);
registeredClasses.put("LSMColumnBTreeLocalResource", LSMColumnBTreeLocalResource.class);
// ILSMMergePolicyFactory
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 775672c..399b7b4 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -33,7 +33,6 @@
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -71,7 +70,6 @@
import org.apache.asterix.common.api.IResponsePrinter;
import org.apache.asterix.common.cluster.IClusterStateManager;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
-import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.config.DatasetConfig.TransactionState;
import org.apache.asterix.common.config.GlobalConfig;
@@ -96,7 +94,6 @@
import org.apache.asterix.common.utils.StorageConstants;
import org.apache.asterix.compiler.provider.ILangCompilationProvider;
import org.apache.asterix.external.dataset.adapter.AdapterIdentifier;
-import org.apache.asterix.external.indexing.ExternalFile;
import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.external.operators.FeedIntakeOperatorNodePushable;
import org.apache.asterix.external.util.ExternalDataConstants;
@@ -148,7 +145,6 @@
import org.apache.asterix.lang.common.statement.NodeGroupDropStatement;
import org.apache.asterix.lang.common.statement.NodegroupDecl;
import org.apache.asterix.lang.common.statement.Query;
-import org.apache.asterix.lang.common.statement.RefreshExternalDatasetStatement;
import org.apache.asterix.lang.common.statement.SetStatement;
import org.apache.asterix.lang.common.statement.StartFeedStatement;
import org.apache.asterix.lang.common.statement.StopFeedStatement;
@@ -193,7 +189,6 @@
import org.apache.asterix.metadata.functions.ExternalFunctionCompilerUtil;
import org.apache.asterix.metadata.lock.ExternalDatasetsRegistry;
import org.apache.asterix.metadata.utils.DatasetUtil;
-import org.apache.asterix.metadata.utils.ExternalIndexingOperations;
import org.apache.asterix.metadata.utils.IndexUtil;
import org.apache.asterix.metadata.utils.KeyFieldTypeUtil;
import org.apache.asterix.metadata.utils.MetadataConstants;
@@ -263,7 +258,6 @@
import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
import org.apache.hyracks.storage.am.lsm.invertedindex.fulltext.TokenizerCategory;
import org.apache.hyracks.util.LogRedactionUtil;
-import org.apache.hyracks.util.OptionalBoolean;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -1558,76 +1552,16 @@
Index filesIndex = null;
boolean firstExternalDatasetIndex = false;
boolean datasetLocked = false;
- List<ExternalFile> externalFilesSnapshot;
MetadataTransactionContext mdTxnCtx = metadataProvider.getMetadataTxnContext();
JobSpecification spec;
- boolean filesIndexReplicated = false;
try {
index.setPendingOp(MetadataUtil.PENDING_ADD_OP);
if (ds.getDatasetType() == DatasetType.INTERNAL) {
validateDatasetState(metadataProvider, ds, sourceLoc);
- } else {
+ } else if (ds.getDatasetType() == DatasetType.EXTERNAL) {
// External dataset
- // Check if the dataset is indexible
- if (!ExternalIndexingOperations.isIndexible((ExternalDatasetDetails) ds.getDatasetDetails())) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- dataset() + " using " + ((ExternalDatasetDetails) ds.getDatasetDetails()).getAdapter()
- + " adapter can't be indexed");
- }
- // Check if the name of the index is valid
- if (!ExternalIndexingOperations.isValidIndexName(index.getDatasetName(), index.getIndexName())) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "external " + dataset() + " index name is invalid");
- }
-
- // Check if the files index exist
- filesIndex = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(),
- index.getDataverseName(), index.getDatasetName(),
- IndexingConstants.getFilesIndexName(index.getDatasetName()));
- firstExternalDatasetIndex = filesIndex == null;
- // Lock external dataset
- ExternalDatasetsRegistry.INSTANCE.buildIndexBegin(ds, firstExternalDatasetIndex);
- datasetLocked = true;
- if (firstExternalDatasetIndex) {
- // Verify that no one has created an index before we acquire the lock
- filesIndex = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(),
- index.getDataverseName(), index.getDatasetName(),
- IndexingConstants.getFilesIndexName(index.getDatasetName()));
- if (filesIndex != null) {
- ExternalDatasetsRegistry.INSTANCE.buildIndexEnd(ds, firstExternalDatasetIndex);
- firstExternalDatasetIndex = false;
- ExternalDatasetsRegistry.INSTANCE.buildIndexBegin(ds, firstExternalDatasetIndex);
- }
- }
- if (firstExternalDatasetIndex) {
- // Get snapshot from External File System
- externalFilesSnapshot = ExternalIndexingOperations.getSnapshotFromExternalFileSystem(ds);
- // Add an entry for the files index
- OptionalBoolean excludeUnknownKey =
- ((Index.ValueIndexDetails) index.getIndexDetails()).getExcludeUnknownKey();
- OptionalBoolean castDefaultNull =
- ((Index.ValueIndexDetails) index.getIndexDetails()).getCastDefaultNull();
- String datetimeFormat = ((Index.ValueIndexDetails) index.getIndexDetails()).getCastDatetimeFormat();
- String dateFormat = ((Index.ValueIndexDetails) index.getIndexDetails()).getCastDateFormat();
- String timeFormat = ((Index.ValueIndexDetails) index.getIndexDetails()).getCastTimeFormat();
-
- filesIndex = new Index(index.getDataverseName(), index.getDatasetName(),
- IndexingConstants.getFilesIndexName(index.getDatasetName()), IndexType.BTREE,
- new Index.ValueIndexDetails(ExternalIndexingOperations.FILE_INDEX_FIELD_NAMES, null,
- ExternalIndexingOperations.FILE_INDEX_FIELD_TYPES, false, excludeUnknownKey,
- castDefaultNull, datetimeFormat, dateFormat, timeFormat),
- false, false, MetadataUtil.PENDING_ADD_OP);
- MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), filesIndex);
- // Add files to the external files index
- for (ExternalFile file : externalFilesSnapshot) {
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- }
- // This is the first index for the external dataset, replicate the files index
- spec = ExternalIndexingOperations.buildFilesIndexCreateJobSpec(ds, externalFilesSnapshot,
- metadataProvider);
- filesIndexReplicated = true;
- runJob(hcc, spec, jobFlags);
- }
+ throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, dataset() + " using "
+ + ((ExternalDatasetDetails) ds.getDatasetDetails()).getAdapter() + " adapter can't be indexed");
}
// check whether there exists another enforced index on the same field
@@ -1748,24 +1682,6 @@
if (bActiveTxn) {
abort(e, e, mdTxnCtx);
}
- // If files index was replicated for external dataset, it should be cleaned up
- // on NC side
- if (filesIndexReplicated) {
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- bActiveTxn = true;
- try {
- JobSpecification jobSpec =
- ExternalIndexingOperations.buildDropFilesIndexJobSpec(metadataProvider, ds);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- bActiveTxn = false;
- runJob(hcc, jobSpec, jobFlags);
- } catch (Exception e2) {
- e.addSuppressed(e2);
- if (bActiveTxn) {
- abort(e, e2, mdTxnCtx);
- }
- }
- }
if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
// #. execute compensation operations
@@ -1992,13 +1908,8 @@
case EXTERNAL:
indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
for (Index index : indexes) {
- if (ExternalIndexingOperations.isFileIndex(index)) {
- jobsToExecute.add(ExternalIndexingOperations
- .buildDropFilesIndexJobSpec(metadataProvider, dataset));
- } else {
- jobsToExecute.add(
- IndexUtil.buildDropIndexJobSpec(index, metadataProvider, dataset, sourceLoc));
- }
+ jobsToExecute
+ .add(IndexUtil.buildDropIndexJobSpec(index, metadataProvider, dataset, sourceLoc));
}
externalDatasetsToDeregister.add(dataset);
break;
@@ -2299,67 +2210,6 @@
MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
} else {
// External dataset
- indexName = stmtIndexDrop.getIndexName().getValue();
- Index index = MetadataManager.INSTANCE.getIndex(mdTxnCtx, dataverseName, datasetName, indexName);
- if (index == null) {
- if (stmtIndexDrop.getIfExists()) {
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- return false;
- } else {
- throw new CompilationException(ErrorCode.UNKNOWN_INDEX, sourceLoc, indexName);
- }
- } else if (ExternalIndexingOperations.isFileIndex(index)) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
- "Dropping " + dataset() + " files index is not allowed.");
- }
- ensureNonPrimaryIndexDrop(index, sourceLoc);
- prepareIndexDrop(metadataProvider, dataverseName, datasetName, sourceLoc, indexName, jobsToExecute,
- mdTxnCtx, ds, index);
-
- List<Index> datasetIndexes =
- MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
- if (datasetIndexes.size() == 2) {
- dropFilesIndex = true;
- // only one index + the files index, we need to delete both of the indexes
- for (Index externalIndex : datasetIndexes) {
- if (ExternalIndexingOperations.isFileIndex(externalIndex)) {
- jobsToExecute
- .add(ExternalIndexingOperations.buildDropFilesIndexJobSpec(metadataProvider, ds));
- // #. mark PendingDropOp on the existing files index
- MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName,
- externalIndex.getIndexName());
- MetadataManager.INSTANCE.addIndex(mdTxnCtx,
- new Index(dataverseName, datasetName, externalIndex.getIndexName(),
- externalIndex.getIndexType(), externalIndex.getIndexDetails(),
- externalIndex.isEnforced(), externalIndex.isPrimaryIndex(),
- MetadataUtil.PENDING_DROP_OP));
- }
- }
- }
-
- // #. commit the existing transaction before calling runJob.
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- bActiveTxn = false;
- progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
-
- for (JobSpecification jobSpec : jobsToExecute) {
- runJob(hcc, jobSpec);
- }
-
- // #. begin a new transaction
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- bActiveTxn = true;
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
-
- // #. finally, delete the existing index
- MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
- if (dropFilesIndex) {
- // delete the files index too
- MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName,
- IndexingConstants.getFilesIndexName(datasetName));
- MetadataManager.INSTANCE.dropDatasetExternalFiles(mdTxnCtx, ds);
- ExternalDatasetsRegistry.INSTANCE.removeDatasetInfo(ds);
- }
}
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
return true;
@@ -4897,229 +4747,7 @@
protected void handleExternalDatasetRefreshStatement(MetadataProvider metadataProvider, Statement stmt,
IHyracksClientConnection hcc) throws Exception {
- RefreshExternalDatasetStatement stmtRefresh = (RefreshExternalDatasetStatement) stmt;
- SourceLocation sourceLoc = stmtRefresh.getSourceLocation();
- DataverseName dataverseName = getActiveDataverseName(stmtRefresh.getDataverseName());
- String datasetName = stmtRefresh.getDatasetName().getValue();
- TransactionState transactionState = TransactionState.COMMIT;
- JobSpecification spec = null;
- Dataset ds = null;
- List<ExternalFile> metadataFiles = null;
- List<ExternalFile> deletedFiles = null;
- List<ExternalFile> addedFiles = null;
- List<ExternalFile> appendedFiles = null;
- List<Index> indexes = null;
- Dataset transactionDataset = null;
- boolean lockAquired = false;
- boolean success = false;
- if (isCompileOnly()) {
- return;
- }
- MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- boolean bActiveTxn = true;
- lockUtil.refreshDatasetBegin(lockManager, metadataProvider.getLocks(), dataverseName, datasetName);
- try {
- ds = metadataProvider.findDataset(dataverseName, datasetName);
- // Dataset exists ?
- if (ds == null) {
- throw new CompilationException(ErrorCode.UNKNOWN_DATASET_IN_DATAVERSE, sourceLoc, datasetName,
- dataverseName);
- }
- // Dataset external ?
- if (ds.getDatasetType() != DatasetType.EXTERNAL) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, dataset() + " " + datasetName
- + " in " + dataverse() + " " + dataverseName + " is not an external " + dataset());
- }
- // Dataset has indexes ?
- indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
- if (indexes.isEmpty()) {
- throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "External " + dataset() + " "
- + datasetName + " in " + dataverse() + " " + dataverseName + " doesn't have any index");
- }
-
- // Record transaction time
- Date txnTime = new Date();
-
- // refresh lock here
- ExternalDatasetsRegistry.INSTANCE.refreshBegin(ds);
- lockAquired = true;
-
- // Get internal files
- metadataFiles = MetadataManager.INSTANCE.getDatasetExternalFiles(mdTxnCtx, ds);
- deletedFiles = new ArrayList<>();
- addedFiles = new ArrayList<>();
- appendedFiles = new ArrayList<>();
-
- // Compute delta
- // Now we compare snapshot with external file system
- if (ExternalIndexingOperations.isDatasetUptodate(ds, metadataFiles, addedFiles, deletedFiles,
- appendedFiles)) {
- ((ExternalDatasetDetails) ds.getDatasetDetails()).setRefreshTimestamp(txnTime);
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, ds);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- // latch will be released in the finally clause
- return;
- }
-
- // At this point, we know data has changed in the external file system, record
- // transaction in metadata and start
- transactionDataset = ExternalIndexingOperations.createTransactionDataset(ds);
- /*
- * Remove old dataset record and replace it with a new one
- */
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, transactionDataset);
-
- // Add delta files to the metadata
- for (ExternalFile file : addedFiles) {
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- }
- for (ExternalFile file : appendedFiles) {
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- }
- for (ExternalFile file : deletedFiles) {
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- }
-
- // Create the files index update job
- spec = ExternalIndexingOperations.buildFilesIndexUpdateOp(ds, metadataFiles, addedFiles, appendedFiles,
- metadataProvider);
-
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- bActiveTxn = false;
- transactionState = TransactionState.BEGIN;
-
- // run the files update job
- runJob(hcc, spec);
-
- for (Index index : indexes) {
- if (!ExternalIndexingOperations.isFileIndex(index)) {
- spec = ExternalIndexingOperations.buildIndexUpdateOp(ds, index, metadataFiles, addedFiles,
- appendedFiles, metadataProvider, sourceLoc);
- // run the files update job
- runJob(hcc, spec);
- }
- }
-
- // all index updates has completed successfully, record transaction state
- spec = ExternalIndexingOperations.buildCommitJob(ds, indexes, metadataProvider);
-
- // Aquire write latch again -> start a transaction and record the decision to
- // commit
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- bActiveTxn = true;
- ((ExternalDatasetDetails) transactionDataset.getDatasetDetails())
- .setState(TransactionState.READY_TO_COMMIT);
- ((ExternalDatasetDetails) transactionDataset.getDatasetDetails()).setRefreshTimestamp(txnTime);
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, transactionDataset);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- bActiveTxn = false;
- transactionState = TransactionState.READY_TO_COMMIT;
- // We don't release the latch since this job is expected to be quick
- runJob(hcc, spec);
- // Start a new metadata transaction to record the final state of the transaction
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- bActiveTxn = true;
-
- for (ExternalFile file : metadataFiles) {
- if (file.getPendingOp() == ExternalFilePendingOp.DROP_OP) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- } else if (file.getPendingOp() == ExternalFilePendingOp.NO_OP) {
- Iterator<ExternalFile> iterator = appendedFiles.iterator();
- while (iterator.hasNext()) {
- ExternalFile appendedFile = iterator.next();
- if (file.getFileName().equals(appendedFile.getFileName())) {
- // delete existing file
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- // delete existing appended file
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, appendedFile);
- // add the original file with appended information
- appendedFile.setFileNumber(file.getFileNumber());
- appendedFile.setPendingOp(ExternalFilePendingOp.NO_OP);
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, appendedFile);
- iterator.remove();
- }
- }
- }
- }
-
- // remove the deleted files delta
- for (ExternalFile file : deletedFiles) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- }
-
- // insert new files
- for (ExternalFile file : addedFiles) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- file.setPendingOp(ExternalFilePendingOp.NO_OP);
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- }
-
- // mark the transaction as complete
- ((ExternalDatasetDetails) transactionDataset.getDatasetDetails()).setState(TransactionState.COMMIT);
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, transactionDataset);
-
- // commit metadata transaction
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- success = true;
- } catch (Exception e) {
- if (bActiveTxn) {
- abort(e, e, mdTxnCtx);
- }
- if (transactionState == TransactionState.READY_TO_COMMIT) {
- throw new IllegalStateException("System is inconsistent state: commit of (" + dataverseName + "."
- + datasetName + ") refresh couldn't carry out the commit phase", e);
- }
- if (transactionState == TransactionState.COMMIT) {
- // Nothing to do , everything should be clean
- throw e;
- }
- if (transactionState == TransactionState.BEGIN) {
- // transaction failed, need to do the following
- // clean NCs removing transaction components
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- bActiveTxn = true;
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- spec = ExternalIndexingOperations.buildAbortOp(ds, indexes, metadataProvider);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- bActiveTxn = false;
- try {
- runJob(hcc, spec);
- } catch (Exception e2) {
- // This should never happen -- fix throw illegal
- e.addSuppressed(e2);
- throw new IllegalStateException("System is in inconsistent state. Failed to abort refresh", e);
- }
- // remove the delta of files
- // return the state of the dataset to committed
- try {
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- for (ExternalFile file : deletedFiles) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- }
- for (ExternalFile file : addedFiles) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- }
- for (ExternalFile file : appendedFiles) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- }
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, ds);
- // commit metadata transaction
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- } catch (Exception e2) {
- abort(e, e2, mdTxnCtx);
- e.addSuppressed(e2);
- throw new IllegalStateException("System is in inconsistent state. Failed to drop delta files", e);
- }
- }
- } finally {
- if (lockAquired) {
- ExternalDatasetsRegistry.INSTANCE.refreshEnd(ds, success);
- }
- metadataProvider.getLocks().unlock();
- }
+ // no op
}
@Override
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
index e6ef8df..2452b8f 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
@@ -30,23 +30,14 @@
import org.apache.asterix.common.api.IClusterManagementWork;
import org.apache.asterix.common.api.IClusterManagementWork.ClusterState;
import org.apache.asterix.common.cluster.IGlobalRecoveryManager;
-import org.apache.asterix.common.config.DatasetConfig.DatasetType;
-import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
-import org.apache.asterix.common.config.DatasetConfig.TransactionState;
import org.apache.asterix.common.context.IStorageComponentProvider;
import org.apache.asterix.common.dataflow.ICcApplicationContext;
-import org.apache.asterix.external.indexing.ExternalFile;
import org.apache.asterix.messaging.CCMessageBroker;
import org.apache.asterix.metadata.MetadataManager;
import org.apache.asterix.metadata.MetadataTransactionContext;
-import org.apache.asterix.metadata.declared.MetadataProvider;
import org.apache.asterix.metadata.entities.Dataset;
import org.apache.asterix.metadata.entities.Dataverse;
-import org.apache.asterix.metadata.entities.ExternalDatasetDetails;
-import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.metadata.utils.DatasetUtil;
-import org.apache.asterix.metadata.utils.ExternalIndexingOperations;
-import org.apache.asterix.metadata.utils.MetadataConstants;
import org.apache.hyracks.api.application.ICCServiceContext;
import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.apache.hyracks.api.job.JobId;
@@ -162,7 +153,6 @@
throws Exception {
// Loop over datasets
for (Dataverse dataverse : MetadataManager.INSTANCE.getDataverses(mdTxnCtx)) {
- mdTxnCtx = recoverDatasets(appCtx, mdTxnCtx, dataverse);
// Fixes ASTERIXDB-2386 by caching the dataverse during recovery
MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverse.getDataverseName());
}
@@ -182,96 +172,6 @@
}
}
- private MetadataTransactionContext recoverDatasets(ICcApplicationContext appCtx,
- MetadataTransactionContext mdTxnCtx, Dataverse dataverse) throws Exception {
- if (!dataverse.getDataverseName().equals(MetadataConstants.METADATA_DATAVERSE_NAME)) {
- MetadataProvider metadataProvider = MetadataProvider.create(appCtx, dataverse);
- try {
- List<Dataset> datasets =
- MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dataverse.getDataverseName());
- for (Dataset dataset : datasets) {
- if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
- // External dataset
- // Get indexes
- List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx,
- dataset.getDataverseName(), dataset.getDatasetName());
- // Get the state of the dataset
- ExternalDatasetDetails dsd = (ExternalDatasetDetails) dataset.getDatasetDetails();
- TransactionState datasetState = dsd.getState();
- if (!indexes.isEmpty()) {
- if (datasetState == TransactionState.BEGIN) {
- List<ExternalFile> files =
- MetadataManager.INSTANCE.getDatasetExternalFiles(mdTxnCtx, dataset);
- // if persumed abort, roll backward
- // 1. delete all pending files
- for (ExternalFile file : files) {
- if (file.getPendingOp() != ExternalFilePendingOp.NO_OP) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- }
- }
- }
- // 2. clean artifacts in NCs
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- JobSpecification jobSpec =
- ExternalIndexingOperations.buildAbortOp(dataset, indexes, metadataProvider);
- executeHyracksJob(jobSpec);
- // 3. correct the dataset state
- ((ExternalDatasetDetails) dataset.getDatasetDetails()).setState(TransactionState.COMMIT);
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, dataset);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- } else if (datasetState == TransactionState.READY_TO_COMMIT) {
- List<ExternalFile> files =
- MetadataManager.INSTANCE.getDatasetExternalFiles(mdTxnCtx, dataset);
- // if ready to commit, roll forward
- // 1. commit indexes in NCs
- metadataProvider.setMetadataTxnContext(mdTxnCtx);
- JobSpecification jobSpec =
- ExternalIndexingOperations.buildRecoverOp(dataset, indexes, metadataProvider);
- executeHyracksJob(jobSpec);
- // 2. add pending files in metadata
- for (ExternalFile file : files) {
- if (file.getPendingOp() == ExternalFilePendingOp.ADD_OP) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- file.setPendingOp(ExternalFilePendingOp.NO_OP);
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, file);
- } else if (file.getPendingOp() == ExternalFilePendingOp.DROP_OP) {
- // find original file
- for (ExternalFile originalFile : files) {
- if (originalFile.getFileName().equals(file.getFileName())) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, originalFile);
- break;
- }
- }
- } else if (file.getPendingOp() == ExternalFilePendingOp.APPEND_OP) {
- // find original file
- for (ExternalFile originalFile : files) {
- if (originalFile.getFileName().equals(file.getFileName())) {
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
- MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, originalFile);
- originalFile.setSize(file.getSize());
- MetadataManager.INSTANCE.addExternalFile(mdTxnCtx, originalFile);
- }
- }
- }
- // 3. correct the dataset state
- ((ExternalDatasetDetails) dataset.getDatasetDetails())
- .setState(TransactionState.COMMIT);
- MetadataManager.INSTANCE.updateDataset(mdTxnCtx, dataset);
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
- mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
- }
- }
- }
- }
- } finally {
- metadataProvider.getLocks().unlock();
- }
- }
- return mdTxnCtx;
- }
-
@Override
public boolean isRecoveryCompleted() {
return recoveryCompleted;
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
index fcc8bc6..13b9bd1 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
@@ -25,7 +25,6 @@
import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.context.AsterixVirtualBufferCacheProvider;
import org.apache.asterix.common.context.IStorageComponentProvider;
-import org.apache.asterix.external.indexing.FilesIndexDescription;
import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.metadata.api.IResourceFactoryProvider;
import org.apache.asterix.metadata.declared.MetadataProvider;
@@ -96,7 +95,7 @@
return primaryTypeTraits;
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL
&& index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.EXTERNAL_FILE_INDEX_TYPE_TRAITS;
+ return null;
}
Index.ValueIndexDetails indexDetails = (Index.ValueIndexDetails) index.getIndexDetails();
int numPrimaryKeys = dataset.getPrimaryKeys().size();
@@ -131,7 +130,7 @@
return dataset.getPrimaryComparatorFactories(metadataProvider, recordType, metaType);
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL
&& index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.FILES_INDEX_COMP_FACTORIES;
+ return null;
}
Index.ValueIndexDetails indexDetails = (Index.ValueIndexDetails) index.getIndexDetails();
int numPrimaryKeys = dataset.getPrimaryKeys().size();
@@ -166,7 +165,7 @@
return dataset.getPrimaryBloomFilterFields();
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
if (index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.BLOOM_FILTER_FIELDS;
+ return null;
} else {
return new int[] { ((Index.ValueIndexDetails) index.getIndexDetails()).getKeyFieldNames().size() };
}
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
deleted file mode 100644
index c801bd0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
+++ /dev/null
@@ -1,63 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.TwitterUserType as
- closed {
- `screen-name` : string,
- lang : string,
- `friends-count` : bigint,
- `statuses-count` : bigint,
- name : string,
- `followers-count` : bigint
-};
-
-create type test.TweetMessageType as
- closed {
- tweetid : bigint,
- user : TwitterUserType,
- `sender-location` : point,
- `send-time` : datetime,
- `referred-topics` : {{string}},
- `message-text` : string,
- countA : bigint,
- countB : bigint
-};
-
-create external dataset TweetMessages(TweetMessageType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/tw_for_indexleftouterjoin.adm`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index IdIx on TweetMessages (tweetid) type btree;
-
-create index msgCountAIx on TweetMessages (countA) type btree;
-
-create index msgCountBIx on TweetMessages (countB) type btree;
-
-create index twmSndLocIx on TweetMessages (`sender-location`) type rtree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
deleted file mode 100644
index 56615ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
+++ /dev/null
@@ -1,39 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-use test;
-
-
-select element {'tweetid1':t1.tweetid,'loc1':t1.`sender-location`,'nearby-message':(
- select element {'tweetid2':t2.tweetid,'loc2':t2.`sender-location`}
- from TweetMessages as t2
- where test.`spatial-intersect`(t2.`sender-location`,n)
- order by t2.tweetid
- )}
-from TweetMessages as t1
-with n as test.`create-circle`(t1.`sender-location`,0.5)
-where (t1.tweetid < test.bigint('10'))
-order by t1.tweetid
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
deleted file mode 100644
index 6cbeb79..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
+++ /dev/null
@@ -1,61 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.TwitterUserType as
- closed {
- `screen-name` : string,
- lang : string,
- `friends-count` : bigint,
- `statuses-count` : bigint,
- name : string,
- `followers-count` : bigint
-};
-
-create type test.TweetMessageType as
- closed {
- tweetid : bigint,
- user : TwitterUserType,
- `sender-location` : point,
- `send-time` : datetime,
- `referred-topics` : {{string}},
- `message-text` : string,
- countA : bigint,
- countB : bigint
-};
-
-create external dataset TweetMessages(TweetMessageType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/tw_for_indexleftouterjoin.adm`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index IdIx on TweetMessages (tweetid) type btree;
-
-create index msgCountAIx on TweetMessages (countA) type btree;
-
-create index msgCountBIx on TweetMessages (countB) type btree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
deleted file mode 100644
index df67ea3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
+++ /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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
deleted file mode 100644
index 86fc87b..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
+++ /dev/null
@@ -1,32 +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.
- */
-
-use test;
-
-
-select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
- select element {'tweetid2':t2.tweetid,'count2':t2.countB}
- from TweetMessages as t2
- where (t1.countA /*+ indexnl */ = t2.countB)
- order by t2.tweetid
- )}
-from TweetMessages as t1
-where (t1.tweetid < test.bigint('10'))
-order by t1.tweetid
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
deleted file mode 100644
index 6e87e38..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
+++ /dev/null
@@ -1,42 +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.
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.MyRecord as
- closed {
- id : bigint,
- point : point,
- kwds : string,
- line1 : line,
- line2 : line,
- poly1 : polygon,
- poly2 : polygon,
- rec : rectangle,
- circle : circle
-};
-
-create external dataset MyData(MyRecord) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/spatialData.json`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index rtree_index_point on MyData (point) type rtree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp
deleted file mode 100644
index 6406409..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/rtree-index/rtree-index.3.query.sqlpp
+++ /dev/null
@@ -1,27 +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.
- */
-
-use test;
-
-
-select element {'id':o.id}
-from MyData as o
-where test.`spatial-intersect`(o.point,test.`create-polygon`([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
-order by o.id
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp
deleted file mode 100644
index f366b4a..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.1.ddl.sqlpp
+++ /dev/null
@@ -1,43 +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.
- */
-/*
- * Description : Create an external dataset that contains records stored with sequence hdfs file format.
- * Build an index over the external dataset age attribute
- * Perform a query over the dataset using the index.
- * Expected Res : Success
- * Date : 3rd Jan 2014
-*/
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.EmployeeType as
- closed {
- id : bigint,
- name : string,
- age : bigint
-};
-
-create external dataset EmployeeDataset(EmployeeType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/external-indexing-test.seq`),(`input-format`=`sequence-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
-
-create index EmployeeAgeIdx on EmployeeDataset (age) type btree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.sqlpp
deleted file mode 100644
index bbb644e..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.2.update.sqlpp
+++ /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.
- */
-/*
- * Description : Create an external dataset that contains records stored with sequence hdfs file format.
- * Build an index over the external dataset age attribute
- * Perform a query over the dataset using the index.
- * Expected Res : Success
- * Date : 3rd Jan 2014
-*/
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp
deleted file mode 100644
index 477ad06..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/sequence-format/sequence-format.3.query.sqlpp
+++ /dev/null
@@ -1,33 +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.
- */
-/*
- * Description : Create an external dataset that contains records stored with sequence hdfs file format.
- * Build an index over the external dataset age attribute
- * Perform a query over the dataset using the index.
- * Expected Res : Success
- * Date : 3rd Jan 2014
-*/
-
-use test;
-
-
-select element emp
-from EmployeeDataset as emp
-where (emp.age = 22)
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp
deleted file mode 100644
index ca874e5..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.1.ddl.sqlpp
+++ /dev/null
@@ -1,43 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.EmployeeType as
- closed {
- id : bigint,
- name : string,
- age : bigint
-};
-
-create external dataset EmployeeDataset(EmployeeType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/external-indexing-test.txt`),(`input-format`=`text-input-format`),(`format`=`delimited-text`),(`delimiter`=`|`));
-
-create index EmployeeAgeIdx on EmployeeDataset (age) type btree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.sqlpp
deleted file mode 100644
index 1c90e53..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.2.update.sqlpp
+++ /dev/null
@@ -1,26 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp
deleted file mode 100644
index b0ba55d..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-indexing/text-format/text-format.3.query.sqlpp
+++ /dev/null
@@ -1,34 +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.
- */
-/*
- * Description : Create an external dataset that contains records stored with text hdfs file format.
- * Build an index over the external dataset age attribute
- * Perform a query over the dataset using the index.
- * Expected Res : Success
- * Date : 3rd Jan 2014
-*/
-
-use test;
-
-
-select element emp
-from EmployeeDataset as emp
-where (emp.age = 22)
-order by emp.id
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp
deleted file mode 100644
index 7cafed2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.1.ddl.sqlpp
+++ /dev/null
@@ -1,48 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.MyRecord as
-{
- point : point,
- kwds : string,
- line1 : line,
- line2 : line,
- poly1 : polygon,
- poly2 : polygon,
- rec : rectangle,
- circle : circle
-};
-
-create external dataset MyData(MyRecord) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/spatialData.json`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index idx on MyData (id:bigint?) type btree enforced;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.sqlpp
deleted file mode 100644
index 7b2e6a3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.2.update.sqlpp
+++ /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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp
deleted file mode 100644
index dfa9fe3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/adm-format/adm-format.3.query.sqlpp
+++ /dev/null
@@ -1,32 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-use test;
-
-
-select element d
-from MyData as d
-where (d.id = 10)
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
deleted file mode 100644
index f7000eb1..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.ddl.sqlpp
+++ /dev/null
@@ -1,59 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.TwitterUserType as
- closed {
- `screen-name` : string,
- lang : string,
- `friends-count` : bigint,
- `statuses-count` : bigint,
- name : string,
- `followers-count` : bigint
-};
-
-create type test.TweetMessageType as
-{
- user : TwitterUserType,
- `send-time` : datetime,
- `referred-topics` : {{string}},
- `message-text` : string
-};
-
-create external dataset TweetMessages(TweetMessageType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/tw_for_indexleftouterjoin.adm`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index IdIx on TweetMessages (tweetid:bigint?) type btree enforced;
-
-create index msgCountAIx on TweetMessages (countA:bigint?) type btree enforced;
-
-create index msgCountBIx on TweetMessages (countB:bigint?) type btree enforced;
-
-create index twmSndLocIx on TweetMessages (`sender-location`:point?) type rtree enforced;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
deleted file mode 100644
index 56615ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.3.query.sqlpp
+++ /dev/null
@@ -1,39 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-use test;
-
-
-select element {'tweetid1':t1.tweetid,'loc1':t1.`sender-location`,'nearby-message':(
- select element {'tweetid2':t2.tweetid,'loc2':t2.`sender-location`}
- from TweetMessages as t2
- where test.`spatial-intersect`(t2.`sender-location`,n)
- order by t2.tweetid
- )}
-from TweetMessages as t1
-with n as test.`create-circle`(t1.`sender-location`,0.5)
-where (t1.tweetid < test.bigint('10'))
-order by t1.tweetid
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
deleted file mode 100644
index fcd4f77..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.1.ddl.sqlpp
+++ /dev/null
@@ -1,58 +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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.TwitterUserType as
- closed {
- `screen-name` : string,
- lang : string,
- `friends-count` : bigint,
- `statuses-count` : bigint,
- name : string,
- `followers-count` : bigint
-};
-
-create type test.TweetMessageType as
-{
- user : TwitterUserType,
- `sender-location` : point,
- `send-time` : datetime,
- `referred-topics` : {{string}},
- `message-text` : string
-};
-
-create external dataset TweetMessages(TweetMessageType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/tw_for_indexleftouterjoin.adm`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index IdIx on TweetMessages (tweetid:bigint?) type btree enforced;
-
-create index msgCountAIx on TweetMessages (countA:bigint?) type btree enforced;
-
-create index msgCountBIx on TweetMessages (countB:bigint?) type btree enforced;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
deleted file mode 100644
index df67ea3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.2.update.sqlpp
+++ /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.
- */
-/*
- * Description : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
- * Issue : 730, 741
- * Expected Res : Success
- * Date : 8th May 2014
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
deleted file mode 100644
index 86fc87b..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/leftouterjoin/leftouterjoin.3.query.sqlpp
+++ /dev/null
@@ -1,32 +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.
- */
-
-use test;
-
-
-select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
- select element {'tweetid2':t2.tweetid,'count2':t2.countB}
- from TweetMessages as t2
- where (t1.countA /*+ indexnl */ = t2.countB)
- order by t2.tweetid
- )}
-from TweetMessages as t1
-where (t1.tweetid < test.bigint('10'))
-order by t1.tweetid
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
deleted file mode 100644
index 9b94759..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.1.ddl.sqlpp
+++ /dev/null
@@ -1,41 +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.
- */
-
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-
-create type test.MyRecord as
-{
- id : bigint,
- kwds : string,
- line1 : line,
- line2 : line,
- poly1 : polygon,
- poly2 : polygon,
- rec : rectangle,
- circle : circle
-};
-
-create external dataset MyData(MyRecord) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/spatialData.json`),(`input-format`=`text-input-format`),(`format`=`adm`));
-
-create index rtree_index_point on MyData (point:point?) type rtree enforced;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp
deleted file mode 100644
index 6406409..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-enforced/external-indexing/rtree-index/rtree-index.3.query.sqlpp
+++ /dev/null
@@ -1,27 +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.
- */
-
-use test;
-
-
-select element {'id':o.id}
-from MyData as o
-where test.`spatial-intersect`(o.point,test.`create-polygon`([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
-order by o.id
-;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/decorrelate_with_unique_id_2/decorrelate_with_unique_id_2.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/decorrelate_with_unique_id_2/decorrelate_with_unique_id_2.1.ddl.sqlpp
index d124116..aea6acc 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/decorrelate_with_unique_id_2/decorrelate_with_unique_id_2.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/decorrelate_with_unique_id_2/decorrelate_with_unique_id_2.1.ddl.sqlpp
@@ -47,9 +47,3 @@
create external dataset TweetMessages(TweetMessageType) using `hdfs`((`hdfs`=`hdfs://127.0.0.1:31888`),(`path`=`/asterix/tw_for_indexleftouterjoin.adm`),(`input-format`=`text-input-format`),(`format`=`adm`));
-create index IdIx on TweetMessages (tweetid) type btree;
-
-create index msgCountAIx on TweetMessages (countA) type btree;
-
-create index msgCountBIx on TweetMessages (countB) type btree;
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.adm
deleted file mode 100644
index d3eb71a..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin-rtree/leftouterjoin-rtree.1.adm
+++ /dev/null
@@ -1,9 +0,0 @@
-{ "tweetid1": 1, "loc1": point("42.83,72.44"), "nearby-message": [ { "tweetid2": 1, "loc2": point("42.83,72.44") }, { "tweetid2": 55, "loc2": point("42.77,72.16") }, { "tweetid2": 114, "loc2": point("42.87,72.38") } ] }
-{ "tweetid1": 2, "loc1": point("34.81,72.44"), "nearby-message": [ { "tweetid2": 2, "loc2": point("34.81,72.44") } ] }
-{ "tweetid1": 3, "loc1": point("24.54,82.66"), "nearby-message": [ { "tweetid2": 3, "loc2": point("24.54,82.66") } ] }
-{ "tweetid1": 4, "loc1": point("38.14,68.1"), "nearby-message": [ { "tweetid2": 4, "loc2": point("38.14,68.1") } ] }
-{ "tweetid1": 5, "loc1": point("35.4,68.89"), "nearby-message": [ { "tweetid2": 5, "loc2": point("35.4,68.89") } ] }
-{ "tweetid1": 6, "loc1": point("42.75,78.5"), "nearby-message": [ { "tweetid2": 6, "loc2": point("42.75,78.5") } ] }
-{ "tweetid1": 7, "loc1": point("48.16,71.59"), "nearby-message": [ { "tweetid2": 7, "loc2": point("48.16,71.59") }, { "tweetid2": 42, "loc2": point("47.86,71.93") }, { "tweetid2": 192, "loc2": point("48.12,72.0") } ] }
-{ "tweetid1": 8, "loc1": point("36.17,72.56"), "nearby-message": [ { "tweetid2": 8, "loc2": point("36.17,72.56") } ] }
-{ "tweetid1": 9, "loc1": point("38.02,70.38"), "nearby-message": [ { "tweetid2": 9, "loc2": point("38.02,70.38") }, { "tweetid2": 51, "loc2": point("37.65,70.54") } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin/leftouterjoin.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin/leftouterjoin.1.adm
deleted file mode 100644
index 9a236f6..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/leftouterjoin/leftouterjoin.1.adm
+++ /dev/null
@@ -1,9 +0,0 @@
-{ "tweetid1": 1, "count1": 1, "t2info": [ ] }
-{ "tweetid1": 2, "count1": 2, "t2info": [ { "tweetid2": 60, "count2": 2 } ] }
-{ "tweetid1": 3, "count1": 3, "t2info": [ { "tweetid2": 105, "count2": 3 }, { "tweetid2": 206, "count2": 3 } ] }
-{ "tweetid1": 4, "count1": 4, "t2info": [ ] }
-{ "tweetid1": 5, "count1": 5, "t2info": [ { "tweetid2": 138, "count2": 5 }, { "tweetid2": 175, "count2": 5 } ] }
-{ "tweetid1": 6, "count1": 6, "t2info": [ { "tweetid2": 148, "count2": 6 } ] }
-{ "tweetid1": 7, "count1": 7, "t2info": [ { "tweetid2": 125, "count2": 7 } ] }
-{ "tweetid1": 8, "count1": 8, "t2info": [ ] }
-{ "tweetid1": 9, "count1": 9, "t2info": [ { "tweetid2": 141, "count2": 9 } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rc-format/rc-format.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rc-format/rc-format.1.adm
deleted file mode 100644
index aca40dc..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rc-format/rc-format.1.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "id": 3, "name": "Samuel", "age": 22 }
-{ "id": 10, "name": "David", "age": 22 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rtree-index/rtree-index.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rtree-index/rtree-index.1.adm
deleted file mode 100644
index b7c6180..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/rtree-index/rtree-index.1.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "id": 12 }
-{ "id": 20 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/sequence-format/sequence-format.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/sequence-format/sequence-format.1.adm
deleted file mode 100644
index aca40dc..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/sequence-format/sequence-format.1.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "id": 3, "name": "Samuel", "age": 22 }
-{ "id": 10, "name": "David", "age": 22 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/text-format/text-format.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/text-format/text-format.1.adm
deleted file mode 100644
index aca40dc..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/external-indexing/text-format/text-format.1.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "id": 3, "name": "Samuel", "age": 22 }
-{ "id": 10, "name": "David", "age": 22 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_hdfs.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_hdfs.xml
index 4d50ca2..0d3ae3d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_hdfs.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_hdfs.xml
@@ -17,78 +17,6 @@
! under the License.
!-->
<test-suite xmlns="urn:xml.testframework.asterix.apache.org" ResultOffsetPath="results" QueryOffsetPath="queries_sqlpp" QueryFileExtension=".sqlpp" SourceLocation="true">
- <test-group name="open-index-enforced">
- <test-group name="open-index-enforced/external-indexing">
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="Text">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="Text">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="Text">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="Text">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
- </test-group>
- <test-group name="nested-open-index">
- <test-group name="nested-open-index/external-indexing">
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="Text">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="Text">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="Text">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="Text">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
- </test-group>
- <test-group name="nested-index">
- <test-group name="nested-index/external-indexing">
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="Text">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="Text">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="Text">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="Text">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
- </test-group>
<test-group name="subquery">
<test-case FilePath="subquery">
<compilation-unit name="decorrelate_with_unique_id_2">
@@ -131,31 +59,4 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="external-indexing">
- <test-case FilePath="external-indexing">
- <compilation-unit name="text-format">
- <output-dir compare="Text">text-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="sequence-format">
- <output-dir compare="Text">sequence-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="Text">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="Text">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="Text">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
</test-suite>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
index a96c57e..94ee14a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
@@ -3103,28 +3103,6 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="open-index-enforced/external-indexing">
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="AST">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="AST">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="AST">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="open-index-enforced/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="AST">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
</test-group>
<test-group name="nested-open-index">
<test-group FilePath="nested-open-index/index-join">
@@ -3278,28 +3256,6 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="nested-open-index/external-indexing">
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="AST">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="AST">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="AST">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-open-index/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="AST">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
<test-group name="nested-open-index/highly-open-highly-nested">
<test-case FilePath="nested-open-index/highly-open-highly-nested">
<compilation-unit name="bottom-closed-top-closed">
@@ -3530,28 +3486,6 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="nested-index/external-indexing">
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="adm-format">
- <output-dir compare="AST">adm-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="AST">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="AST">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="nested-index/external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="AST">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
</test-group>
<test-group name="nested-index-dml">
<test-case FilePath="nested-index-dml">
@@ -6146,38 +6080,6 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="external-indexing">
- <test-case FilePath="external-indexing">
- <compilation-unit name="text-format">
- <output-dir compare="AST">text-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="sequence-format">
- <output-dir compare="AST">sequence-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="rc-format">
- <output-dir compare="AST">rc-format</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="rtree-index">
- <output-dir compare="AST">rtree-index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="leftouterjoin">
- <output-dir compare="AST">leftouterjoin</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="external-indexing">
- <compilation-unit name="leftouterjoin-rtree">
- <output-dir compare="AST">leftouterjoin-rtree</output-dir>
- </compilation-unit>
- </test-case>
- </test-group>
<test-group name="temporal">
<test-case FilePath="temporal">
<compilation-unit name="overlap_bins_gby_3">
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java
deleted file mode 100644
index fc0c4f9..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java
+++ /dev/null
@@ -1,91 +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.asterix.external.adapter.factory;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.apache.asterix.external.api.ILookupReaderFactory;
-import org.apache.asterix.external.api.ILookupRecordReader;
-import org.apache.asterix.external.api.IRecordDataParser;
-import org.apache.asterix.external.api.IRecordDataParserFactory;
-import org.apache.asterix.external.dataset.adapter.LookupAdapter;
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.indexing.RecordIdReader;
-import org.apache.asterix.external.indexing.RecordIdReaderFactory;
-import org.apache.asterix.external.provider.LookupReaderFactoryProvider;
-import org.apache.asterix.external.provider.ParserFactoryProvider;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.api.application.ICCServiceContext;
-import org.apache.hyracks.api.comm.IFrameWriter;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.IWarningCollector;
-
-@SuppressWarnings({ "rawtypes", "unchecked" })
-public class LookupAdapterFactory<T> implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private IRecordDataParserFactory dataParserFactory;
- private ILookupReaderFactory readerFactory;
- private final ARecordType recordType;
- private final int[] ridFields;
- private Map<String, String> configuration;
- private final boolean retainInput;
- private final boolean retainMissing;
- private final IMissingWriterFactory isMissingWriterFactory;
-
- public LookupAdapterFactory(ARecordType recordType, int[] ridFields, boolean retainInput, boolean retainNull,
- IMissingWriterFactory iNullWriterFactory) {
- this.recordType = recordType;
- this.ridFields = ridFields;
- this.retainInput = retainInput;
- this.retainMissing = retainNull;
- this.isMissingWriterFactory = iNullWriterFactory;
- }
-
- public LookupAdapter<T> createAdapter(IHyracksTaskContext ctx, int partition, RecordDescriptor inRecDesc,
- ExternalFileIndexAccessor snapshotAccessor, IFrameWriter writer) throws HyracksDataException {
- try {
- IRecordDataParser<T> dataParser = dataParserFactory.createRecordParser(ctx);
- ILookupRecordReader<? extends T> reader =
- readerFactory.createRecordReader(ctx, partition, snapshotAccessor);
- reader.configure(configuration);
- RecordIdReader ridReader = RecordIdReaderFactory.create(configuration, ridFields);
- return new LookupAdapter<>(dataParser, reader, inRecDesc, ridReader, retainInput, retainMissing,
- isMissingWriterFactory, ctx, writer);
- } catch (Exception e) {
- throw HyracksDataException.create(e);
- }
- }
-
- public void configure(ICCServiceContext serviceContext, Map<String, String> configuration,
- IWarningCollector warningCollector) throws HyracksDataException, AlgebricksException {
- this.configuration = configuration;
- readerFactory =
- LookupReaderFactoryProvider.getLookupReaderFactory(serviceContext, configuration, warningCollector);
- dataParserFactory = (IRecordDataParserFactory<T>) ParserFactoryProvider.getDataParserFactory(configuration);
- dataParserFactory.setRecordType(recordType);
- readerFactory.configure(serviceContext, configuration, warningCollector);
- dataParserFactory.configure(configuration);
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupReaderFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupReaderFactory.java
deleted file mode 100644
index 28dbde7..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupReaderFactory.java
+++ /dev/null
@@ -1,27 +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.asterix.external.api;
-
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-
-public interface ILookupReaderFactory<T> extends IExternalDataSourceFactory {
- public ILookupRecordReader<? extends T> createRecordReader(IHyracksTaskContext ctx, int partition,
- ExternalFileIndexAccessor snapshotAccessor) throws Exception;
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java
deleted file mode 100644
index 2588f41..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java
+++ /dev/null
@@ -1,40 +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.asterix.external.api;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.asterix.external.indexing.RecordId;
-
-public interface ILookupRecordReader<T> {
-
- public void configure(Map<String, String> configuration) throws Exception;
-
- public Class<?> getRecordClass() throws IOException;
-
- public IRawRecord<T> read(RecordId rid) throws Exception;
-
- public void open() throws IOException;
-
- public void fail() throws IOException;
-
- public void close() throws IOException;
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java
deleted file mode 100644
index 5700f9d..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java
+++ /dev/null
@@ -1,171 +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.asterix.external.dataset.adapter;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.asterix.external.api.ILookupRecordReader;
-import org.apache.asterix.external.api.IRawRecord;
-import org.apache.asterix.external.api.IRecordDataParser;
-import org.apache.asterix.external.indexing.RecordId;
-import org.apache.asterix.external.indexing.RecordIdReader;
-import org.apache.asterix.external.util.DataflowUtils;
-import org.apache.hyracks.api.comm.IFrameWriter;
-import org.apache.hyracks.api.comm.VSizeFrame;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriter;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender;
-import org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference;
-
-public final class LookupAdapter<T> implements IFrameWriter {
-
- private boolean propagateInput;
- private boolean retainNull;
- private ArrayTupleBuilder tb;
- private FrameTupleAppender appender;
- private IRecordDataParser<T> dataParser;
- private ILookupRecordReader<? extends T> recordReader;
- private RecordIdReader ridReader;
- private FrameTupleAccessor tupleAccessor;
- private IFrameWriter writer;
- private FrameTupleReference frameTuple;
- private ArrayTupleBuilder missingTupleBuild;
-
- public LookupAdapter(IRecordDataParser<T> dataParser, ILookupRecordReader<? extends T> recordReader,
- RecordDescriptor inRecDesc, RecordIdReader ridReader, boolean propagateInput, boolean retainNull,
- IMissingWriterFactory iNullWriterFactory, IHyracksTaskContext ctx, IFrameWriter writer)
- throws HyracksDataException {
- this.dataParser = dataParser;
- this.recordReader = recordReader;
- this.propagateInput = propagateInput;
- this.retainNull = retainNull;
- this.tupleAccessor = new FrameTupleAccessor(inRecDesc);
- this.ridReader = ridReader;
- ridReader.set(tupleAccessor, inRecDesc);
- configurePropagation(iNullWriterFactory);
- appender = new FrameTupleAppender(new VSizeFrame(ctx));
- this.writer = writer;
- }
-
- private void configurePropagation(IMissingWriterFactory iNullWriterFactory) {
- if (propagateInput) {
- // This LookupAdapter generates an external record as its output.
- // Thus, we add 1.
- tb = new ArrayTupleBuilder(tupleAccessor.getFieldCount() + 1);
- frameTuple = new FrameTupleReference();
- } else {
- tb = new ArrayTupleBuilder(1);
- }
- if (retainNull) {
- IMissingWriter missingWriter = iNullWriterFactory.createMissingWriter();
- missingTupleBuild = new ArrayTupleBuilder(1);
- DataOutput out = missingTupleBuild.getDataOutput();
- try {
- missingWriter.writeMissing(out);
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- missingTupleBuild = null;
- }
- }
-
- @Override
- public void fail() throws HyracksDataException {
- try {
- recordReader.fail();
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- } finally {
- writer.fail();
- }
- }
-
- @Override
- public void open() throws HyracksDataException {
- writer.open();
-
- }
-
- @Override
- public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
- try {
- tupleAccessor.reset(buffer);
- int tupleIndex = 0;
- int tupleCount = tupleAccessor.getTupleCount();
- while (tupleIndex < tupleCount) {
- IRawRecord<? extends T> record = null;
- RecordId rid = ridReader.read(tupleIndex);
- if (rid != null) {
- record = recordReader.read(rid);
- }
- tb.reset();
- if (propagateInput) {
- propagateInputFields(tupleIndex);
- }
- if (record != null) {
- if (dataParser.parse(record, tb.getDataOutput())) {
- tb.addFieldEndOffset();
- DataflowUtils.addTupleToFrame(appender, tb, writer);
- }
- } else if (retainNull) {
- tb.getDataOutput().write(missingTupleBuild.getByteArray());
- tb.addFieldEndOffset();
- DataflowUtils.addTupleToFrame(appender, tb, writer);
- }
- tupleIndex++;
- }
- } catch (Exception e) {
- throw HyracksDataException.create(e);
- }
- }
-
- private void propagateInputFields(int idx) throws IOException {
- frameTuple.reset(tupleAccessor, idx);
- for (int i = 0; i < frameTuple.getFieldCount(); i++) {
- tb.getDataOutput().write(frameTuple.getFieldData(i), frameTuple.getFieldStart(i),
- frameTuple.getFieldLength(i));
- tb.addFieldEndOffset();
- }
- }
-
- @Override
- public void close() throws HyracksDataException {
- try {
- appender.write(writer, true);
- } catch (Exception e) {
- writer.fail();
- throw e;
- } finally {
- writer.close();
- }
- }
-
- @Override
- public void flush() throws HyracksDataException {
- appender.flush(writer);
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java
deleted file mode 100644
index 58a2413..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java
+++ /dev/null
@@ -1,148 +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.asterix.external.indexing;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.util.Date;
-
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
-import org.apache.asterix.om.base.ADateTime;
-import org.apache.asterix.om.base.AInt64;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.ARecord;
-import org.apache.asterix.om.base.AString;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.util.CleanupUtils;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-import org.apache.hyracks.storage.am.btree.impls.RangePredicate;
-import org.apache.hyracks.storage.am.btree.util.BTreeUtils;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.util.ResourceReleaseUtils;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor;
-import org.apache.hyracks.storage.common.IIndexCursor;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.MultiComparator;
-
-/*
- * This class was created specifically to facilitate accessing
- * external file index when doing external lookup during runtime
- */
-@SuppressWarnings({ "rawtypes", "unchecked" })
-public class ExternalFileIndexAccessor {
- private IIndexDataflowHelper indexDataflowHelper;
- private IHyracksTaskContext ctx;
- private ExternalBTree index;
- private ArrayTupleBuilder searchKeyTupleBuilder;
- private ArrayTupleReference searchKey;
- private AMutableInt32 currentFileNumber = new AMutableInt32(-1);
- private ISerializerDeserializer intSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
- private RangePredicate searchPredicate;
- private ILSMIndexAccessor fileIndexAccessor;
- private IIndexCursor fileIndexSearchCursor;
- private ISearchOperationCallbackFactory searchCallbackFactory;
- private int version;
- private ISerializerDeserializer externalFileRecordSerde = FilesIndexDescription.createExternalFileRecordSerde();
-
- public ExternalFileIndexAccessor(IIndexDataflowHelper indexDataflowHelper,
- ISearchOperationCallbackFactory searchCallbackFactory, int version) {
- this.indexDataflowHelper = indexDataflowHelper;
- this.searchCallbackFactory = searchCallbackFactory;
- this.version = version;
- }
-
- public void open() throws HyracksDataException {
- // Open the index and get the instance
- indexDataflowHelper.open();
- index = (ExternalBTree) indexDataflowHelper.getIndexInstance();
- // Create search key and search predicate objects
- searchKey = new ArrayTupleReference();
- searchKeyTupleBuilder = new ArrayTupleBuilder(FilesIndexDescription.FILE_KEY_SIZE);
- searchKeyTupleBuilder.reset();
- searchKeyTupleBuilder.addField(intSerde, currentFileNumber);
- searchKey.reset(searchKeyTupleBuilder.getFieldEndOffsets(), searchKeyTupleBuilder.getByteArray());
- MultiComparator searchCmp = BTreeUtils.getSearchMultiComparator(index.getComparatorFactories(), searchKey);
- searchPredicate = new RangePredicate(searchKey, searchKey, true, true, searchCmp, searchCmp);
-
- // create the accessor and the cursor using the passed version
- ISearchOperationCallback searchCallback = searchCallbackFactory
- .createSearchOperationCallback(indexDataflowHelper.getResource().getId(), ctx, null);
- fileIndexAccessor = index.createAccessor(searchCallback, version);
- fileIndexSearchCursor = fileIndexAccessor.createSearchCursor(false);
- }
-
- public void lookup(int fileId, ExternalFile file) throws HyracksDataException {
- // Set search parameters
- currentFileNumber.setValue(fileId);
- searchKeyTupleBuilder.reset();
- searchKeyTupleBuilder.addField(intSerde, currentFileNumber);
- searchKey.reset(searchKeyTupleBuilder.getFieldEndOffsets(), searchKeyTupleBuilder.getByteArray());
- fileIndexSearchCursor.close();
-
- // Perform search
- fileIndexAccessor.search(fileIndexSearchCursor, searchPredicate);
- if (fileIndexSearchCursor.hasNext()) {
- fileIndexSearchCursor.next();
- ITupleReference tuple = fileIndexSearchCursor.getTuple();
- // Deserialize
- byte[] serRecord = tuple.getFieldData(FilesIndexDescription.FILE_PAYLOAD_INDEX);
- int recordStartOffset = tuple.getFieldStart(FilesIndexDescription.FILE_PAYLOAD_INDEX);
- int recordLength = tuple.getFieldLength(FilesIndexDescription.FILE_PAYLOAD_INDEX);
- ByteArrayInputStream stream = new ByteArrayInputStream(serRecord, recordStartOffset, recordLength);
- DataInput in = new DataInputStream(stream);
- ARecord externalFileRecord = (ARecord) externalFileRecordSerde.deserialize(in);
- setFile(externalFileRecord, file);
- } else {
- // This should never happen
- throw new RuntimeDataException(ErrorCode.INDEXING_EXTERNAL_FILE_INDEX_ACCESSOR_UNABLE_TO_FIND_FILE_INDEX);
- }
- }
-
- private void setFile(ARecord externalFileRecord, ExternalFile file) {
- file.setFileName(
- ((AString) externalFileRecord.getValueByPos(FilesIndexDescription.EXTERNAL_FILE_NAME_FIELD_INDEX))
- .getStringValue());
- file.setSize(((AInt64) externalFileRecord.getValueByPos(FilesIndexDescription.EXTERNAL_FILE_SIZE_FIELD_INDEX))
- .getLongValue());
- file.setLastModefiedTime(new Date(
- ((ADateTime) externalFileRecord.getValueByPos(FilesIndexDescription.EXTERNAL_FILE_MOD_DATE_FIELD_INDEX))
- .getChrononTime()));
- }
-
- public void close() throws HyracksDataException {
- Throwable failure = ResourceReleaseUtils.close(fileIndexSearchCursor, null);
- failure = CleanupUtils.destroy(failure, fileIndexSearchCursor, fileIndexAccessor);
- failure = ResourceReleaseUtils.close(indexDataflowHelper, failure);
- if (failure != null) {
- throw HyracksDataException.create(failure);
- }
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java
deleted file mode 100644
index 2597782..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java
+++ /dev/null
@@ -1,86 +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.asterix.external.indexing;
-
-import org.apache.asterix.builders.RecordBuilder;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
-import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.AMutableString;
-import org.apache.asterix.om.base.IAObject;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-
-@SuppressWarnings("unchecked")
-public class FileIndexTupleTranslator {
- private final ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(FilesIndexDescription.FILE_INDEX_TUPLE_SIZE);
- private RecordBuilder recordBuilder = new RecordBuilder();
- private ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
- private AMutableInt32 aInt32 = new AMutableInt32(0);
- private AMutableInt64 aInt64 = new AMutableInt64(0);
- private AMutableString aString = new AMutableString(null);
- private AMutableDateTime aDateTime = new AMutableDateTime(0);
- private ISerializerDeserializer<IAObject> stringSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
- private ISerializerDeserializer<IAObject> dateTimeSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADATETIME);
- private ISerializerDeserializer<IAObject> longSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
- private ArrayTupleReference tuple = new ArrayTupleReference();
-
- public ITupleReference getTupleFromFile(ExternalFile file) throws HyracksDataException {
- tupleBuilder.reset();
- //File Number
- aInt32.setValue(file.getFileNumber());
- FilesIndexDescription.FILE_NUMBER_SERDE.serialize(aInt32, tupleBuilder.getDataOutput());
- tupleBuilder.addFieldEndOffset();
-
- //File Record
- recordBuilder.reset(FilesIndexDescription.EXTERNAL_FILE_RECORD_TYPE);
- // write field 0 (File Name)
- fieldValue.reset();
- aString.setValue(file.getFileName());
- stringSerde.serialize(aString, fieldValue.getDataOutput());
- recordBuilder.addField(0, fieldValue);
-
- //write field 1 (File Size)
- fieldValue.reset();
- aInt64.setValue(file.getSize());
- longSerde.serialize(aInt64, fieldValue.getDataOutput());
- recordBuilder.addField(1, fieldValue);
-
- //write field 2 (File Mod Date)
- fieldValue.reset();
- aDateTime.setValue(file.getLastModefiedTime().getTime());
- dateTimeSerde.serialize(aDateTime, fieldValue.getDataOutput());
- recordBuilder.addField(2, fieldValue);
-
- //write the record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
- tupleBuilder.addFieldEndOffset();
- tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
- return tuple;
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileOffsetIndexer.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileOffsetIndexer.java
deleted file mode 100644
index 34c8795..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileOffsetIndexer.java
+++ /dev/null
@@ -1,79 +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.asterix.external.indexing;
-
-import java.io.IOException;
-
-import org.apache.asterix.external.api.IExternalIndexer;
-import org.apache.asterix.external.api.IIndexingDatasource;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.IAObject;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.mapred.RecordReader;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-
-public class FileOffsetIndexer implements IExternalIndexer {
-
- private static final long serialVersionUID = 1L;
- public static final int NUM_OF_FIELDS = 2;
- protected final AMutableInt32 fileNumber = new AMutableInt32(0);
- protected final AMutableInt64 offset = new AMutableInt64(0);
- protected RecordReader<?, ? extends Writable> recordReader;
-
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<IAObject> intSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<IAObject> longSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
-
- @Override
- public void reset(IIndexingDatasource dataSource) throws HyracksDataException {
- try {
- //TODO: Make it more generic since we can't assume it is always going to be HDFS records
- fileNumber.setValue(dataSource.getSnapshot().get(dataSource.getCurrentSplitIndex()).getFileNumber());
- recordReader = dataSource.getReader();
- offset.setValue(recordReader.getPos());
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public void index(ArrayTupleBuilder tb) throws HyracksDataException {
- try {
- tb.addField(intSerde, fileNumber);
- tb.addField(longSerde, offset);
- // Get position for next index(tb) call
- offset.setValue(recordReader.getPos());
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public int getNumberOfFields() {
- return NUM_OF_FIELDS;
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FilesIndexDescription.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FilesIndexDescription.java
deleted file mode 100644
index 45ccfa0..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FilesIndexDescription.java
+++ /dev/null
@@ -1,92 +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.asterix.external.indexing;
-
-import java.io.IOException;
-
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
-import org.apache.asterix.formats.nontagged.TypeTraitProvider;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
-
-@SuppressWarnings("rawtypes")
-public class FilesIndexDescription {
- public static final int FILE_INDEX_TUPLE_SIZE = 2;
- public static final int FILE_KEY_INDEX = 0;
- public static final int FILE_KEY_SIZE = 1;
- public static final int FILE_PAYLOAD_INDEX = 1;
- private static final String[] payloadFieldNames = { "FileName", "FileSize", "FileModDate" };
- private static final IAType[] payloadFieldTypes =
- { BuiltinType.ASTRING, BuiltinType.AINT64, BuiltinType.ADATETIME };
-
- public static final int[] BLOOM_FILTER_FIELDS = { 0 };
- public static final int EXTERNAL_FILE_NAME_FIELD_INDEX = 0;
- public static final int EXTERNAL_FILE_SIZE_FIELD_INDEX = 1;
- public static final int EXTERNAL_FILE_MOD_DATE_FIELD_INDEX = 2;
-
- public static final ARecordType EXTERNAL_FILE_RECORD_TYPE =
- new ARecordType("ExternalFileRecordType", payloadFieldNames, payloadFieldTypes, true);
- public static final ITypeTraits[] EXTERNAL_FILE_BUDDY_BTREE_TYPE_TRAITS =
- new ITypeTraits[] { TypeTraitProvider.INSTANCE.getTypeTrait(IndexingConstants.FILE_NUMBER_FIELD_TYPE) };
- public static final ITypeTraits[] EXTERNAL_FILE_INDEX_TYPE_TRAITS =
- new ITypeTraits[] { TypeTraitProvider.INSTANCE.getTypeTrait(IndexingConstants.FILE_NUMBER_FIELD_TYPE),
- TypeTraitProvider.INSTANCE.getTypeTrait(EXTERNAL_FILE_RECORD_TYPE) };
- public static final IBinaryComparatorFactory[] FILES_INDEX_COMP_FACTORIES = new IBinaryComparatorFactory[] {
- BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(BuiltinType.AINT32, true) };
- public static final ISerializerDeserializer FILE_NUMBER_SERDE =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(IndexingConstants.FILE_NUMBER_FIELD_TYPE);
- public static final ISerializerDeserializer[] EXTERNAL_FILE_BUDDY_BTREE_FIELDS =
- new ISerializerDeserializer[] { FILE_NUMBER_SERDE };
- public static final RecordDescriptor FILE_BUDDY_BTREE_RECORD_DESCRIPTOR =
- new RecordDescriptor(EXTERNAL_FILE_BUDDY_BTREE_FIELDS, EXTERNAL_FILE_BUDDY_BTREE_TYPE_TRAITS);
-
- private FilesIndexDescription() {
- }
-
- public static ISerializerDeserializer createExternalFileRecordSerde() {
- return SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(EXTERNAL_FILE_RECORD_TYPE);
- }
-
- public static ISerializerDeserializer[] createExternalFileTupleFieldsSerdes() {
- return new ISerializerDeserializer[] { FILE_NUMBER_SERDE, createExternalFileRecordSerde() };
- }
-
- public static RecordDescriptor createFileIndexRecordDescriptor() {
- return new RecordDescriptor(createExternalFileTupleFieldsSerdes(), EXTERNAL_FILE_INDEX_TYPE_TRAITS);
- }
-
- @SuppressWarnings("unchecked")
- public static void getBuddyBTreeTupleFromFileNumber(ArrayTupleReference tuple, ArrayTupleBuilder tupleBuilder,
- AMutableInt32 aInt32) throws IOException, AsterixException {
- tupleBuilder.reset();
- FILE_NUMBER_SERDE.serialize(aInt32, tupleBuilder.getDataOutput());
- tupleBuilder.addFieldEndOffset();
- tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
deleted file mode 100644
index f22693a..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
+++ /dev/null
@@ -1,324 +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.asterix.external.indexing;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Random;
-
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.mapred.InputSplit;
-import org.apache.hyracks.api.client.NodeControllerInfo;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.HyracksException;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class IndexingScheduler {
- private static final Logger LOGGER = LogManager.getLogger();
-
- /** a list of NCs */
- private String[] NCs;
-
- /** a map from ip to NCs */
- private Map<String, List<String>> ipToNcMapping = new HashMap<String, List<String>>();
-
- /** a map from the NC name to the index */
- private Map<String, Integer> ncNameToIndex = new HashMap<String, Integer>();
-
- /**
- * The constructor of the scheduler.
- *
- * @param ncNameToNcInfos
- * @throws HyracksException
- */
- public IndexingScheduler(Map<String, NodeControllerInfo> ncNameToNcInfos) throws HyracksException {
- try {
- loadIPAddressToNCMap(ncNameToNcInfos);
- } catch (Exception e) {
- throw HyracksException.create(e);
- }
- }
-
- /**
- * Set location constraints for a file scan operator with a list of file
- * splits. It tries to assign splits to their local machines fairly
- * Locality is more important than fairness
- *
- * @throws HyracksDataException
- */
- public String[] getLocationConstraints(InputSplit[] splits) throws HyracksException {
- if (splits == null) {
- /* deal the case when the splits array is null */
- return new String[] {};
- }
- int[] workloads = new int[NCs.length];
- Arrays.fill(workloads, 0);
- String[] locations = new String[splits.length];
- Map<String, IntWritable> locationToNumOfSplits = new HashMap<String, IntWritable>();
- /*
- * upper bound is number of splits
- */
- int upperBoundSlots = splits.length;
-
- try {
- Random random = new Random(System.currentTimeMillis());
- boolean scheduled[] = new boolean[splits.length];
- Arrays.fill(scheduled, false);
- /*
- * scan the splits and build the popularity map
- * give the machines with less local splits more scheduling priority
- */
- buildPopularityMap(splits, locationToNumOfSplits);
- HashMap<String, Integer> locationToNumOfAssignement = new HashMap<String, Integer>();
- for (String location : locationToNumOfSplits.keySet()) {
- locationToNumOfAssignement.put(location, 0);
- }
- /*
- * push data-local upper-bounds slots to each machine
- */
- scheduleLocalSlots(splits, workloads, locations, upperBoundSlots, random, scheduled, locationToNumOfSplits,
- locationToNumOfAssignement);
-
- int dataLocalCount = 0;
- for (int i = 0; i < scheduled.length; i++) {
- if (scheduled[i] == true) {
- dataLocalCount++;
- }
- }
- LOGGER.info("Data local rate: "
- + (scheduled.length == 0 ? 0.0 : ((float) dataLocalCount / (float) (scheduled.length))));
- /*
- * push non-data-local upper-bounds slots to each machine
- */
- locationToNumOfAssignement.clear();
- for (String nc : NCs) {
- locationToNumOfAssignement.put(nc, 0);
- }
- for (int i = 0; i < scheduled.length; i++) {
- if (scheduled[i]) {
- locationToNumOfAssignement.put(locations[i], locationToNumOfAssignement.get(locations[i]) + 1);
- }
- }
-
- scheduleNonLocalSlots(splits, workloads, locations, upperBoundSlots, scheduled, locationToNumOfAssignement);
- return locations;
- } catch (IOException e) {
- throw HyracksException.create(e);
- }
- }
-
- /**
- * Schedule non-local slots to each machine
- *
- * @param splits
- * The HDFS file splits.
- * @param workloads
- * The current capacity of each machine.
- * @param locations
- * The result schedule.
- * @param slotLimit
- * The maximum slots of each machine.
- * @param scheduled
- * Indicate which slot is scheduled.
- * @param locationToNumOfAssignement
- */
- private void scheduleNonLocalSlots(InputSplit[] splits, final int[] workloads, String[] locations, int slotLimit,
- boolean[] scheduled, final HashMap<String, Integer> locationToNumOfAssignement)
- throws IOException, UnknownHostException {
-
- PriorityQueue<String> scheduleCadndiates =
- new PriorityQueue<String>(NCs.length, Comparator.comparing(locationToNumOfAssignement::get));
-
- scheduleCadndiates.addAll(Arrays.asList(NCs));
- /*
- * schedule no-local file reads
- */
- for (int i = 0; i < splits.length; i++) {
- /* if there is no data-local NC choice, choose a random one */
- if (!scheduled[i]) {
- String selectedNcName = scheduleCadndiates.remove();
- if (selectedNcName != null) {
- int ncIndex = ncNameToIndex.get(selectedNcName);
- workloads[ncIndex]++;
- scheduled[i] = true;
- locations[i] = selectedNcName;
- locationToNumOfAssignement.put(selectedNcName, workloads[ncIndex]);
- scheduleCadndiates.add(selectedNcName);
- }
- }
- }
- }
-
- /**
- * Schedule data-local slots to each machine.
- *
- * @param splits
- * The HDFS file splits.
- * @param workloads
- * The current capacity of each machine.
- * @param locations
- * The result schedule.
- * @param slots
- * The maximum slots of each machine.
- * @param random
- * The random generator.
- * @param scheduled
- * Indicate which slot is scheduled.
- * @throws IOException
- * @throws UnknownHostException
- */
- private void scheduleLocalSlots(InputSplit[] splits, int[] workloads, String[] locations, int slots, Random random,
- boolean[] scheduled, final Map<String, IntWritable> locationToNumSplits,
- final HashMap<String, Integer> locationToNumOfAssignement) throws IOException, UnknownHostException {
- /* scheduling candidates will be ordered inversely according to their popularity */
- PriorityQueue<String> scheduleCadndiates = new PriorityQueue<>(3, (s1, s2) -> {
- int assignmentDifference = locationToNumOfAssignement.get(s1).compareTo(locationToNumOfAssignement.get(s2));
- if (assignmentDifference != 0) {
- return assignmentDifference;
- }
- return locationToNumSplits.get(s1).compareTo(locationToNumSplits.get(s2));
- });
-
- for (int i = 0; i < splits.length; i++) {
- if (scheduled[i]) {
- continue;
- }
- /*
- * get the location of all the splits
- */
- String[] locs = splits[i].getLocations();
- if (locs.length > 0) {
- scheduleCadndiates.clear();
- Collections.addAll(scheduleCadndiates, locs);
-
- for (String candidate : scheduleCadndiates) {
- /*
- * get all the IP addresses from the name
- */
- InetAddress[] allIps = InetAddress.getAllByName(candidate);
- /*
- * iterate overa all ips
- */
- for (InetAddress ip : allIps) {
- /*
- * if the node controller exists
- */
- if (ipToNcMapping.get(ip.getHostAddress()) != null) {
- /*
- * set the ncs
- */
- List<String> dataLocations = ipToNcMapping.get(ip.getHostAddress());
- int arrayPos = random.nextInt(dataLocations.size());
- String nc = dataLocations.get(arrayPos);
- int pos = ncNameToIndex.get(nc);
- /*
- * check if the node is already full
- */
- if (workloads[pos] < slots) {
- locations[i] = nc;
- workloads[pos]++;
- scheduled[i] = true;
- locationToNumOfAssignement.put(candidate,
- locationToNumOfAssignement.get(candidate) + 1);
- break;
- }
- }
- }
- /*
- * break the loop for data-locations if the schedule has
- * already been found
- */
- if (scheduled[i]) {
- break;
- }
- }
- }
- }
- }
-
- /**
- * Scan the splits once and build a popularity map
- *
- * @param splits
- * the split array
- * @param locationToNumOfSplits
- * the map to be built
- * @throws IOException
- */
- private void buildPopularityMap(InputSplit[] splits, Map<String, IntWritable> locationToNumOfSplits)
- throws IOException {
- for (InputSplit split : splits) {
- String[] locations = split.getLocations();
- for (String loc : locations) {
- IntWritable locCount = locationToNumOfSplits.get(loc);
- if (locCount == null) {
- locCount = new IntWritable(0);
- locationToNumOfSplits.put(loc, locCount);
- }
- locCount.set(locCount.get() + 1);
- }
- }
- }
-
- /**
- * Load the IP-address-to-NC map from the NCNameToNCInfoMap
- *
- * @param ncNameToNcInfos
- * @throws HyracksException
- */
- private void loadIPAddressToNCMap(Map<String, NodeControllerInfo> ncNameToNcInfos) throws HyracksException {
- try {
- NCs = new String[ncNameToNcInfos.size()];
- ipToNcMapping.clear();
- ncNameToIndex.clear();
- int i = 0;
-
- /*
- * build the IP address to NC map
- */
- for (Map.Entry<String, NodeControllerInfo> entry : ncNameToNcInfos.entrySet()) {
- String ipAddr = InetAddress.getByAddress(entry.getValue().getNetworkAddress().lookupIpAddress())
- .getHostAddress();
- List<String> matchedNCs = ipToNcMapping.computeIfAbsent(ipAddr, k -> new ArrayList<>());
- matchedNCs.add(entry.getKey());
- NCs[i] = entry.getKey();
- i++;
- }
-
- /*
- * set up the NC name to index mapping
- */
- for (i = 0; i < NCs.length; i++) {
- ncNameToIndex.put(NCs[i], i);
- }
- } catch (Exception e) {
- throw HyracksException.create(e);
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RCRecordIdReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RCRecordIdReader.java
deleted file mode 100644
index 07d09db..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RCRecordIdReader.java
+++ /dev/null
@@ -1,43 +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.asterix.external.indexing;
-
-import org.apache.asterix.om.base.AInt32;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class RCRecordIdReader extends RecordIdReader {
-
- public RCRecordIdReader(int[] ridFields) {
- super(ridFields);
- }
-
- @Override
- public RecordId read(int index) throws HyracksDataException {
- if (super.read(index) == null) {
- return null;
- }
- // Get row number
- bbis.setByteBuffer(frameBuffer, tupleStartOffset
- + tupleAccessor.getFieldStartOffset(index, ridFields[IndexingConstants.ROW_NUMBER_FIELD_INDEX]));
- rid.setRow(
- ((AInt32) inRecDesc.getFields()[ridFields[IndexingConstants.ROW_NUMBER_FIELD_INDEX]].deserialize(dis))
- .getIntegerValue());
- return rid;
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordColumnarIndexer.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordColumnarIndexer.java
deleted file mode 100644
index 6cecc20..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordColumnarIndexer.java
+++ /dev/null
@@ -1,94 +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.asterix.external.indexing;
-
-import java.io.IOException;
-
-import org.apache.asterix.external.api.IExternalIndexer;
-import org.apache.asterix.external.api.IIndexingDatasource;
-import org.apache.asterix.external.input.record.reader.hdfs.HDFSRecordReader;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.IAObject;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.mapred.RecordReader;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-
-public class RecordColumnarIndexer implements IExternalIndexer {
-
- private static final long serialVersionUID = 1L;
- public static final int NUM_OF_FIELDS = 3;
- protected final AMutableInt32 fileNumber = new AMutableInt32(0);
- protected final AMutableInt64 offset = new AMutableInt64(0);
- protected long nextOffset;
- protected final AMutableInt32 rowNumber = new AMutableInt32(0);
- protected RecordReader<?, Writable> recordReader;
-
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<IAObject> intSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<IAObject> longSerde =
- SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
-
- @Override
- public void reset(IIndexingDatasource reader) throws HyracksDataException {
- try {
- //TODO: Make this more generic. right now, it works because we only index hdfs files.
- @SuppressWarnings("unchecked")
- HDFSRecordReader<?, Writable> hdfsReader = (HDFSRecordReader<?, Writable>) reader;
- fileNumber.setValue(hdfsReader.getSnapshot().get(hdfsReader.getCurrentSplitIndex()).getFileNumber());
- recordReader = hdfsReader.getReader();
- offset.setValue(recordReader.getPos());
-
- nextOffset = offset.getLongValue();
- rowNumber.setValue(0);
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public void index(ArrayTupleBuilder tb) throws HyracksDataException {
- try {
- if (recordReader.getPos() != nextOffset) {
- // start of a new group
- offset.setValue(nextOffset);
- nextOffset = recordReader.getPos();
- rowNumber.setValue(0);
- }
- tb.addField(intSerde, fileNumber);
- tb.addField(longSerde, offset);
- tb.addField(intSerde, rowNumber);
- rowNumber.setValue(rowNumber.getIntegerValue() + 1);
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public int getNumberOfFields() {
- return NUM_OF_FIELDS;
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordId.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordId.java
deleted file mode 100644
index 9027101..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordId.java
+++ /dev/null
@@ -1,54 +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.asterix.external.indexing;
-
-public class RecordId {
- public static enum RecordIdType {
- OFFSET,
- RC
- }
-
- private int fileId;
- private long offset;
- private int row;
-
- public int getFileId() {
- return fileId;
- }
-
- public void setFileId(int fileId) {
- this.fileId = fileId;
- }
-
- public long getOffset() {
- return offset;
- }
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-
- public int getRow() {
- return row;
- }
-
- public void setRow(int row) {
- this.row = row;
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java
deleted file mode 100644
index 3cca7e1..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java
+++ /dev/null
@@ -1,78 +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.asterix.external.indexing;
-
-import java.io.DataInputStream;
-import java.nio.ByteBuffer;
-
-import org.apache.asterix.om.base.AInt32;
-import org.apache.asterix.om.base.AInt64;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
-
-public class RecordIdReader {
-
- private final static byte MISSING_BYTE = ATypeTag.SERIALIZED_MISSING_TYPE_TAG;
- protected FrameTupleAccessor tupleAccessor;
- protected int fieldSlotsLength;
- protected int[] ridFields;
- protected RecordId rid;
- protected RecordDescriptor inRecDesc;
- protected ByteBufferInputStream bbis;
- protected DataInputStream dis;
- protected int tupleStartOffset;
- protected ByteBuffer frameBuffer;
-
- public RecordIdReader(int[] ridFields) {
- this.ridFields = ridFields;
- this.rid = new RecordId();
- }
-
- public void set(FrameTupleAccessor accessor, RecordDescriptor inRecDesc) {
- this.tupleAccessor = accessor;
- this.fieldSlotsLength = accessor.getFieldSlotsLength();
- this.inRecDesc = inRecDesc;
- this.bbis = new ByteBufferInputStream();
- this.dis = new DataInputStream(bbis);
- }
-
- public RecordId read(int index) throws HyracksDataException {
- tupleStartOffset = tupleAccessor.getTupleStartOffset(index) + fieldSlotsLength;
- int fileNumberStartOffset =
- tupleAccessor.getFieldStartOffset(index, ridFields[IndexingConstants.FILE_NUMBER_FIELD_INDEX]);
- frameBuffer = tupleAccessor.getBuffer();
- if (frameBuffer.get(tupleStartOffset + fileNumberStartOffset) == MISSING_BYTE) {
- return null;
- }
- // Get file number
- bbis.setByteBuffer(frameBuffer, tupleStartOffset + fileNumberStartOffset);
- rid.setFileId(
- ((AInt32) inRecDesc.getFields()[ridFields[IndexingConstants.FILE_NUMBER_FIELD_INDEX]].deserialize(dis))
- .getIntegerValue());
- // Get record group offset
- bbis.setByteBuffer(frameBuffer, tupleStartOffset
- + tupleAccessor.getFieldStartOffset(index, ridFields[IndexingConstants.RECORD_OFFSET_FIELD_INDEX]));
- rid.setOffset(((AInt64) inRecDesc.getFields()[ridFields[IndexingConstants.RECORD_OFFSET_FIELD_INDEX]]
- .deserialize(dis)).getLongValue());
- return rid;
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReaderFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReaderFactory.java
deleted file mode 100644
index d0bf2ff..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReaderFactory.java
+++ /dev/null
@@ -1,38 +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.asterix.external.indexing;
-
-import java.util.Map;
-
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.util.HDFSUtils;
-
-public class RecordIdReaderFactory {
-
- public static RecordIdReader create(Map<String, String> configuration, int[] ridFields) throws AsterixException {
- switch (HDFSUtils.getRecordIdType(configuration)) {
- case OFFSET:
- return new RecordIdReader(ridFields);
- case RC:
- return new RCRecordIdReader(ridFields);
- default:
- throw new AsterixException("Unknown Record Id type: " + HDFSUtils.getRecordIdType(configuration));
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
index b190e33..596edb2 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
@@ -37,13 +37,11 @@
import org.apache.asterix.external.api.IRecordReader;
import org.apache.asterix.external.api.IRecordReaderFactory;
import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.IndexingScheduler;
import org.apache.asterix.external.input.record.reader.IndexingStreamRecordReader;
import org.apache.asterix.external.input.record.reader.hdfs.HDFSRecordReader;
import org.apache.asterix.external.input.record.reader.hdfs.parquet.ParquetFileRecordReader;
import org.apache.asterix.external.input.record.reader.stream.StreamRecordReader;
import org.apache.asterix.external.input.stream.HDFSInputStream;
-import org.apache.asterix.external.provider.ExternalIndexerProvider;
import org.apache.asterix.external.provider.StreamRecordReaderProvider;
import org.apache.asterix.external.util.ExternalDataConstants;
import org.apache.asterix.external.util.ExternalDataUtils;
@@ -77,7 +75,6 @@
protected ConfFactory confFactory;
protected boolean configured = false;
protected static Scheduler hdfsScheduler;
- protected static IndexingScheduler indexingScheduler;
protected static Boolean initialized = false;
protected static Object initLock = new Object();
protected List<ExternalFile> files;
@@ -117,11 +114,7 @@
} else {
inputSplits = HDFSUtils.getSplits(conf, files);
}
- if (indexingOp) {
- readSchedule = indexingScheduler.getLocationConstraints(inputSplits);
- } else {
- readSchedule = hdfsScheduler.getLocationConstraints(inputSplits);
- }
+ readSchedule = hdfsScheduler.getLocationConstraints(inputSplits);
inputSplitsFactory = new InputSplitsFactory(inputSplits);
read = new boolean[readSchedule.length];
Arrays.fill(read, false);
@@ -214,7 +207,6 @@
synchronized (initLock) {
if (!initialized) {
hdfsScheduler = HDFSUtils.initializeHDFSScheduler(serviceCtx);
- indexingScheduler = HDFSUtils.initializeIndexingHDFSScheduler(serviceCtx);
initialized = true;
}
}
@@ -243,7 +235,7 @@
public IRecordReader<? extends Object> createRecordReader(IHyracksTaskContext ctx, int partition)
throws HyracksDataException {
try {
- IExternalIndexer indexer = files == null ? null : ExternalIndexerProvider.getIndexer(configuration);
+ IExternalIndexer indexer = null;
if (recordReaderClazz != null) {
StreamRecordReader streamReader = (StreamRecordReader) recordReaderClazz.getConstructor().newInstance();
streamReader.configure(ctx, createInputStream(ctx, partition, indexer), configuration);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractCharRecordLookupReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractCharRecordLookupReader.java
deleted file mode 100644
index 6c7c42e..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractCharRecordLookupReader.java
+++ /dev/null
@@ -1,79 +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.asterix.external.input.record.reader.hdfs;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.asterix.external.api.IRawRecord;
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.indexing.RecordId;
-import org.apache.asterix.external.input.record.CharArrayRecord;
-import org.apache.asterix.external.util.ExternalDataConstants;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.io.Text;
-
-public abstract class AbstractCharRecordLookupReader extends AbstractHDFSLookupRecordReader<char[]> {
- public AbstractCharRecordLookupReader(ExternalFileIndexAccessor snapshotAccessor, FileSystem fs,
- Configuration conf) {
- super(snapshotAccessor, fs, conf);
- }
-
- protected CharArrayRecord record = new CharArrayRecord();
- protected Text value = new Text();
- protected CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
- protected ByteBuffer reusableByteBuffer = ByteBuffer.allocateDirect(ExternalDataConstants.DEFAULT_BUFFER_SIZE);
- protected CharBuffer reusableCharBuffer = CharBuffer.allocate(ExternalDataConstants.DEFAULT_BUFFER_SIZE);
-
- @Override
- public Class<?> getRecordClass() throws IOException {
- return char[].class;
- }
-
- @Override
- protected IRawRecord<char[]> lookup(RecordId rid) throws IOException {
- record.reset();
- readRecord(rid);
- writeRecord();
- return record;
- }
-
- protected abstract void readRecord(RecordId rid) throws IOException;
-
- private void writeRecord() throws IOException {
- reusableByteBuffer.clear();
- if (reusableByteBuffer.remaining() < value.getLength()) {
- reusableByteBuffer = ByteBuffer
- .allocateDirect((int) (value.getLength() * ExternalDataConstants.DEFAULT_BUFFER_INCREMENT_FACTOR));
- }
- reusableByteBuffer.put(value.getBytes(), 0, value.getLength());
- reusableByteBuffer.flip();
- while (reusableByteBuffer.hasRemaining()) {
- reusableCharBuffer.clear();
- decoder.decode(reusableByteBuffer, reusableCharBuffer, false);
- reusableCharBuffer.flip();
- record.append(reusableCharBuffer);
- }
- record.endRecord();
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractHDFSLookupRecordReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractHDFSLookupRecordReader.java
deleted file mode 100644
index 28abddb..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/AbstractHDFSLookupRecordReader.java
+++ /dev/null
@@ -1,113 +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.asterix.external.input.record.reader.hdfs;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.asterix.external.api.ILookupRecordReader;
-import org.apache.asterix.external.api.IRawRecord;
-import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.indexing.RecordId;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public abstract class AbstractHDFSLookupRecordReader<T> implements ILookupRecordReader<T> {
-
- protected int fileId;
- private ExternalFileIndexAccessor snapshotAccessor;
- protected ExternalFile file;
- protected FileSystem fs;
- protected Configuration conf;
- protected boolean replaced;
-
- public AbstractHDFSLookupRecordReader(ExternalFileIndexAccessor snapshotAccessor, FileSystem fs,
- Configuration conf) {
- this.snapshotAccessor = snapshotAccessor;
- this.fs = fs;
- this.conf = conf;
- this.fileId = -1;
- this.file = new ExternalFile();
- }
-
- @Override
- public void configure(Map<String, String> configurations) throws Exception {
- }
-
- @Override
- public IRawRecord<T> read(RecordId rid) throws Exception {
- if (rid.getFileId() != fileId) {
- // close current file
- closeFile();
- // lookup new file
- snapshotAccessor.lookup(rid.getFileId(), file);
- fileId = rid.getFileId();
- try {
- validate();
- if (!replaced) {
- openFile();
- validate();
- if (replaced) {
- closeFile();
- }
- }
- } catch (FileNotFoundException e) {
- replaced = true;
- }
- }
- if (replaced) {
- return null;
- }
- return lookup(rid);
- }
-
- protected abstract IRawRecord<T> lookup(RecordId rid) throws IOException;
-
- private void validate() throws IllegalArgumentException, IOException {
- FileStatus fileStatus = fs.getFileStatus(new Path(file.getFileName()));
- replaced = fileStatus.getModificationTime() != file.getLastModefiedTime().getTime();
- }
-
- protected abstract void closeFile();
-
- protected abstract void openFile() throws IllegalArgumentException, IOException;
-
- @Override
- public final void open() throws HyracksDataException {
- snapshotAccessor.open();
- }
-
- @Override
- public void close() throws IOException {
- try {
- closeFile();
- } finally {
- snapshotAccessor.close();
- }
- }
-
- @Override
- public void fail() {
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSLookupReaderFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSLookupReaderFactory.java
deleted file mode 100644
index 75d431d..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSLookupReaderFactory.java
+++ /dev/null
@@ -1,103 +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.asterix.external.input.record.reader.hdfs;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.asterix.common.api.IApplicationContext;
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.api.ILookupReaderFactory;
-import org.apache.asterix.external.api.ILookupRecordReader;
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.util.ExternalDataConstants;
-import org.apache.asterix.external.util.HDFSUtils;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.mapred.JobConf;
-import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
-import org.apache.hyracks.api.application.IServiceContext;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.IWarningCollector;
-import org.apache.hyracks.hdfs.dataflow.ConfFactory;
-
-public class HDFSLookupReaderFactory<T> implements ILookupReaderFactory<T> {
-
- private static final long serialVersionUID = 1L;
- protected ConfFactory confFactory;
- protected Map<String, String> configuration;
- protected transient AlgebricksAbsolutePartitionConstraint clusterLocations;
- protected transient IServiceContext serviceCtx;
-
- public HDFSLookupReaderFactory() {
- }
-
- @Override
- public DataSourceType getDataSourceType() {
- return DataSourceType.RECORDS;
- }
-
- @Override
- public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() throws AsterixException {
- clusterLocations = HDFSUtils.getPartitionConstraints((IApplicationContext) serviceCtx.getApplicationContext(),
- clusterLocations);
- return clusterLocations;
- }
-
- @Override
- public void configure(IServiceContext serviceCtx, Map<String, String> configuration,
- IWarningCollector warningCollector) throws AsterixException {
- this.serviceCtx = serviceCtx;
- this.configuration = configuration;
- JobConf conf = HDFSUtils.configureHDFSJobConf(configuration);
- try {
- confFactory = new ConfFactory(conf);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
-
- }
-
- @Override
- public boolean isIndexible() {
- return false;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ILookupRecordReader<? extends T> createRecordReader(IHyracksTaskContext ctx, int partition,
- ExternalFileIndexAccessor snapshotAccessor) throws HyracksDataException {
- String inputFormatParameter = configuration.get(ExternalDataConstants.KEY_INPUT_FORMAT).trim();
- JobConf conf = confFactory.getConf();
- FileSystem fs;
- try {
- fs = FileSystem.get(conf);
- } catch (IOException e) {
- throw new HyracksDataException("Unable to get filesystem object", e);
- }
- switch (inputFormatParameter) {
- case ExternalDataConstants.INPUT_FORMAT_TEXT:
- return (ILookupRecordReader<? extends T>) new TextLookupReader(snapshotAccessor, fs, conf);
- case ExternalDataConstants.INPUT_FORMAT_SEQUENCE:
- return (ILookupRecordReader<? extends T>) new SequenceLookupReader(snapshotAccessor, fs, conf);
- default:
- throw new HyracksDataException("Unrecognised input format: " + inputFormatParameter);
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/SequenceLookupReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/SequenceLookupReader.java
deleted file mode 100644
index 46ae9ac..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/SequenceLookupReader.java
+++ /dev/null
@@ -1,72 +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.asterix.external.input.record.reader.hdfs;
-
-import java.io.IOException;
-
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.indexing.RecordId;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.SequenceFile;
-import org.apache.hadoop.io.SequenceFile.Reader;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class SequenceLookupReader extends AbstractCharRecordLookupReader {
-
- public SequenceLookupReader(ExternalFileIndexAccessor snapshotAccessor, FileSystem fs, Configuration conf) {
- super(snapshotAccessor, fs, conf);
- }
-
- private static final Logger LOGGER = LogManager.getLogger();
- private Reader reader;
- private Writable key;
-
- @Override
- protected void readRecord(RecordId rid) throws IOException {
- reader.seek(rid.getOffset());
- reader.next(key, value);
- }
-
- @Override
- protected void closeFile() {
- if (reader == null) {
- return;
- }
- try {
- reader.close();
- } catch (Exception e) {
- LOGGER.warn("Error closing HDFS file ", e);
- }
- }
-
- @SuppressWarnings("deprecation")
- @Override
- protected void openFile() throws IllegalArgumentException, IOException {
- reader = new SequenceFile.Reader(fs, new Path(file.getFileName()), conf);
- key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
- value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/TextLookupReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/TextLookupReader.java
deleted file mode 100644
index 199d05a..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/TextLookupReader.java
+++ /dev/null
@@ -1,65 +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.asterix.external.input.record.reader.hdfs;
-
-import java.io.IOException;
-
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.asterix.external.indexing.RecordId;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class TextLookupReader extends AbstractCharRecordLookupReader {
-
- public TextLookupReader(ExternalFileIndexAccessor snapshotAccessor, FileSystem fs, Configuration conf) {
- super(snapshotAccessor, fs, conf);
- }
-
- private static final Logger LOGGER = LogManager.getLogger();
- private HDFSTextLineReader reader;
-
- @Override
- protected void readRecord(RecordId rid) throws IOException {
- reader.seek(rid.getOffset());
- reader.readLine(value);
- }
-
- @Override
- protected void closeFile() {
- if (reader == null) {
- return;
- }
- try {
- reader.close();
- } catch (Exception e) {
- LOGGER.warn("Error closing HDFS file ", e);
- }
- }
-
- @Override
- protected void openFile() throws IllegalArgumentException, IOException {
- if (reader == null) {
- reader = new HDFSTextLineReader();
- }
- reader.resetReader(fs.open(new Path(file.getFileName())));
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/AbstractExternalDatasetIndexesOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/AbstractExternalDatasetIndexesOperatorDescriptor.java
deleted file mode 100644
index 4a7635c..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/AbstractExternalDatasetIndexesOperatorDescriptor.java
+++ /dev/null
@@ -1,96 +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.asterix.external.operators;
-
-import java.util.List;
-
-import org.apache.hyracks.api.comm.IFrameWriter;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-
-// This is an operator that takes a single file index and an array of secondary indexes
-// it is intended to be used for
-// 1. commit transaction operation
-// 2. abort transaction operation
-// 3. recover transaction operation
-public abstract class AbstractExternalDatasetIndexesOperatorDescriptor
- extends AbstractSingleActivityOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private List<IIndexDataflowHelperFactory> treeIndexesDataflowHelperFactories;
-
- public AbstractExternalDatasetIndexesOperatorDescriptor(IOperatorDescriptorRegistry spec,
- List<IIndexDataflowHelperFactory> treeIndexesDataflowHelperFactories) {
- super(spec, 0, 0);
- this.treeIndexesDataflowHelperFactories = treeIndexesDataflowHelperFactories;
- }
-
- // opening and closing the index is done inside these methods since we don't always need open indexes
- protected abstract void performOpOnIndex(IIndexDataflowHelper indexDataflowHelper, IHyracksTaskContext ctx)
- throws HyracksDataException;
-
- @Override
- public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, final int partition, int nPartitions) {
- return new AbstractOperatorNodePushable() {
-
- @Override
- public void initialize() throws HyracksDataException {
- try {
- // perform operation on btrees
- for (int i = 0; i < treeIndexesDataflowHelperFactories.size(); i++) {
- IIndexDataflowHelper indexHelper = treeIndexesDataflowHelperFactories.get(i)
- .create(ctx.getJobletContext().getServiceContext(), partition);
- performOpOnIndex(indexHelper, ctx);
- }
- } catch (Exception e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public void deinitialize() throws HyracksDataException {
- }
-
- @Override
- public int getInputArity() {
- return 0;
- }
-
- @Override
- public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc)
- throws HyracksDataException {
- }
-
- @Override
- public IFrameWriter getInputFrameWriter(int index) {
- return null;
- }
-
- };
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java
deleted file mode 100644
index 56bedea..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java
+++ /dev/null
@@ -1,56 +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.asterix.external.operators;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescriptor;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-
-public class ExternalBTreeSearchOperatorDescriptor extends BTreeSearchOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private final int version;
-
- public ExternalBTreeSearchOperatorDescriptor(IOperatorDescriptorRegistry spec, RecordDescriptor outRecDesc,
- int[] lowKeyFields, int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
- IIndexDataflowHelperFactory indexHelperFactory, boolean retainInput, boolean retainMissing,
- IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchCallbackFactory,
- int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes, int version) {
- super(spec, outRecDesc, lowKeyFields, highKeyFields, lowKeyInclusive, highKeyInclusive, indexHelperFactory,
- retainInput, retainMissing, missingWriterFactory, searchCallbackFactory, minFilterFieldIndexes,
- maxFilterFieldIndexes, false, null);
- this.version = version;
- }
-
- @Override
- public ExternalBTreeSearchOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new ExternalBTreeSearchOperatorNodePushable(ctx, partition,
- recordDescProvider.getInputRecordDescriptor(getActivityId(), 0), lowKeyFields, highKeyFields,
- lowKeyInclusive, highKeyInclusive, indexHelperFactory, retainInput, retainMissing, missingWriterFactory,
- searchCallbackFactory, version);
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java
deleted file mode 100644
index 4e669c3..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java
+++ /dev/null
@@ -1,94 +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.asterix.external.operators;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hyracks.api.comm.VSizeFrame;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender;
-import org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference;
-import org.apache.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorNodePushable;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTreeWithBuddy;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-
-public class ExternalBTreeSearchOperatorNodePushable extends BTreeSearchOperatorNodePushable {
-
- private final int version;
-
- public ExternalBTreeSearchOperatorNodePushable(IHyracksTaskContext ctx, int partition,
- RecordDescriptor intputRecDesc, int[] lowKeyFields, int[] highKeyFields, boolean lowKeyInclusive,
- boolean highKeyInclusive, IIndexDataflowHelperFactory indexHelperFactory, boolean retainInput,
- boolean retainMissing, IMissingWriterFactory missingWriterFactory,
- ISearchOperationCallbackFactory searchCallbackFactory, int version) throws HyracksDataException {
- super(ctx, partition, intputRecDesc, lowKeyFields, highKeyFields, lowKeyInclusive, highKeyInclusive, null, null,
- indexHelperFactory, retainInput, retainMissing, missingWriterFactory, searchCallbackFactory, false,
- null);
- this.version = version;
- }
-
- // We override the open function to search a specific version of the index
- @Override
- public void open() throws HyracksDataException {
- writer.open();
- accessor = new FrameTupleAccessor(inputRecDesc);
- indexHelper.open();
- index = indexHelper.getIndexInstance();
- if (retainMissing) {
- int fieldCount = getFieldCount();
- nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
- DataOutput out = nonMatchTupleBuild.getDataOutput();
- for (int i = 0; i < fieldCount; i++) {
- try {
- nonMatchWriter.writeMissing(out);
- } catch (IOException e) {
- e.printStackTrace();
- }
- nonMatchTupleBuild.addFieldEndOffset();
- }
- } else {
- nonMatchTupleBuild = null;
- }
- ExternalBTreeWithBuddy externalIndex = (ExternalBTreeWithBuddy) index;
- try {
- searchPred = createSearchPredicate();
- tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
- dos = tb.getDataOutput();
- appender = new FrameTupleAppender(new VSizeFrame(ctx));
- ISearchOperationCallback searchCallback =
- searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, null);
- // The next line is the reason we override this method
- indexAccessor = externalIndex.createAccessor(searchCallback, version);
- cursor = createCursor();
- if (retainInput) {
- frameTuple = new FrameTupleReference();
- }
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesAbortOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesAbortOperatorDescriptor.java
deleted file mode 100644
index 20f0c55..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesAbortOperatorDescriptor.java
+++ /dev/null
@@ -1,51 +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.asterix.external.operators;
-
-import java.util.List;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbortRecoverLSMIndexFileManager;
-
-public class ExternalDatasetIndexesAbortOperatorDescriptor extends AbstractExternalDatasetIndexesOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalDatasetIndexesAbortOperatorDescriptor(IOperatorDescriptorRegistry spec,
- List<IIndexDataflowHelperFactory> indexesDataflowHelperFactories) {
- super(spec, indexesDataflowHelperFactories);
- }
-
- @Override
- protected void performOpOnIndex(IIndexDataflowHelper indexDataflowHelper, IHyracksTaskContext ctx)
- throws HyracksDataException {
- String path = indexDataflowHelper.getResource().getPath();
- IIOManager ioManager = ctx.getIoManager();
- FileReference file = ioManager.resolve(path);
- AbortRecoverLSMIndexFileManager fileManager = new AbortRecoverLSMIndexFileManager(ctx.getIoManager(), file);
- fileManager.deleteTransactionFiles();
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesCommitOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesCommitOperatorDescriptor.java
deleted file mode 100644
index 337946b..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesCommitOperatorDescriptor.java
+++ /dev/null
@@ -1,57 +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.asterix.external.operators;
-
-import java.util.List;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.common.IIndex;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class ExternalDatasetIndexesCommitOperatorDescriptor extends AbstractExternalDatasetIndexesOperatorDescriptor {
- private static final long serialVersionUID = 1L;
- private static final Logger LOGGER = LogManager.getLogger();
-
- public ExternalDatasetIndexesCommitOperatorDescriptor(IOperatorDescriptorRegistry spec,
- List<IIndexDataflowHelperFactory> indexesDataflowHelperFactories) {
- super(spec, indexesDataflowHelperFactories);
- }
-
- @Override
- protected void performOpOnIndex(IIndexDataflowHelper indexHelper, IHyracksTaskContext ctx)
- throws HyracksDataException {
- String path = indexHelper.getResource().getPath();
- IIOManager ioManager = ctx.getIoManager();
- FileReference file = ioManager.resolve(path);
- LOGGER.warn("performing the operation on " + file.getFile().getAbsolutePath());
- // Get index
- IIndex index = indexHelper.getIndexInstance();
- // commit transaction
- ((ITwoPCIndex) index).commitTransaction();
- LOGGER.warn("operation on " + file.getFile().getAbsolutePath() + " Succeded");
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesRecoverOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesRecoverOperatorDescriptor.java
deleted file mode 100644
index 5413e4d..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalDatasetIndexesRecoverOperatorDescriptor.java
+++ /dev/null
@@ -1,50 +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.asterix.external.operators;
-
-import java.util.List;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbortRecoverLSMIndexFileManager;
-
-public class ExternalDatasetIndexesRecoverOperatorDescriptor extends AbstractExternalDatasetIndexesOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalDatasetIndexesRecoverOperatorDescriptor(IOperatorDescriptorRegistry spec,
- List<IIndexDataflowHelperFactory> indexesDataflowHelperFactories) {
- super(spec, indexesDataflowHelperFactories);
- }
-
- @Override
- protected void performOpOnIndex(IIndexDataflowHelper indexDataflowHelper, IHyracksTaskContext ctx)
- throws HyracksDataException {
- String path = indexDataflowHelper.getResource().getPath();
- IIOManager ioManager = ctx.getIoManager();
- FileReference file = ioManager.resolve(path);
- AbortRecoverLSMIndexFileManager fileManager = new AbortRecoverLSMIndexFileManager(ctx.getIoManager(), file);
- fileManager.recoverTransaction();
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexCreateOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexCreateOperatorDescriptor.java
deleted file mode 100644
index df4c093..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexCreateOperatorDescriptor.java
+++ /dev/null
@@ -1,119 +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.asterix.external.operators;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.asterix.common.ioopcallbacks.LSMIOOperationCallback;
-import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.FileIndexTupleTranslator;
-import org.apache.hyracks.api.comm.IFrameWriter;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
-import org.apache.hyracks.storage.am.btree.impls.BTree;
-import org.apache.hyracks.storage.am.common.api.IIndexBuilder;
-import org.apache.hyracks.storage.am.common.api.IIndexBuilderFactory;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentId;
-import org.apache.hyracks.storage.common.IIndexBulkLoader;
-
-/**
- * For the replicated file index
- * It creates and bulkloads initial set of files
- */
-public class ExternalFilesIndexCreateOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private List<ExternalFile> files;
- private IIndexDataflowHelperFactory dataflowHelperFactory;
- private IIndexBuilderFactory indexBuilderFactory;
-
- public ExternalFilesIndexCreateOperatorDescriptor(IOperatorDescriptorRegistry spec,
- IIndexBuilderFactory indexBuilderFactory, IIndexDataflowHelperFactory dataflowHelperFactory,
- List<ExternalFile> files) {
- super(spec, 0, 0);
- this.indexBuilderFactory = indexBuilderFactory;
- this.dataflowHelperFactory = dataflowHelperFactory;
- this.files = files;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new AbstractOperatorNodePushable() {
- @Override
- public void initialize() throws HyracksDataException {
- IIndexBuilder indexBuilder = indexBuilderFactory.create(ctx, partition);
- IIndexDataflowHelper indexHelper =
- dataflowHelperFactory.create(ctx.getJobletContext().getServiceContext(), partition);
- FileIndexTupleTranslator filesTupleTranslator = new FileIndexTupleTranslator();
- // Build the index
- indexBuilder.build();
- // Open the index
- indexHelper.open();
- try {
- ILSMIndex index = (ILSMIndex) indexHelper.getIndexInstance();
- Map<String, Object> parameters = new HashMap<>();
- parameters.put(LSMIOOperationCallback.KEY_FLUSHED_COMPONENT_ID,
- LSMComponentId.DEFAULT_COMPONENT_ID);
- // Create bulk loader
- IIndexBulkLoader bulkLoader =
- index.createBulkLoader(BTree.DEFAULT_FILL_FACTOR, false, files.size(), false, parameters);
- // Load files
- for (ExternalFile file : files) {
- bulkLoader.add(filesTupleTranslator.getTupleFromFile(file));
- }
- bulkLoader.end();
- } finally {
- indexHelper.close();
- }
- }
-
- @Override
- public void deinitialize() throws HyracksDataException {
- }
-
- @Override
- public int getInputArity() {
- return 0;
- }
-
- @Override
- public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc)
- throws HyracksDataException {
- }
-
- @Override
- public IFrameWriter getInputFrameWriter(int index) {
- return null;
- }
-
- };
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexModificationOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexModificationOperatorDescriptor.java
deleted file mode 100644
index 477f0fe..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexModificationOperatorDescriptor.java
+++ /dev/null
@@ -1,129 +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.asterix.external.operators;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
-import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.FileIndexTupleTranslator;
-import org.apache.hyracks.api.comm.IFrameWriter;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.dataflow.std.base.AbstractOperatorNodePushable;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
-import org.apache.hyracks.storage.am.btree.impls.BTree;
-import org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree.LSMTwoPCBTreeBulkLoader;
-import org.apache.hyracks.storage.common.IIndex;
-
-/**
- * This operator is intended solely for external dataset files replicated index.
- * It bulkmodify the index creating a hidden transaction component which later might be committed or deleted
- */
-public class ExternalFilesIndexModificationOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private List<ExternalFile> files;
- private IIndexDataflowHelperFactory dataflowHelperFactory;
-
- public ExternalFilesIndexModificationOperatorDescriptor(IOperatorDescriptorRegistry spec,
- IIndexDataflowHelperFactory dataflowHelperFactory, List<ExternalFile> files) {
- super(spec, 0, 0);
- this.dataflowHelperFactory = dataflowHelperFactory;
- this.files = files;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new AbstractOperatorNodePushable() {
- @Override
- public void initialize() throws HyracksDataException {
- final IIndexDataflowHelper indexHelper =
- dataflowHelperFactory.create(ctx.getJobletContext().getServiceContext(), partition);
- FileIndexTupleTranslator filesTupleTranslator = new FileIndexTupleTranslator();
- // Open and get
- indexHelper.open();
- IIndex index = indexHelper.getIndexInstance();
- LSMTwoPCBTreeBulkLoader bulkLoader = null;
- Map<String, Object> parameters = new HashMap<>();
- try {
- bulkLoader = (LSMTwoPCBTreeBulkLoader) ((ExternalBTree) index)
- .createTransactionBulkLoader(BTree.DEFAULT_FILL_FACTOR, false, files.size(), parameters);
- // Load files
- // The files must be ordered according to their numbers
- for (ExternalFile file : files) {
- switch (file.getPendingOp()) {
- case ADD_OP:
- case APPEND_OP:
- bulkLoader.add(filesTupleTranslator.getTupleFromFile(file));
- break;
- case DROP_OP:
- bulkLoader.delete(filesTupleTranslator.getTupleFromFile(file));
- break;
- case NO_OP:
- break;
- default:
- throw RuntimeDataException.create(ErrorCode.UNKNOWN_EXTERNAL_FILE_PENDING_OP, sourceLoc,
- file.getPendingOp());
- }
- }
- bulkLoader.end();
- } catch (Exception e) {
- if (bulkLoader != null) {
- bulkLoader.abort();
- }
- throw HyracksDataException.create(e);
- } finally {
- indexHelper.close();
- }
- }
-
- @Override
- public void deinitialize() throws HyracksDataException {
- }
-
- @Override
- public int getInputArity() {
- return 0;
- }
-
- @Override
- public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc)
- throws HyracksDataException {
- }
-
- @Override
- public IFrameWriter getInputFrameWriter(int index) {
- return null;
- }
-
- };
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorDescriptor.java
deleted file mode 100644
index f910fb4..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorDescriptor.java
+++ /dev/null
@@ -1,55 +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.asterix.external.operators;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.TreeIndexBulkLoadOperatorDescriptor;
-
-public class ExternalIndexBulkLoadOperatorDescriptor extends TreeIndexBulkLoadOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private final int version;
- private final ITupleFilterFactory tupleFilterFactory;
-
- public ExternalIndexBulkLoadOperatorDescriptor(IOperatorDescriptorRegistry spec, RecordDescriptor outRecDesc,
- int[] fieldPermutation, float fillFactor, boolean verifyInput, long numElementsHint,
- boolean checkIfEmptyIndex, IIndexDataflowHelperFactory indexHelperFactory, int version,
- ITupleFilterFactory tupleFilterFactory) {
- super(spec, outRecDesc, fieldPermutation, fillFactor, verifyInput, numElementsHint, checkIfEmptyIndex,
- indexHelperFactory);
- this.version = version;
- this.tupleFilterFactory = tupleFilterFactory;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new ExternalIndexBulkLoadOperatorNodePushable(indexHelperFactory, ctx, partition, fieldPermutation,
- fillFactor, verifyInput, numElementsHint, checkIfEmptyIndex,
- recordDescProvider.getInputRecordDescriptor(this.getActivityId(), 0), version, tupleFilterFactory);
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorNodePushable.java
deleted file mode 100644
index 39f23ed..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkLoadOperatorNodePushable.java
+++ /dev/null
@@ -1,61 +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.asterix.external.operators;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.asterix.common.ioopcallbacks.LSMIOOperationCallback;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IndexBulkLoadOperatorNodePushable;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentId;
-
-public class ExternalIndexBulkLoadOperatorNodePushable extends IndexBulkLoadOperatorNodePushable {
-
- private final int version;
-
- public ExternalIndexBulkLoadOperatorNodePushable(IIndexDataflowHelperFactory indexDataflowHelperFactory,
- IHyracksTaskContext ctx, int partition, int[] fieldPermutation, float fillFactor, boolean verifyInput,
- long numElementsHint, boolean checkIfEmptyIndex, RecordDescriptor recDesc, int version,
- ITupleFilterFactory tupleFilterFactory) throws HyracksDataException {
- super(indexDataflowHelperFactory, ctx, partition, fieldPermutation, fillFactor, verifyInput, numElementsHint,
- checkIfEmptyIndex, recDesc, tupleFilterFactory);
- this.version = version;
- }
-
- @Override
- public void open() throws HyracksDataException {
- super.open();
- ((ITwoPCIndex) index).setCurrentVersion(version);
- }
-
- @Override
- protected void initializeBulkLoader() throws HyracksDataException {
- Map<String, Object> parameters = new HashMap<>();
- parameters.put(LSMIOOperationCallback.KEY_FLUSHED_COMPONENT_ID, LSMComponentId.DEFAULT_COMPONENT_ID);
- bulkLoader = ((ILSMIndex) index).createBulkLoader(fillFactor, verifyInput, numElementsHint, checkIfEmptyIndex,
- parameters);
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorDescriptor.java
deleted file mode 100644
index 674ee42..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorDescriptor.java
+++ /dev/null
@@ -1,53 +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.asterix.external.operators;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.TreeIndexBulkLoadOperatorDescriptor;
-
-public class ExternalIndexBulkModifyOperatorDescriptor extends TreeIndexBulkLoadOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private final int[] deletedFiles;
- private final ITupleFilterFactory tupleFilterFactory;
-
- public ExternalIndexBulkModifyOperatorDescriptor(IOperatorDescriptorRegistry spec,
- IIndexDataflowHelperFactory dataflowHelperFactory, int[] deletedFiles, int[] fieldPermutation,
- float fillFactor, boolean verifyInput, long numElementsHint, ITupleFilterFactory tupleFilterFactory) {
- super(spec, null, fieldPermutation, fillFactor, verifyInput, numElementsHint, false, dataflowHelperFactory,
- tupleFilterFactory);
- this.deletedFiles = deletedFiles;
- this.tupleFilterFactory = tupleFilterFactory;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new ExternalIndexBulkModifyOperatorNodePushable(indexHelperFactory, ctx, partition, fieldPermutation,
- fillFactor, verifyInput, numElementsHint,
- recordDescProvider.getInputRecordDescriptor(getActivityId(), 0), deletedFiles, tupleFilterFactory);
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorNodePushable.java
deleted file mode 100644
index 745853e..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalIndexBulkModifyOperatorNodePushable.java
+++ /dev/null
@@ -1,118 +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.asterix.external.operators;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.asterix.external.indexing.FilesIndexDescription;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.storage.am.common.api.ITupleFilterFactory;
-import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IndexBulkLoadOperatorNodePushable;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-
-public class ExternalIndexBulkModifyOperatorNodePushable extends IndexBulkLoadOperatorNodePushable {
-
- private final int[] deletedFiles;
- private ArrayTupleBuilder buddyBTreeTupleBuilder =
- new ArrayTupleBuilder(FilesIndexDescription.FILE_BUDDY_BTREE_RECORD_DESCRIPTOR.getFieldCount());
- private AMutableInt32 fileNumber = new AMutableInt32(0);
- private ArrayTupleReference deleteTuple = new ArrayTupleReference();
-
- public ExternalIndexBulkModifyOperatorNodePushable(IIndexDataflowHelperFactory indexHelperFactory,
- IHyracksTaskContext ctx, int partition, int[] fieldPermutation, float fillFactor, boolean verifyInput,
- long numElementsHint, RecordDescriptor inputRecDesc, int[] deletedFiles,
- ITupleFilterFactory tupleFilterFactory) throws HyracksDataException {
- super(indexHelperFactory, ctx, partition, fieldPermutation, fillFactor, verifyInput, numElementsHint, false,
- inputRecDesc, tupleFilterFactory);
- this.deletedFiles = deletedFiles;
- }
-
- // We override this method to do two things
- // when creating the bulkLoader, it creates a transaction bulk loader
- // It uses the bulkLoader to insert delete tuples for the deleted files
- @Override
- public void open() throws HyracksDataException {
- accessor = new FrameTupleAccessor(recDesc);
- indexHelper.open();
- index = indexHelper.getIndexInstance();
- try {
- writer.open();
- // Transactional BulkLoader
- Map<String, Object> parameters = new HashMap<>();
- bulkLoader = ((ITwoPCIndex) index).createTransactionBulkLoader(fillFactor, verifyInput, deletedFiles.length,
- parameters);
- // Delete files
- for (int i = 0; i < deletedFiles.length; i++) {
- fileNumber.setValue(deletedFiles[i]);
- FilesIndexDescription.getBuddyBTreeTupleFromFileNumber(deleteTuple, buddyBTreeTupleBuilder, fileNumber);
- ((ITwoPCIndexBulkLoader) bulkLoader).delete(deleteTuple);
- }
- } catch (Throwable e) {
- throw HyracksDataException.create(e);
- }
- }
-
- @Override
- public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
- accessor.reset(buffer);
- int tupleCount = accessor.getTupleCount();
- for (int i = 0; i < tupleCount; i++) {
- tuple.reset(accessor, i);
- bulkLoader.add(tuple);
- }
- }
-
- @Override
- public void close() throws HyracksDataException {
- if (index != null) {
- try {
- bulkLoader.end();
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- } finally {
- try {
- indexHelper.close();
- } finally {
- writer.close();
- }
- }
- }
- }
-
- @Override
- public void fail() throws HyracksDataException {
- if (index != null) {
- try {
- ((ITwoPCIndexBulkLoader) bulkLoader).abort();
- } finally {
- writer.fail();
- }
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java
deleted file mode 100644
index e54b3d2..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java
+++ /dev/null
@@ -1,133 +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.asterix.external.operators;
-
-import java.nio.ByteBuffer;
-
-import org.apache.asterix.external.adapter.factory.LookupAdapterFactory;
-import org.apache.asterix.external.dataset.adapter.LookupAdapter;
-import org.apache.asterix.external.indexing.ExternalFileIndexAccessor;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
-import org.apache.hyracks.dataflow.std.base.AbstractUnaryInputUnaryOutputOperatorNodePushable;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-
-/*
- * This operator is intended for using record ids to access data in external sources
- */
-public class ExternalLookupOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
- private static final long serialVersionUID = 1L;
- private final LookupAdapterFactory<?> adapterFactory;
- private final IIndexDataflowHelperFactory dataflowHelperFactory;
- private final int version;
- private final ISearchOperationCallbackFactory searchOpCallbackFactory;
-
- public ExternalLookupOperatorDescriptor(IOperatorDescriptorRegistry spec, LookupAdapterFactory<?> adapterFactory,
- RecordDescriptor outRecDesc, IIndexDataflowHelperFactory dataflowHelperFactory,
- ISearchOperationCallbackFactory searchOpCallbackFactory, int version) {
- super(spec, 1, 1);
- outRecDescs[0] = outRecDesc;
- this.dataflowHelperFactory = dataflowHelperFactory;
- this.searchOpCallbackFactory = searchOpCallbackFactory;
- this.version = version;
- this.adapterFactory = adapterFactory;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
- final IRecordDescriptorProvider recordDescProvider, final int partition, int nPartitions)
- throws HyracksDataException {
- // Create a file index accessor to be used for files lookup operations
- final ExternalFileIndexAccessor snapshotAccessor = new ExternalFileIndexAccessor(
- dataflowHelperFactory.create(ctx.getJobletContext().getServiceContext(), partition),
- searchOpCallbackFactory, version);
- return new AbstractUnaryInputUnaryOutputOperatorNodePushable() {
- // The adapter that uses the file index along with the coming tuples to access files in HDFS
- private LookupAdapter<?> adapter;
- private boolean indexOpen = false;
-
- @Override
- public void open() throws HyracksDataException {
- try {
- adapter = adapterFactory.createAdapter(ctx, partition,
- recordDescProvider.getInputRecordDescriptor(getActivityId(), 0), snapshotAccessor, writer);
- // Open the file index accessor here
- snapshotAccessor.open();
- indexOpen = true;
- adapter.open();
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- }
- }
-
- @Override
- public void close() throws HyracksDataException {
- HyracksDataException hde = null;
- if (indexOpen) {
- try {
- snapshotAccessor.close();
- } catch (Throwable th) {
- hde = HyracksDataException.create(th);
- }
- try {
- adapter.close();
- } catch (Throwable th) {
- if (hde == null) {
- hde = HyracksDataException.create(th);
- } else {
- hde.addSuppressed(th);
- }
- }
- }
- if (hde != null) {
- throw hde;
- }
- }
-
- @Override
- public void fail() throws HyracksDataException {
- try {
- adapter.fail();
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- }
- }
-
- @Override
- public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
- try {
- adapter.nextFrame(buffer);
- } catch (Throwable th) {
- throw HyracksDataException.create(th);
- }
- }
-
- @Override
- public void flush() throws HyracksDataException {
- adapter.flush();
- }
- };
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java
deleted file mode 100644
index bd6c922..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java
+++ /dev/null
@@ -1,57 +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.asterix.external.operators;
-
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.rtree.dataflow.RTreeSearchOperatorDescriptor;
-
-public class ExternalRTreeSearchOperatorDescriptor extends RTreeSearchOperatorDescriptor {
-
- private static final long serialVersionUID = 1L;
- private final int version;
-
- public ExternalRTreeSearchOperatorDescriptor(IOperatorDescriptorRegistry spec, RecordDescriptor outRecDesc,
- int[] keyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
- IIndexDataflowHelperFactory indexHelperFactory, boolean retainInput, boolean retainMissing,
- IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchCallbackFactory,
- int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes, int version) {
- super(spec, outRecDesc, keyFields, lowKeyInclusive, highKeyInclusive, indexHelperFactory, retainInput,
- retainMissing, missingWriterFactory, searchCallbackFactory, minFilterFieldIndexes,
- maxFilterFieldIndexes, false, null);
- this.version = version;
- }
-
- @Override
- public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
- IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
- return new ExternalRTreeSearchOperatorNodePushable(ctx, partition,
- recordDescProvider.getInputRecordDescriptor(getActivityId(), 0), keyFields, minFilterFieldIndexes,
- maxFilterFieldIndexes, indexHelperFactory, retainInput, retainMissing, missingWriterFactory,
- searchCallbackFactory, version);
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
deleted file mode 100644
index 508cff7..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
+++ /dev/null
@@ -1,95 +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.asterix.external.operators;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hyracks.api.comm.VSizeFrame;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender;
-import org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference;
-import org.apache.hyracks.storage.am.common.api.ISearchOperationCallbackFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree;
-import org.apache.hyracks.storage.am.rtree.dataflow.RTreeSearchOperatorNodePushable;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-
-public class ExternalRTreeSearchOperatorNodePushable extends RTreeSearchOperatorNodePushable {
-
- private final int version;
-
- public ExternalRTreeSearchOperatorNodePushable(IHyracksTaskContext ctx, int partition,
- RecordDescriptor inputRecDesc, int[] keyFields, int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes,
- IIndexDataflowHelperFactory indexHelperFactory, boolean retainInput, boolean retainMissing,
- IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchCallbackFactory,
- int version) throws HyracksDataException {
- super(ctx, partition, inputRecDesc, keyFields, minFilterFieldIndexes, maxFilterFieldIndexes, indexHelperFactory,
- retainInput, retainMissing, missingWriterFactory, searchCallbackFactory, false, null);
- this.version = version;
- }
-
- // We override this method to specify the searched version of the index
- @Override
- public void open() throws HyracksDataException {
- writer.open();
- accessor = new FrameTupleAccessor(inputRecDesc);
- indexHelper.open();
- index = indexHelper.getIndexInstance();
- if (retainMissing) {
- int fieldCount = getFieldCount();
- nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
- DataOutput out = nonMatchTupleBuild.getDataOutput();
- for (int i = 0; i < fieldCount; i++) {
- try {
- nonMatchWriter.writeMissing(out);
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- nonMatchTupleBuild.addFieldEndOffset();
- }
- } else {
- nonMatchTupleBuild = null;
- }
- ExternalRTree rTreeIndex = (ExternalRTree) index;
- try {
- searchPred = createSearchPredicate();
- tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
- dos = tb.getDataOutput();
- appender = new FrameTupleAppender(new VSizeFrame(ctx));
- ISearchOperationCallback searchCallback =
- searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, null);
- // The next line is the reason we override this method...
- // The right thing to do would be to change the signature of createAccessor
- indexAccessor = rTreeIndex.createAccessor(searchCallback, version);
- cursor = createCursor();
- if (retainInput) {
- frameTuple = new FrameTupleReference();
- }
- } catch (Exception e) {
- throw HyracksDataException.create(e);
- }
- }
-
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
index a4fdcfb..4b0148e 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
@@ -18,20 +18,14 @@
*/
package org.apache.asterix.external.provider;
-import java.util.List;
import java.util.Map;
import org.apache.asterix.common.dataflow.ICcApplicationContext;
-import org.apache.asterix.external.adapter.factory.GenericAdapterFactory;
-import org.apache.asterix.external.adapter.factory.LookupAdapterFactory;
-import org.apache.asterix.external.api.IIndexingAdapterFactory;
import org.apache.asterix.external.api.ITypedAdapterFactory;
-import org.apache.asterix.external.indexing.ExternalFile;
import org.apache.asterix.external.util.ExternalDataUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.application.ICCServiceContext;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.exceptions.IWarningCollector;
@@ -57,29 +51,4 @@
adapterFactory.configure(serviceCtx, configuration, warningCollector);
return adapterFactory;
}
-
- // get indexing adapter factory. this method has the side effect of modifying the configuration as necessary
- public static IIndexingAdapterFactory getIndexingAdapterFactory(ICCServiceContext serviceCtx, String adapterName,
- Map<String, String> configuration, ARecordType itemType, List<ExternalFile> snapshot, boolean indexingOp,
- ARecordType metaType, IWarningCollector warningCollector) throws HyracksDataException, AlgebricksException {
- ExternalDataUtils.defaultConfiguration(configuration);
- ExternalDataUtils.prepare(adapterName, configuration);
- GenericAdapterFactory adapterFactory = new GenericAdapterFactory();
- adapterFactory.setOutputType(itemType);
- adapterFactory.setMetaType(metaType);
- adapterFactory.setSnapshot(snapshot, indexingOp);
- adapterFactory.configure(serviceCtx, configuration, warningCollector);
- return adapterFactory;
- }
-
- // Lookup Adapters
- public static LookupAdapterFactory<?> getLookupAdapterFactory(ICCServiceContext serviceCtx,
- Map<String, String> configuration, ARecordType recordType, int[] ridFields, boolean retainInput,
- boolean retainMissing, IMissingWriterFactory missingWriterFactory, IWarningCollector warningCollector)
- throws HyracksDataException, AlgebricksException {
- LookupAdapterFactory<?> adapterFactory =
- new LookupAdapterFactory<>(recordType, ridFields, retainInput, retainMissing, missingWriterFactory);
- adapterFactory.configure(serviceCtx, configuration, warningCollector);
- return adapterFactory;
- }
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/ExternalIndexerProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/ExternalIndexerProvider.java
deleted file mode 100644
index e24f433..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/ExternalIndexerProvider.java
+++ /dev/null
@@ -1,41 +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.asterix.external.provider;
-
-import java.util.Map;
-
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.api.IExternalIndexer;
-import org.apache.asterix.external.indexing.FileOffsetIndexer;
-import org.apache.asterix.external.util.ExternalDataConstants;
-
-public class ExternalIndexerProvider {
-
- public static IExternalIndexer getIndexer(Map<String, String> configuration) throws AsterixException {
- String inputFormatParameter = configuration.get(ExternalDataConstants.KEY_INPUT_FORMAT).trim();
- if (inputFormatParameter.equalsIgnoreCase(ExternalDataConstants.INPUT_FORMAT_TEXT)
- || inputFormatParameter.equalsIgnoreCase(ExternalDataConstants.CLASS_NAME_TEXT_INPUT_FORMAT)
- || inputFormatParameter.equalsIgnoreCase(ExternalDataConstants.INPUT_FORMAT_SEQUENCE)
- || inputFormatParameter.equalsIgnoreCase(ExternalDataConstants.CLASS_NAME_SEQUENCE_INPUT_FORMAT)) {
- return new FileOffsetIndexer();
- } else {
- throw new AsterixException("Unable to create indexer for data with format: " + inputFormatParameter);
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/LookupReaderFactoryProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/LookupReaderFactoryProvider.java
deleted file mode 100644
index db04479..0000000
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/LookupReaderFactoryProvider.java
+++ /dev/null
@@ -1,46 +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.asterix.external.provider;
-
-import java.util.Map;
-
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.api.ILookupReaderFactory;
-import org.apache.asterix.external.input.record.reader.hdfs.HDFSLookupReaderFactory;
-import org.apache.asterix.external.util.ExternalDataConstants;
-import org.apache.asterix.external.util.HDFSUtils;
-import org.apache.hyracks.api.application.IServiceContext;
-import org.apache.hyracks.api.exceptions.IWarningCollector;
-
-public class LookupReaderFactoryProvider {
-
- @SuppressWarnings("rawtypes")
- public static ILookupReaderFactory getLookupReaderFactory(IServiceContext serviceCtx,
- Map<String, String> configuration, IWarningCollector warningCollector) throws AsterixException {
- String inputFormat = HDFSUtils.getInputFormatClassName(configuration);
- if (inputFormat.equals(ExternalDataConstants.CLASS_NAME_TEXT_INPUT_FORMAT)
- || inputFormat.equals(ExternalDataConstants.CLASS_NAME_SEQUENCE_INPUT_FORMAT)) {
- HDFSLookupReaderFactory<Object> readerFactory = new HDFSLookupReaderFactory<>();
- readerFactory.configure(serviceCtx, configuration, warningCollector);
- return readerFactory;
- } else {
- throw new AsterixException("Unrecognized external format");
- }
- }
-}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
index a4e47ca..7bafd78 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
@@ -35,8 +35,6 @@
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.exceptions.RuntimeDataException;
import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.IndexingScheduler;
-import org.apache.asterix.external.indexing.RecordId.RecordIdType;
import org.apache.asterix.external.input.record.reader.hdfs.parquet.MapredParquetInputFormat;
import org.apache.asterix.external.input.record.reader.hdfs.parquet.ParquetReadSupport;
import org.apache.asterix.external.input.stream.HDFSInputStream;
@@ -56,7 +54,6 @@
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.api.application.ICCServiceContext;
-import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.apache.hyracks.api.context.ICCContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.exceptions.HyracksException;
@@ -85,19 +82,6 @@
return scheduler;
}
- public static IndexingScheduler initializeIndexingHDFSScheduler(ICCServiceContext serviceCtx)
- throws HyracksDataException {
- IndexingScheduler scheduler = null;
- try {
- ICcApplicationContext appCtx = (ICcApplicationContext) serviceCtx.getApplicationContext();
- IHyracksClientConnection hcc = appCtx.getHcc();
- scheduler = new IndexingScheduler(hcc.getNodeControllerInfos());
- } catch (HyracksException e) {
- throw new RuntimeDataException(ErrorCode.UTIL_HDFS_UTILS_CANNOT_OBTAIN_HDFS_SCHEDULER);
- }
- return scheduler;
- }
-
/**
* Instead of creating the split using the input format, we do it manually
* This function returns fileSplits (1 per hdfs file block) irrespective of the number of partitions
@@ -271,17 +255,6 @@
}
- public static RecordIdType getRecordIdType(Map<String, String> configuration) {
- String inputFormatParameter = configuration.get(ExternalDataConstants.KEY_INPUT_FORMAT).trim();
- switch (inputFormatParameter) {
- case ExternalDataConstants.INPUT_FORMAT_TEXT:
- case ExternalDataConstants.INPUT_FORMAT_SEQUENCE:
- return RecordIdType.OFFSET;
- default:
- return null;
- }
- }
-
public static ARecordType getExpectedType(Configuration configuration) throws IOException {
String encoded = configuration.get(ExternalDataConstants.KEY_REQUESTED_FIELDS, "");
if (encoded.isEmpty() || encoded.equals(DataProjectionFiltrationInfo.ALL_FIELDS_TYPE.getTypeName())) {
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
index cafa001..91edc4c 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
@@ -28,7 +28,6 @@
import org.apache.asterix.common.context.IStorageComponentProvider;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.external.indexing.FilesIndexDescription;
import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.formats.nontagged.NullIntrospector;
import org.apache.asterix.metadata.api.IResourceFactoryProvider;
@@ -50,8 +49,6 @@
import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
import org.apache.hyracks.storage.am.lsm.btree.column.api.IColumnManagerFactory;
import org.apache.hyracks.storage.am.lsm.btree.column.dataflow.LSMColumnBTreeLocalResourceFactory;
-import org.apache.hyracks.storage.am.lsm.btree.dataflow.ExternalBTreeLocalResourceFactory;
-import org.apache.hyracks.storage.am.lsm.btree.dataflow.ExternalBTreeWithBuddyLocalResourceFactory;
import org.apache.hyracks.storage.am.lsm.btree.dataflow.LSMBTreeLocalResourceFactory;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
@@ -93,19 +90,7 @@
ITypeTraitProvider typeTraitProvider = mdProvider.getDataFormat().getTypeTraitProvider();
switch (dataset.getDatasetType()) {
case EXTERNAL:
- return index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))
- ? new ExternalBTreeLocalResourceFactory(storageManager, typeTraits, cmpFactories,
- filterTypeTraits, filterCmpFactories, filterFields, opTrackerFactory,
- ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, true, bloomFilterFields,
- bloomFilterFalsePositiveRate, btreeFields, hasBloomFilter,
- typeTraitProvider.getTypeTrait(BuiltinType.ANULL), NullIntrospector.INSTANCE)
- : new ExternalBTreeWithBuddyLocalResourceFactory(storageManager, typeTraits, cmpFactories,
- filterTypeTraits, filterCmpFactories, filterFields, opTrackerFactory,
- ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, true, bloomFilterFields,
- bloomFilterFalsePositiveRate, btreeFields, hasBloomFilter,
- typeTraitProvider.getTypeTrait(BuiltinType.ANULL), NullIntrospector.INSTANCE);
+ return null;
case INTERNAL:
AsterixVirtualBufferCacheProvider vbcProvider =
new AsterixVirtualBufferCacheProvider(dataset.getDatasetId());
@@ -157,7 +142,7 @@
return primaryTypeTraits;
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL
&& index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.EXTERNAL_FILE_INDEX_TYPE_TRAITS;
+ return null;
}
Index.ValueIndexDetails indexDetails = (Index.ValueIndexDetails) index.getIndexDetails();
int numPrimaryKeys = dataset.getPrimaryKeys().size();
@@ -190,7 +175,7 @@
return dataset.getPrimaryComparatorFactories(metadataProvider, recordType, metaType);
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL
&& index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.FILES_INDEX_COMP_FACTORIES;
+ return null;
}
Index.ValueIndexDetails indexDetails = (Index.ValueIndexDetails) index.getIndexDetails();
int numPrimaryKeys = dataset.getPrimaryKeys().size();
@@ -225,7 +210,7 @@
if (dataset.getDatasetType() == DatasetType.EXTERNAL
&& index.getIndexType() != DatasetConfig.IndexType.SAMPLE) {
if (index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
- return FilesIndexDescription.BLOOM_FILTER_FIELDS;
+ return null;
} else {
Index.ValueIndexDetails indexDetails = ((Index.ValueIndexDetails) index.getIndexDetails());
return new int[] { indexDetails.getKeyFieldNames().size() };
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
index 2d3e0e4..409f0e7 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
@@ -57,14 +57,10 @@
import org.apache.asterix.dataflow.data.nontagged.MissingWriterFactory;
import org.apache.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
import org.apache.asterix.external.adapter.factory.ExternalAdapterFactory;
-import org.apache.asterix.external.adapter.factory.LookupAdapterFactory;
import org.apache.asterix.external.api.ITypedAdapterFactory;
import org.apache.asterix.external.feed.policy.FeedPolicyAccessor;
import org.apache.asterix.external.indexing.ExternalFile;
import org.apache.asterix.external.indexing.IndexingConstants;
-import org.apache.asterix.external.operators.ExternalBTreeSearchOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalLookupOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalRTreeSearchOperatorDescriptor;
import org.apache.asterix.external.operators.ExternalScanOperatorDescriptor;
import org.apache.asterix.external.operators.FeedIntakeOperatorDescriptor;
import org.apache.asterix.external.provider.AdapterFactoryProvider;
@@ -82,7 +78,6 @@
import org.apache.asterix.metadata.entities.DatasourceAdapter;
import org.apache.asterix.metadata.entities.Datatype;
import org.apache.asterix.metadata.entities.Dataverse;
-import org.apache.asterix.metadata.entities.ExternalDatasetDetails;
import org.apache.asterix.metadata.entities.Feed;
import org.apache.asterix.metadata.entities.FeedConnection;
import org.apache.asterix.metadata.entities.FeedPolicyEntity;
@@ -92,7 +87,6 @@
import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.metadata.entities.Synonym;
import org.apache.asterix.metadata.feeds.FeedMetadataUtil;
-import org.apache.asterix.metadata.lock.ExternalDatasetsRegistry;
import org.apache.asterix.metadata.utils.DatasetUtil;
import org.apache.asterix.metadata.utils.FullTextUtil;
import org.apache.asterix.metadata.utils.IndexUtil;
@@ -625,10 +619,7 @@
proceedIndexOnlyPlan, failValueForIndexOnlyPlan, successValueForIndexOnlyPlan,
tupleProjectorFactory);
} else {
- btreeSearchOp = new ExternalBTreeSearchOperatorDescriptor(jobSpec, outputRecDesc, lowKeyFields,
- highKeyFields, lowKeyInclusive, highKeyInclusive, indexHelperFactory, retainInput, retainMissing,
- nonMatchWriterFactory, searchCallbackFactory, minFilterFieldIndexes, maxFilterFieldIndexes,
- ExternalDatasetsRegistry.INSTANCE.getAndLockDatasetVersion(dataset, this));
+ btreeSearchOp = null;
}
return new Pair<>(btreeSearchOp, spPc.second);
}
@@ -689,10 +680,7 @@
nonFilterWriterFactory, isIndexOnlyPlan, failValueForIndexOnlyPlan, successValueForIndexOnlyPlan);
} else {
// Create the operator
- rtreeSearchOp = new ExternalRTreeSearchOperatorDescriptor(jobSpec, outputRecDesc, keyFields, true, true,
- indexDataflowHelperFactory, retainInput, retainMissing, nonMatchWriterFactory,
- searchCallbackFactory, minFilterFieldIndexes, maxFilterFieldIndexes,
- ExternalDatasetsRegistry.INSTANCE.getAndLockDatasetVersion(dataset, this));
+ rtreeSearchOp = null;
}
return new Pair<>(rtreeSearchOp, spPc.second);
@@ -972,36 +960,7 @@
JobSpecification jobSpec, Dataset dataset, int[] ridIndexes, boolean retainInput,
IVariableTypeEnvironment typeEnv, IOperatorSchema opSchema, JobGenContext context,
MetadataProvider metadataProvider, boolean retainMissing) throws AlgebricksException {
- try {
- // Get data type
- ARecordType itemType =
- (ARecordType) MetadataManager.INSTANCE.getDatatype(metadataProvider.getMetadataTxnContext(),
- dataset.getDataverseName(), dataset.getItemTypeName()).getDatatype();
- ExternalDatasetDetails datasetDetails = (ExternalDatasetDetails) dataset.getDatasetDetails();
- LookupAdapterFactory<?> adapterFactory = AdapterFactoryProvider.getLookupAdapterFactory(
- getApplicationContext().getServiceContext(), datasetDetails.getProperties(), itemType, ridIndexes,
- retainInput, retainMissing, context.getMissingWriterFactory(), context.getWarningCollector());
- String fileIndexName = IndexingConstants.getFilesIndexName(dataset.getDatasetName());
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> spPc =
- metadataProvider.getSplitProviderAndConstraints(dataset, fileIndexName);
- Index fileIndex = MetadataManager.INSTANCE.getIndex(mdTxnCtx, dataset.getDataverseName(),
- dataset.getDatasetName(), fileIndexName);
- // Create the file index data flow helper
- IIndexDataflowHelperFactory indexDataflowHelperFactory =
- new IndexDataflowHelperFactory(storageComponentProvider.getStorageManager(), spPc.first);
- // Create the out record descriptor, appContext and fileSplitProvider for the
- // files index
- RecordDescriptor outRecDesc = JobGenHelper.mkRecordDescriptor(typeEnv, opSchema, context);
- ISearchOperationCallbackFactory searchOpCallbackFactory =
- dataset.getSearchCallbackFactory(storageComponentProvider, fileIndex, IndexOperation.SEARCH, null);
- // Create the operator
- ExternalLookupOperatorDescriptor op = new ExternalLookupOperatorDescriptor(jobSpec, adapterFactory,
- outRecDesc, indexDataflowHelperFactory, searchOpCallbackFactory,
- ExternalDatasetsRegistry.INSTANCE.getAndLockDatasetVersion(dataset, this));
- return new Pair<>(op, spPc.second);
- } catch (Exception e) {
- throw new AlgebricksException(e);
- }
+ return null;
}
@Override
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
index 0774928..a35be40 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
@@ -19,6 +19,7 @@
package org.apache.asterix.metadata.entities;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -46,7 +47,6 @@
import org.apache.asterix.common.utils.JobUtils.ProgressState;
import org.apache.asterix.common.utils.StoragePathUtil;
import org.apache.asterix.external.feed.management.FeedConnectionId;
-import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.formats.nontagged.BinaryHashFunctionFactoryProvider;
import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
import org.apache.asterix.formats.nontagged.TypeTraitProvider;
@@ -59,9 +59,7 @@
import org.apache.asterix.metadata.declared.ArrayBTreeResourceFactoryProvider;
import org.apache.asterix.metadata.declared.BTreeResourceFactoryProvider;
import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.metadata.lock.ExternalDatasetsRegistry;
import org.apache.asterix.metadata.utils.DatasetUtil;
-import org.apache.asterix.metadata.utils.ExternalIndexingOperations;
import org.apache.asterix.metadata.utils.IndexUtil;
import org.apache.asterix.metadata.utils.InvertedIndexResourceFactoryProvider;
import org.apache.asterix.metadata.utils.MetadataUtil;
@@ -387,42 +385,6 @@
bActiveTxn.setValue(true);
metadataProvider.setMetadataTxnContext(mdTxnCtx.getValue());
} else if (getDatasetType() == DatasetType.EXTERNAL) {
- // External dataset
- ExternalDatasetsRegistry.INSTANCE.removeDatasetInfo(this);
- // #. prepare jobs to drop the datatset and the indexes in NC
- List<Index> indexes =
- MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx.getValue(), dataverseName, datasetName);
- for (int j = 0; j < indexes.size(); j++) {
- if (ExternalIndexingOperations.isFileIndex(indexes.get(j))) {
- jobsToExecute
- .add(IndexUtil.buildDropIndexJobSpec(indexes.get(j), metadataProvider, this, sourceLoc));
- } else {
- jobsToExecute.add(DatasetUtil.buildDropFilesIndexJobSpec(metadataProvider, this));
- }
- }
-
- // #. mark the existing dataset as PendingDropOp
- MetadataManager.INSTANCE.dropDataset(mdTxnCtx.getValue(), dataverseName, datasetName, force);
- MetadataManager.INSTANCE.addDataset(mdTxnCtx.getValue(),
- new Dataset(dataverseName, datasetName, getItemTypeDataverseName(), getItemTypeName(),
- getNodeGroupName(), getCompactionPolicy(), getCompactionPolicyProperties(),
- getDatasetDetails(), getHints(), getDatasetType(), getDatasetId(),
- MetadataUtil.PENDING_DROP_OP));
-
- MetadataManager.INSTANCE.commitTransaction(mdTxnCtx.getValue());
- bActiveTxn.setValue(false);
- progress.setValue(ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA);
-
- // #. run the jobs
- for (JobSpecification jobSpec : jobsToExecute) {
- JobUtils.runJob(hcc, jobSpec, true);
- }
- if (!indexes.isEmpty()) {
- ExternalDatasetsRegistry.INSTANCE.removeDatasetInfo(this);
- }
- mdTxnCtx.setValue(MetadataManager.INSTANCE.beginTransaction());
- bActiveTxn.setValue(true);
- metadataProvider.setMetadataTxnContext(mdTxnCtx.getValue());
}
// #. finally, delete the dataset.
@@ -684,7 +646,7 @@
@Override
public List<List<String>> getPrimaryKeys() {
if (getDatasetType() == DatasetType.EXTERNAL) {
- return IndexingConstants.getRIDKeys(((ExternalDatasetDetails) getDatasetDetails()).getProperties());
+ return Collections.emptyList();
}
return ((InternalDatasetDetails) getDatasetDetails()).getPartitioningKey();
}
@@ -710,7 +672,7 @@
indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator();
}
for (int i = 0; i < numPrimaryKeys; i++) {
- IAType keyType = datasetType == DatasetType.EXTERNAL ? IndexingConstants.getFieldType(i)
+ IAType keyType = datasetType == DatasetType.EXTERNAL ? null
: (indicators == null || indicators.get(i) == 0)
? recordType.getSubFieldType(partitioningKeys.get(i))
: metaType.getSubFieldType(partitioningKeys.get(i));
@@ -747,7 +709,7 @@
// Set the serde/traits for primary keys
for (int i = 0; i < numPrimaryKeys; i++) {
IAType keyType =
- datasetType == DatasetType.EXTERNAL ? IndexingConstants.getFieldType(i)
+ datasetType == DatasetType.EXTERNAL ? null
: (indicators == null || indicators.get(i) == 0)
? itemType.getSubFieldType(partitioningKeys.get(i))
: metaType.getSubFieldType(partitioningKeys.get(i));
@@ -786,7 +748,7 @@
indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator();
}
for (int i = 0; i < numPrimaryKeys; i++) {
- IAType keyType = datasetType == DatasetType.EXTERNAL ? IndexingConstants.getFieldType(i)
+ IAType keyType = datasetType == DatasetType.EXTERNAL ? null
: (indicators == null || indicators.get(i) == 0)
? recordType.getSubFieldType(partitioningKeys.get(i))
: metaType.getSubFieldType(partitioningKeys.get(i));
@@ -814,7 +776,7 @@
indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator();
}
for (int i = 0; i < numPrimaryKeys; i++) {
- IAType keyType = datasetType == DatasetType.EXTERNAL ? IndexingConstants.getFieldType(i)
+ IAType keyType = datasetType == DatasetType.EXTERNAL ? null
: (indicators == null || indicators.get(i) == 0)
? recordType.getSubFieldType(partitioningKeys.get(i))
: metaType.getSubFieldType(partitioningKeys.get(i));
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/ExternalIndexingOperations.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/ExternalIndexingOperations.java
deleted file mode 100644
index c6eafe0..0000000
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/ExternalIndexingOperations.java
+++ /dev/null
@@ -1,551 +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.asterix.metadata.utils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.asterix.common.config.DatasetConfig.DatasetType;
-import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
-import org.apache.asterix.common.config.DatasetConfig.TransactionState;
-import org.apache.asterix.common.context.IStorageComponentProvider;
-import org.apache.asterix.external.api.ITypedAdapterFactory;
-import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.IndexingConstants;
-import org.apache.asterix.external.operators.ExternalDatasetIndexesAbortOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalDatasetIndexesCommitOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalDatasetIndexesRecoverOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalFilesIndexCreateOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalFilesIndexModificationOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalScanOperatorDescriptor;
-import org.apache.asterix.external.provider.AdapterFactoryProvider;
-import org.apache.asterix.external.util.ExternalDataConstants;
-import org.apache.asterix.metadata.MetadataManager;
-import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.metadata.entities.Dataset;
-import org.apache.asterix.metadata.entities.ExternalDatasetDetails;
-import org.apache.asterix.metadata.entities.Index;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.runtime.utils.RuntimeUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
-import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
-import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraintHelper;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.utils.Pair;
-import org.apache.hyracks.algebricks.core.jobgen.impl.ConnectorPolicyAssignmentPolicy;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.NoOpWarningCollector;
-import org.apache.hyracks.api.exceptions.SourceLocation;
-import org.apache.hyracks.api.job.JobSpecification;
-import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
-import org.apache.hyracks.storage.am.common.api.IIndexBuilderFactory;
-import org.apache.hyracks.storage.am.common.build.IndexBuilderFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IndexDataflowHelperFactory;
-import org.apache.hyracks.storage.am.common.dataflow.IndexDropOperatorDescriptor;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.common.IResourceFactory;
-import org.apache.hyracks.storage.common.IStorageManager;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class ExternalIndexingOperations {
- private static final Logger LOGGER = LogManager.getLogger();
- /**
- * Note: there's a special handling of this empty indexing field name in
- * {@link org.apache.asterix.metadata.entitytupletranslators.IndexTupleTranslator
- * IndexTupleTranslator.createMetadataEntityFromARecord()}
- */
- public static final List<List<String>> FILE_INDEX_FIELD_NAMES =
- Collections.unmodifiableList(Collections.singletonList(Collections.singletonList("")));
- public static final List<IAType> FILE_INDEX_FIELD_TYPES =
- Collections.unmodifiableList(Collections.singletonList(BuiltinType.ASTRING));
-
- private ExternalIndexingOperations() {
- }
-
- public static boolean isIndexible(ExternalDatasetDetails ds) {
- String adapter = ds.getAdapter();
- if (adapter.equalsIgnoreCase(ExternalDataConstants.ALIAS_HDFS_ADAPTER)) {
- return true;
- }
- return false;
- }
-
- public static boolean isRefereshActive(ExternalDatasetDetails ds) {
- return ds.getState() != TransactionState.COMMIT;
- }
-
- public static boolean isValidIndexName(String datasetName, String indexName) {
- return !datasetName.concat(IndexingConstants.EXTERNAL_FILE_INDEX_NAME_SUFFIX).equals(indexName);
- }
-
- public static int getRIDSize(Dataset dataset) {
- ExternalDatasetDetails dsd = (ExternalDatasetDetails) dataset.getDatasetDetails();
- return IndexingConstants.getRIDSize(dsd.getProperties().get(IndexingConstants.KEY_INPUT_FORMAT));
- }
-
- public static IBinaryComparatorFactory[] getComparatorFactories(Dataset dataset) {
- ExternalDatasetDetails dsd = (ExternalDatasetDetails) dataset.getDatasetDetails();
- return IndexingConstants.getComparatorFactories(dsd.getProperties().get(IndexingConstants.KEY_INPUT_FORMAT));
- }
-
- public static IBinaryComparatorFactory[] getBuddyBtreeComparatorFactories() {
- return IndexingConstants.getBuddyBtreeComparatorFactories();
- }
-
- public static List<ExternalFile> getSnapshotFromExternalFileSystem(Dataset dataset) throws AlgebricksException {
- ArrayList<ExternalFile> files = new ArrayList<>();
- ExternalDatasetDetails datasetDetails = (ExternalDatasetDetails) dataset.getDatasetDetails();
- try {
- // Create the file system object
- FileSystem fs = getFileSystemObject(datasetDetails.getProperties());
- // Get paths of dataset
- String path = datasetDetails.getProperties().get(ExternalDataConstants.KEY_PATH);
- String[] paths = path.split(",");
-
- // Add fileStatuses to files
- for (String aPath : paths) {
- FileStatus[] fileStatuses = fs.listStatus(new Path(aPath));
- for (int i = 0; i < fileStatuses.length; i++) {
- int nextFileNumber = files.size();
- handleFile(dataset, files, fs, fileStatuses[i], nextFileNumber);
- }
- }
- // Close file system
- fs.close();
- if (files.isEmpty()) {
- throw new AlgebricksException("File Snapshot retrieved from external file system is empty");
- }
- return files;
- } catch (Exception e) {
- LOGGER.warn("Exception while trying to get snapshot from external system", e);
- throw new AlgebricksException("Unable to get list of HDFS files " + e);
- }
- }
-
- private static void handleFile(Dataset dataset, List<ExternalFile> files, FileSystem fs, FileStatus fileStatus,
- int nextFileNumber) throws IOException {
- if (fileStatus.isDirectory()) {
- listSubFiles(dataset, fs, fileStatus, files);
- } else {
- files.add(new ExternalFile(dataset.getDataverseName(), dataset.getDatasetName(), nextFileNumber,
- fileStatus.getPath().toUri().getPath(), new Date(fileStatus.getModificationTime()),
- fileStatus.getLen(), ExternalFilePendingOp.NO_OP));
- }
- }
-
- /* list all files under the directory
- * src is expected to be a folder
- */
- private static void listSubFiles(Dataset dataset, FileSystem srcFs, FileStatus src, List<ExternalFile> files)
- throws IOException {
- Path path = src.getPath();
- FileStatus[] fileStatuses = srcFs.listStatus(path);
- for (int i = 0; i < fileStatuses.length; i++) {
- int nextFileNumber = files.size();
- if (fileStatuses[i].isDirectory()) {
- listSubFiles(dataset, srcFs, fileStatuses[i], files);
- } else {
- files.add(new ExternalFile(dataset.getDataverseName(), dataset.getDatasetName(), nextFileNumber,
- fileStatuses[i].getPath().toUri().getPath(), new Date(fileStatuses[i].getModificationTime()),
- fileStatuses[i].getLen(), ExternalFilePendingOp.NO_OP));
- }
- }
- }
-
- public static FileSystem getFileSystemObject(Map<String, String> map) throws IOException {
- Configuration conf = new Configuration();
- conf.set(ExternalDataConstants.KEY_HADOOP_FILESYSTEM_URI, map.get(ExternalDataConstants.KEY_HDFS_URL).trim());
- conf.set(ExternalDataConstants.KEY_HADOOP_FILESYSTEM_CLASS, DistributedFileSystem.class.getName());
- return FileSystem.get(conf);
- }
-
- public static JobSpecification buildFilesIndexCreateJobSpec(Dataset dataset,
- List<ExternalFile> externalFilesSnapshot, MetadataProvider metadataProvider) throws AlgebricksException {
- IStorageComponentProvider storageComponentProvider = metadataProvider.getStorageComponentProvider();
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- Pair<ILSMMergePolicyFactory, Map<String, String>> compactionInfo =
- DatasetUtil.getMergePolicyFactory(dataset, metadataProvider.getMetadataTxnContext());
- ILSMMergePolicyFactory mergePolicyFactory = compactionInfo.first;
- Map<String, String> mergePolicyProperties = compactionInfo.second;
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
- .getSplitProviderAndConstraints(dataset, IndexingConstants.getFilesIndexName(dataset.getDatasetName()));
- IFileSplitProvider secondaryFileSplitProvider = secondarySplitsAndConstraint.first;
- String fileIndexName = IndexingConstants.getFilesIndexName(dataset.getDatasetName());
- Index fileIndex = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(),
- dataset.getDataverseName(), dataset.getDatasetName(), fileIndexName);
- ARecordType recordType =
- (ARecordType) metadataProvider.findType(dataset.getItemTypeDataverseName(), dataset.getItemTypeName());
- IResourceFactory resourceFactory = dataset.getResourceFactory(metadataProvider, fileIndex, recordType, null,
- mergePolicyFactory, mergePolicyProperties);
- IIndexBuilderFactory indexBuilderFactory = new IndexBuilderFactory(storageComponentProvider.getStorageManager(),
- secondaryFileSplitProvider, resourceFactory, true);
- IIndexDataflowHelperFactory dataflowHelperFactory = new IndexDataflowHelperFactory(
- storageComponentProvider.getStorageManager(), secondaryFileSplitProvider);
- ExternalFilesIndexCreateOperatorDescriptor externalFilesOp = new ExternalFilesIndexCreateOperatorDescriptor(
- spec, indexBuilderFactory, dataflowHelperFactory, externalFilesSnapshot);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, externalFilesOp,
- secondarySplitsAndConstraint.second);
- spec.addRoot(externalFilesOp);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
- return spec;
- }
-
- public static JobSpecification buildFilesIndexUpdateJobSpec(Dataset dataset,
- List<ExternalFile> externalFilesSnapshot, MetadataProvider metadataProvider) throws AlgebricksException {
- IStorageComponentProvider storageComponentProvider = metadataProvider.getStorageComponentProvider();
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
- .getSplitProviderAndConstraints(dataset, IndexingConstants.getFilesIndexName(dataset.getDatasetName()));
- IFileSplitProvider secondaryFileSplitProvider = secondarySplitsAndConstraint.first;
- IIndexDataflowHelperFactory dataflowHelperFactory = new IndexDataflowHelperFactory(
- storageComponentProvider.getStorageManager(), secondaryFileSplitProvider);
- ExternalFilesIndexModificationOperatorDescriptor externalFilesOp =
- new ExternalFilesIndexModificationOperatorDescriptor(spec, dataflowHelperFactory,
- externalFilesSnapshot);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, externalFilesOp,
- secondarySplitsAndConstraint.second);
- spec.addRoot(externalFilesOp);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
- return spec;
- }
-
- /**
- * This method create an indexing operator that index records in HDFS
- *
- * @param jobSpec
- * @param itemType
- * @param dataset
- * @param files
- * @param indexerDesc
- * @param sourceLoc
- * @return
- * @throws AlgebricksException
- * @throws HyracksDataException
- * @throws Exception
- */
- private static Pair<ExternalScanOperatorDescriptor, AlgebricksPartitionConstraint> getIndexingOperator(
- MetadataProvider metadataProvider, JobSpecification jobSpec, IAType itemType, Dataset dataset,
- List<ExternalFile> files, RecordDescriptor indexerDesc, SourceLocation sourceLoc)
- throws HyracksDataException, AlgebricksException {
- ExternalDatasetDetails externalDatasetDetails = (ExternalDatasetDetails) dataset.getDatasetDetails();
- Map<String, String> configuration = externalDatasetDetails.getProperties();
- ITypedAdapterFactory adapterFactory = AdapterFactoryProvider.getIndexingAdapterFactory(
- metadataProvider.getApplicationContext().getServiceContext(), externalDatasetDetails.getAdapter(),
- configuration, (ARecordType) itemType, files, true, null, NoOpWarningCollector.INSTANCE);
- ExternalScanOperatorDescriptor scanOp =
- new ExternalScanOperatorDescriptor(jobSpec, indexerDesc, adapterFactory);
- scanOp.setSourceLocation(sourceLoc);
- return new Pair<>(scanOp, adapterFactory.getPartitionConstraint());
- }
-
- public static Pair<ExternalScanOperatorDescriptor, AlgebricksPartitionConstraint> createExternalIndexingOp(
- JobSpecification spec, MetadataProvider metadataProvider, Dataset dataset, ARecordType itemType,
- RecordDescriptor indexerDesc, List<ExternalFile> files, SourceLocation sourceLoc)
- throws HyracksDataException, AlgebricksException {
- return getIndexingOperator(metadataProvider, spec, itemType, dataset,
- files == null ? MetadataManager.INSTANCE
- .getDatasetExternalFiles(metadataProvider.getMetadataTxnContext(), dataset) : files,
- indexerDesc, sourceLoc);
- }
-
- /**
- * At the end of this method, we expect to have 4 sets as follows:
- * metadataFiles should contain only the files that are appended in their original state
- * addedFiles should contain new files that has number assigned starting after the max original file number
- * deletedFiles should contain files that are no longer there in the file system
- * appendedFiles should have the new file information of existing files
- * The method should return false in case of zero delta
- *
- * @param dataset
- * @param metadataFiles
- * @param addedFiles
- * @param deletedFiles
- * @param appendedFiles
- * @return
- * @throws AlgebricksException
- */
- public static boolean isDatasetUptodate(Dataset dataset, List<ExternalFile> metadataFiles,
- List<ExternalFile> addedFiles, List<ExternalFile> deletedFiles, List<ExternalFile> appendedFiles)
- throws AlgebricksException {
- boolean uptodate = true;
- int newFileNumber = metadataFiles.get(metadataFiles.size() - 1).getFileNumber() + 1;
-
- List<ExternalFile> fileSystemFiles = getSnapshotFromExternalFileSystem(dataset);
-
- // Loop over file system files < taking care of added files >
- for (ExternalFile fileSystemFile : fileSystemFiles) {
- boolean fileFound = false;
- Iterator<ExternalFile> mdFilesIterator = metadataFiles.iterator();
- while (mdFilesIterator.hasNext()) {
- ExternalFile metadataFile = mdFilesIterator.next();
- if (!fileSystemFile.getFileName().equals(metadataFile.getFileName())) {
- continue;
- }
- // Same file name
- if (fileSystemFile.getLastModefiedTime().equals(metadataFile.getLastModefiedTime())) {
- // Same timestamp
- if (fileSystemFile.getSize() == metadataFile.getSize()) {
- // Same size -> no op
- mdFilesIterator.remove();
- fileFound = true;
- } else {
- // Different size -> append op
- metadataFile.setPendingOp(ExternalFilePendingOp.APPEND_OP);
- fileSystemFile.setPendingOp(ExternalFilePendingOp.APPEND_OP);
- appendedFiles.add(fileSystemFile);
- fileFound = true;
- uptodate = false;
- }
- } else {
- // Same file name, Different file mod date -> delete and add
- metadataFile.setPendingOp(ExternalFilePendingOp.DROP_OP);
- deletedFiles.add(new ExternalFile(metadataFile.getDataverseName(), metadataFile.getDatasetName(), 0,
- metadataFile.getFileName(), metadataFile.getLastModefiedTime(), metadataFile.getSize(),
- ExternalFilePendingOp.DROP_OP));
- fileSystemFile.setPendingOp(ExternalFilePendingOp.ADD_OP);
- fileSystemFile.setFileNumber(newFileNumber);
- addedFiles.add(fileSystemFile);
- newFileNumber++;
- fileFound = true;
- uptodate = false;
- }
- if (fileFound) {
- break;
- }
- }
- if (!fileFound) {
- // File not stored previously in metadata -> pending add op
- fileSystemFile.setPendingOp(ExternalFilePendingOp.ADD_OP);
- fileSystemFile.setFileNumber(newFileNumber);
- addedFiles.add(fileSystemFile);
- newFileNumber++;
- uptodate = false;
- }
- }
-
- // Done with files from external file system -> metadata files now contain both deleted files and appended ones
- // first, correct number assignment to deleted and updated files
- for (ExternalFile deletedFile : deletedFiles) {
- deletedFile.setFileNumber(newFileNumber);
- newFileNumber++;
- }
- for (ExternalFile appendedFile : appendedFiles) {
- appendedFile.setFileNumber(newFileNumber);
- newFileNumber++;
- }
-
- // include the remaining deleted files
- Iterator<ExternalFile> mdFilesIterator = metadataFiles.iterator();
- while (mdFilesIterator.hasNext()) {
- ExternalFile metadataFile = mdFilesIterator.next();
- if (metadataFile.getPendingOp() == ExternalFilePendingOp.NO_OP) {
- metadataFile.setPendingOp(ExternalFilePendingOp.DROP_OP);
- deletedFiles.add(new ExternalFile(metadataFile.getDataverseName(), metadataFile.getDatasetName(),
- newFileNumber, metadataFile.getFileName(), metadataFile.getLastModefiedTime(),
- metadataFile.getSize(), metadataFile.getPendingOp()));
- newFileNumber++;
- uptodate = false;
- }
- }
- return uptodate;
- }
-
- public static Dataset createTransactionDataset(Dataset dataset) {
- ExternalDatasetDetails originalDsd = (ExternalDatasetDetails) dataset.getDatasetDetails();
- ExternalDatasetDetails dsd = new ExternalDatasetDetails(originalDsd.getAdapter(), originalDsd.getProperties(),
- originalDsd.getTimestamp(), TransactionState.BEGIN);
- return new Dataset(dataset.getDataverseName(), dataset.getDatasetName(), dataset.getItemTypeDataverseName(),
- dataset.getItemTypeName(), dataset.getNodeGroupName(), dataset.getCompactionPolicy(),
- dataset.getCompactionPolicyProperties(), dsd, dataset.getHints(), DatasetType.EXTERNAL,
- dataset.getDatasetId(), dataset.getPendingOp());
- }
-
- public static JobSpecification buildDropFilesIndexJobSpec(MetadataProvider metadataProvider, Dataset dataset)
- throws AlgebricksException {
- String indexName = IndexingConstants.getFilesIndexName(dataset.getDatasetName());
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> splitsAndConstraint =
- metadataProvider.getSplitProviderAndConstraints(dataset, indexName);
- IIndexDataflowHelperFactory dataflowHelperFactory = new IndexDataflowHelperFactory(
- metadataProvider.getStorageComponentProvider().getStorageManager(), splitsAndConstraint.first);
- IndexDropOperatorDescriptor btreeDrop = new IndexDropOperatorDescriptor(spec, dataflowHelperFactory);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, btreeDrop,
- splitsAndConstraint.second);
- spec.addRoot(btreeDrop);
-
- return spec;
- }
-
- public static JobSpecification buildFilesIndexUpdateOp(Dataset ds, List<ExternalFile> metadataFiles,
- List<ExternalFile> addedFiles, List<ExternalFile> appendedFiles, MetadataProvider metadataProvider)
- throws AlgebricksException {
- ArrayList<ExternalFile> files = new ArrayList<>();
- for (ExternalFile file : metadataFiles) {
- if (file.getPendingOp() == ExternalFilePendingOp.DROP_OP) {
- files.add(file);
- } else if (file.getPendingOp() == ExternalFilePendingOp.APPEND_OP) {
- for (ExternalFile appendedFile : appendedFiles) {
- if (appendedFile.getFileName().equals(file.getFileName())) {
- files.add(new ExternalFile(file.getDataverseName(), file.getDatasetName(), file.getFileNumber(),
- file.getFileName(), file.getLastModefiedTime(), appendedFile.getSize(),
- ExternalFilePendingOp.NO_OP));
- }
- }
- }
- }
- for (ExternalFile file : addedFiles) {
- files.add(file);
- }
- Collections.sort(files);
- return buildFilesIndexUpdateJobSpec(ds, files, metadataProvider);
- }
-
- public static JobSpecification buildIndexUpdateOp(Dataset ds, Index index, List<ExternalFile> metadataFiles,
- List<ExternalFile> addedFiles, List<ExternalFile> appendedFiles, MetadataProvider metadataProvider,
- SourceLocation sourceLoc) throws AlgebricksException {
- // Create files list
- ArrayList<ExternalFile> files = new ArrayList<>();
-
- for (ExternalFile metadataFile : metadataFiles) {
- if (metadataFile.getPendingOp() != ExternalFilePendingOp.APPEND_OP) {
- files.add(metadataFile);
- } else {
- metadataFile.setPendingOp(ExternalFilePendingOp.NO_OP);
- files.add(metadataFile);
- }
- }
- // add new files
- for (ExternalFile file : addedFiles) {
- files.add(file);
- }
- // add appended files
- for (ExternalFile file : appendedFiles) {
- files.add(file);
- }
- return IndexUtil.buildSecondaryIndexLoadingJobSpec(ds, index, metadataProvider, files, sourceLoc);
- }
-
- public static JobSpecification buildCommitJob(Dataset ds, List<Index> indexes, MetadataProvider metadataProvider)
- throws AlgebricksException {
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- IStorageManager storageMgr = metadataProvider.getStorageComponentProvider().getStorageManager();
- ArrayList<IIndexDataflowHelperFactory> treeDataflowHelperFactories = new ArrayList<>();
- AlgebricksPartitionConstraint constraints = null;
- for (Index index : indexes) {
- IFileSplitProvider indexSplitProvider;
- if (isValidIndexName(index.getDatasetName(), index.getIndexName())) {
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> sAndConstraints =
- metadataProvider.getSplitProviderAndConstraints(ds, index.getIndexName());
- indexSplitProvider = sAndConstraints.first;
- constraints = sAndConstraints.second;
- } else {
- indexSplitProvider = metadataProvider.getSplitProviderAndConstraints(ds,
- IndexingConstants.getFilesIndexName(ds.getDatasetName())).first;
- }
- IIndexDataflowHelperFactory indexDataflowHelperFactory =
- new IndexDataflowHelperFactory(storageMgr, indexSplitProvider);
- treeDataflowHelperFactories.add(indexDataflowHelperFactory);
- }
- ExternalDatasetIndexesCommitOperatorDescriptor op =
- new ExternalDatasetIndexesCommitOperatorDescriptor(spec, treeDataflowHelperFactories);
- spec.addRoot(op);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, op, constraints);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
- return spec;
- }
-
- public static JobSpecification buildAbortOp(Dataset ds, List<Index> indexes, MetadataProvider metadataProvider)
- throws AlgebricksException {
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- IStorageManager storageMgr = metadataProvider.getStorageComponentProvider().getStorageManager();
- ArrayList<IIndexDataflowHelperFactory> treeDataflowHelperFactories = new ArrayList<>();
- AlgebricksPartitionConstraint constraints = null;
- for (Index index : indexes) {
- IFileSplitProvider indexSplitProvider;
- if (isValidIndexName(index.getDatasetName(), index.getIndexName())) {
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> sAndConstraints =
- metadataProvider.getSplitProviderAndConstraints(ds, index.getIndexName());
- indexSplitProvider = sAndConstraints.first;
- constraints = sAndConstraints.second;
- } else {
- indexSplitProvider = metadataProvider.getSplitProviderAndConstraints(ds,
- IndexingConstants.getFilesIndexName(ds.getDatasetName())).first;
- }
- IIndexDataflowHelperFactory indexDataflowHelperFactory =
- new IndexDataflowHelperFactory(storageMgr, indexSplitProvider);
- treeDataflowHelperFactories.add(indexDataflowHelperFactory);
- }
- ExternalDatasetIndexesAbortOperatorDescriptor op =
- new ExternalDatasetIndexesAbortOperatorDescriptor(spec, treeDataflowHelperFactories);
-
- spec.addRoot(op);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, op, constraints);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
- return spec;
-
- }
-
- public static JobSpecification buildRecoverOp(Dataset ds, List<Index> indexes, MetadataProvider metadataProvider)
- throws AlgebricksException {
- JobSpecification spec = RuntimeUtils.createJobSpecification(metadataProvider.getApplicationContext());
- IStorageManager storageMgr = metadataProvider.getStorageComponentProvider().getStorageManager();
- ArrayList<IIndexDataflowHelperFactory> treeDataflowHelperFactories = new ArrayList<>();
- AlgebricksPartitionConstraint constraints = null;
- for (Index index : indexes) {
- IFileSplitProvider indexSplitProvider;
- if (isValidIndexName(index.getDatasetName(), index.getIndexName())) {
- Pair<IFileSplitProvider, AlgebricksPartitionConstraint> sAndConstraints =
- metadataProvider.getSplitProviderAndConstraints(ds, index.getIndexName());
- indexSplitProvider = sAndConstraints.first;
- constraints = sAndConstraints.second;
- } else {
- indexSplitProvider = metadataProvider.getSplitProviderAndConstraints(ds,
- IndexingConstants.getFilesIndexName(ds.getDatasetName())).first;
- }
- IIndexDataflowHelperFactory indexDataflowHelperFactory =
- new IndexDataflowHelperFactory(storageMgr, indexSplitProvider);
- treeDataflowHelperFactories.add(indexDataflowHelperFactory);
- }
- ExternalDatasetIndexesRecoverOperatorDescriptor op =
- new ExternalDatasetIndexesRecoverOperatorDescriptor(spec, treeDataflowHelperFactories);
- spec.addRoot(op);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, op, constraints);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
- return spec;
- }
-
- public static boolean isFileIndex(Index index) {
- return index.getIndexName().equals(IndexingConstants.getFilesIndexName(index.getDatasetName()));
- }
-}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/RTreeResourceFactoryProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/RTreeResourceFactoryProvider.java
index aa37ebb..36a5351 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/RTreeResourceFactoryProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/RTreeResourceFactoryProvider.java
@@ -27,7 +27,6 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.formats.nontagged.NullIntrospector;
import org.apache.asterix.metadata.api.IResourceFactoryProvider;
import org.apache.asterix.metadata.declared.MetadataProvider;
@@ -54,7 +53,6 @@
import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.rtree.dataflow.ExternalRTreeLocalResourceFactory;
import org.apache.hyracks.storage.am.lsm.rtree.dataflow.LSMRTreeWithAntiMatterLocalResourceFactory;
import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
import org.apache.hyracks.storage.common.IResourceFactory;
@@ -130,8 +128,8 @@
}
for (int i = 0; i < numPrimaryKeys; i++) {
- secondaryTypeTraits[numNestedSecondaryKeyFields + i] = (dataset.getDatasetType() == DatasetType.INTERNAL)
- ? primaryTypeTraits[i] : IndexingConstants.getTypeTraits(i);
+ secondaryTypeTraits[numNestedSecondaryKeyFields + i] =
+ (dataset.getDatasetType() == DatasetType.INTERNAL) ? primaryTypeTraits[i] : null;
}
int[] rtreeFields = null;
if (filterTypeTraits != null && filterTypeTraits.length > 0) {
@@ -154,10 +152,9 @@
IBinaryComparatorFactory[] rtreeCmpFactories = getCmpFactories(mdProvider, index, recordType, metaType);
int[] secondaryFilterFields = (filterTypeTraits != null && filterTypeTraits.length > 0)
? new int[] { numNestedSecondaryKeyFields + numPrimaryKeys } : null;
- IBinaryComparatorFactory[] btreeCompFactories =
- dataset.getDatasetType() == DatasetType.EXTERNAL ? IndexingConstants.getBuddyBtreeComparatorFactories()
- : getComparatorFactoriesForDeletedKeyBTree(secondaryTypeTraits, primaryComparatorFactories,
- secondaryComparatorFactories);
+ IBinaryComparatorFactory[] btreeCompFactories = dataset.getDatasetType() == DatasetType.EXTERNAL ? null
+ : getComparatorFactoriesForDeletedKeyBTree(secondaryTypeTraits, primaryComparatorFactories,
+ secondaryComparatorFactories);
ITypeTraitProvider typeTraitProvider = mdProvider.getDataFormat().getTypeTraitProvider();
if (dataset.getDatasetType() == DatasetType.INTERNAL) {
AsterixVirtualBufferCacheProvider vbcProvider =
@@ -169,13 +166,7 @@
linearizeCmpFactory, rtreeFields, isPointMBR, btreeCompFactories,
typeTraitProvider.getTypeTrait(BuiltinType.ANULL), NullIntrospector.INSTANCE);
} else {
- return new ExternalRTreeLocalResourceFactory(storageManager, typeTraits, rtreeCmpFactories,
- filterTypeTraits, filterCmpFactories, secondaryFilterFields, opTrackerFactory, ioOpCallbackFactory,
- pageWriteCallbackFactory, metadataPageManagerFactory, ioSchedulerProvider, mergePolicyFactory,
- mergePolicyProperties, true, btreeCompFactories, valueProviderFactories, rTreePolicyType,
- linearizeCmpFactory, rtreeFields, new int[] { numNestedSecondaryKeyFields }, isPointMBR,
- mdProvider.getStorageProperties().getBloomFilterFalsePositiveRate(),
- typeTraitProvider.getTypeTrait(BuiltinType.ANULL), NullIntrospector.INSTANCE);
+ return null;
}
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryBTreeOperationsHelper.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryBTreeOperationsHelper.java
index 5a9753c..01d1c38 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryBTreeOperationsHelper.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryBTreeOperationsHelper.java
@@ -23,7 +23,6 @@
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.utils.StorageConstants;
import org.apache.asterix.external.indexing.IndexingConstants;
-import org.apache.asterix.external.operators.ExternalScanOperatorDescriptor;
import org.apache.asterix.metadata.declared.MetadataProvider;
import org.apache.asterix.metadata.entities.Dataset;
import org.apache.asterix.metadata.entities.Index;
@@ -48,9 +47,7 @@
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.api.job.JobSpecification;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
import org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor;
-import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
import org.apache.hyracks.storage.am.common.dataflow.IndexDataflowHelperFactory;
import org.apache.hyracks.storage.common.projection.ITupleProjectorFactory;
@@ -71,56 +68,6 @@
metadataProvider.getStorageComponentProvider().getStorageManager(), secondaryFileSplitProvider);
boolean excludeUnknown = excludeUnknownKeys(index, indexDetails, anySecondaryKeyIsNullable);
if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
- /*
- * In case of external data,
- * this method is used to build loading jobs for both initial load on index creation
- * and transaction load on dataset referesh
- */
-
- // Create external indexing scan operator
- ExternalScanOperatorDescriptor primaryScanOp = createExternalIndexingOp(spec);
-
- // Assign op.
- AlgebricksMetaOperatorDescriptor asterixAssignOp =
- createExternalAssignOp(spec, indexDetails.getKeyFieldNames().size(), secondaryRecDesc);
-
- // If any of the secondary fields are nullable, then add a select op that filters nulls.
- AlgebricksMetaOperatorDescriptor selectOp = null;
- if (excludeUnknown) {
- selectOp =
- createFilterAllUnknownsSelectOp(spec, indexDetails.getKeyFieldNames().size(), secondaryRecDesc);
- }
- // Sort by secondary keys.
- ExternalSortOperatorDescriptor sortOp = createSortOp(spec, secondaryComparatorFactories, secondaryRecDesc);
- // Create secondary BTree bulk load op.
- AbstractSingleActivityOperatorDescriptor secondaryBulkLoadOp;
- IOperatorDescriptor root;
- if (externalFiles != null) {
- // Transaction load
- secondaryBulkLoadOp = createExternalIndexBulkModifyOp(spec, fieldPermutation, dataflowHelperFactory,
- StorageConstants.DEFAULT_TREE_FILL_FACTOR);
- } else {
- // Initial load
- secondaryBulkLoadOp = createExternalIndexBulkLoadOp(spec, fieldPermutation, dataflowHelperFactory,
- StorageConstants.DEFAULT_TREE_FILL_FACTOR);
- }
- SinkRuntimeFactory sinkRuntimeFactory = new SinkRuntimeFactory();
- sinkRuntimeFactory.setSourceLocation(sourceLoc);
- AlgebricksMetaOperatorDescriptor metaOp = new AlgebricksMetaOperatorDescriptor(spec, 1, 0,
- new IPushRuntimeFactory[] { sinkRuntimeFactory }, new RecordDescriptor[] { secondaryRecDesc });
- metaOp.setSourceLocation(sourceLoc);
- spec.connect(new OneToOneConnectorDescriptor(spec), secondaryBulkLoadOp, 0, metaOp, 0);
- root = metaOp;
- spec.connect(new OneToOneConnectorDescriptor(spec), primaryScanOp, 0, asterixAssignOp, 0);
- if (excludeUnknown) {
- spec.connect(new OneToOneConnectorDescriptor(spec), asterixAssignOp, 0, selectOp, 0);
- spec.connect(new OneToOneConnectorDescriptor(spec), selectOp, 0, sortOp, 0);
- } else {
- spec.connect(new OneToOneConnectorDescriptor(spec), asterixAssignOp, 0, sortOp, 0);
- }
- spec.connect(new OneToOneConnectorDescriptor(spec), sortOp, 0, secondaryBulkLoadOp, 0);
- spec.addRoot(root);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
return spec;
} else {
// job spec:
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
index c8fd546..25b138d 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
@@ -26,15 +26,10 @@
import java.util.function.Supplier;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
-import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
import org.apache.asterix.common.config.OptimizationConfUtil;
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.external.indexing.ExternalFile;
-import org.apache.asterix.external.indexing.IndexingConstants;
-import org.apache.asterix.external.operators.ExternalIndexBulkLoadOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalIndexBulkModifyOperatorDescriptor;
-import org.apache.asterix.external.operators.ExternalScanOperatorDescriptor;
import org.apache.asterix.formats.base.IDataFormat;
import org.apache.asterix.formats.nontagged.BinaryBooleanInspector;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
@@ -44,7 +39,6 @@
import org.apache.asterix.metadata.entities.Dataset;
import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.metadata.entities.InternalDatasetDetails;
-import org.apache.asterix.metadata.lock.ExternalDatasetsRegistry;
import org.apache.asterix.om.base.IAObject;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.AbstractFunctionDescriptor;
@@ -84,7 +78,6 @@
import org.apache.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
import org.apache.hyracks.storage.am.common.dataflow.IndexDataflowHelperFactory;
import org.apache.hyracks.storage.am.common.dataflow.IndexDropOperatorDescriptor.DropOption;
-import org.apache.hyracks.storage.am.common.dataflow.TreeIndexBulkLoadOperatorDescriptor;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
@SuppressWarnings("rawtypes")
@@ -459,17 +452,6 @@
return treeIndexBulkLoadOp;
}
- protected TreeIndexBulkLoadOperatorDescriptor createExternalIndexBulkLoadOp(JobSpecification spec,
- int[] fieldPermutation, IIndexDataflowHelperFactory dataflowHelperFactory, float fillFactor) {
- ExternalIndexBulkLoadOperatorDescriptor treeIndexBulkLoadOp = new ExternalIndexBulkLoadOperatorDescriptor(spec,
- secondaryRecDesc, fieldPermutation, fillFactor, false, numElementsHint, false, dataflowHelperFactory,
- ExternalDatasetsRegistry.INSTANCE.getAndLockDatasetVersion(dataset, metadataProvider), null);
- treeIndexBulkLoadOp.setSourceLocation(sourceLoc);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, treeIndexBulkLoadOp,
- secondaryPartitionConstraint);
- return treeIndexBulkLoadOp;
- }
-
public AlgebricksMetaOperatorDescriptor createFilterAllUnknownsSelectOp(JobSpecification spec,
int numSecondaryKeyFields, RecordDescriptor secondaryRecDesc) throws AlgebricksException {
return createFilterSelectOp(spec, numSecondaryKeyFields, secondaryRecDesc, OrDescriptor::new);
@@ -516,39 +498,6 @@
return asterixSelectOp;
}
- // This method creates a source indexing operator for external data
- protected ExternalScanOperatorDescriptor createExternalIndexingOp(JobSpecification spec)
- throws AlgebricksException {
- // A record + primary keys
- ISerializerDeserializer[] serdes = new ISerializerDeserializer[1 + numPrimaryKeys];
- ITypeTraits[] typeTraits = new ITypeTraits[1 + numPrimaryKeys];
- // payload serde and type traits for the record slot
- serdes[0] = payloadSerde;
- typeTraits[0] = TypeTraitProvider.INSTANCE.getTypeTrait(itemType);
- // serdes and type traits for rid fields
- for (int i = 1; i < serdes.length; i++) {
- serdes[i] = IndexingConstants.getSerializerDeserializer(i - 1);
- typeTraits[i] = IndexingConstants.getTypeTraits(i - 1);
- }
- // output record desc
- RecordDescriptor indexerDesc = new RecordDescriptor(serdes, typeTraits);
-
- // Create the operator and its partition constraits
- Pair<ExternalScanOperatorDescriptor, AlgebricksPartitionConstraint> indexingOpAndConstraints;
- try {
- indexingOpAndConstraints = ExternalIndexingOperations.createExternalIndexingOp(spec, metadataProvider,
- dataset, itemType, indexerDesc, externalFiles, sourceLoc);
- } catch (Exception e) {
- throw new AlgebricksException(e);
- }
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, indexingOpAndConstraints.first,
- indexingOpAndConstraints.second);
-
- // Set the primary partition constraints to this partition constraints
- primaryPartitionConstraint = indexingOpAndConstraints.second;
- return indexingOpAndConstraints.first;
- }
-
protected AlgebricksMetaOperatorDescriptor createExternalAssignOp(JobSpecification spec, int numSecondaryKeys,
RecordDescriptor secondaryRecDesc) {
int[] outColumns = new int[numSecondaryKeys];
@@ -570,33 +519,6 @@
new RecordDescriptor[] { secondaryRecDesc });
}
- protected ExternalIndexBulkModifyOperatorDescriptor createExternalIndexBulkModifyOp(JobSpecification spec,
- int[] fieldPermutation, IIndexDataflowHelperFactory dataflowHelperFactory, float fillFactor) {
- // create a list of file ids
- int numOfDeletedFiles = 0;
- for (ExternalFile file : externalFiles) {
- if (file.getPendingOp() == ExternalFilePendingOp.DROP_OP) {
- numOfDeletedFiles++;
- }
- }
- int[] deletedFiles = new int[numOfDeletedFiles];
- int i = 0;
- for (ExternalFile file : externalFiles) {
- if (file.getPendingOp() == ExternalFilePendingOp.DROP_OP) {
- deletedFiles[i] = file.getFileNumber();
- }
- }
- ExternalIndexBulkModifyOperatorDescriptor treeIndexBulkLoadOp = new ExternalIndexBulkModifyOperatorDescriptor(
- spec, dataflowHelperFactory, deletedFiles, fieldPermutation, fillFactor, false, numElementsHint, null);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, treeIndexBulkLoadOp,
- secondaryPartitionConstraint);
- return treeIndexBulkLoadOp;
- }
-
- public List<ExternalFile> getExternalFiles() {
- return externalFiles;
- }
-
public void setExternalFiles(List<ExternalFile> externalFiles) {
this.externalFiles = externalFiles;
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryRTreeOperationsHelper.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryRTreeOperationsHelper.java
index e36e71f..792d495 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryRTreeOperationsHelper.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryRTreeOperationsHelper.java
@@ -24,7 +24,6 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.utils.StorageConstants;
import org.apache.asterix.external.indexing.IndexingConstants;
-import org.apache.asterix.external.operators.ExternalScanOperatorDescriptor;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
import org.apache.asterix.formats.nontagged.TypeTraitProvider;
@@ -50,8 +49,6 @@
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.api.job.JobSpecification;
-import org.apache.hyracks.dataflow.std.base.AbstractOperatorDescriptor;
-import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
import org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor;
import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
@@ -254,63 +251,6 @@
spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
} else {
// External dataset
- /*
- * In case of external data, this method is used to build loading jobs for both
- * initial load on index creation
- * and transaction load on dataset referesh
- */
- // Create external indexing scan operator
- ExternalScanOperatorDescriptor primaryScanOp = createExternalIndexingOp(spec);
- AbstractOperatorDescriptor sourceOp = primaryScanOp;
- if (isOverridingKeyFieldTypes && !enforcedItemType.equals(itemType)) {
- sourceOp = createCastOp(spec, dataset.getDatasetType(), index.isEnforced());
- spec.connect(new OneToOneConnectorDescriptor(spec), primaryScanOp, 0, sourceOp, 0);
- }
- // Assign op.
- AlgebricksMetaOperatorDescriptor asterixAssignOp = createExternalAssignOp(spec,
- numNestedSecondaryKeFieldsConsideringPointMBR, secondaryRecDescConsideringPointMBR);
-
- // If any of the secondary fields are nullable, then add a select op that filters nulls.
- AlgebricksMetaOperatorDescriptor selectOp = null;
- if (anySecondaryKeyIsNullable || isOverridingKeyFieldTypes) {
- selectOp = createFilterAnyUnknownSelectOp(spec, numNestedSecondaryKeFieldsConsideringPointMBR,
- secondaryRecDescConsideringPointMBR);
- }
-
- // Sort by secondary keys.
- ExternalSortOperatorDescriptor sortOp = createSortOp(spec,
- new IBinaryComparatorFactory[] {
- MetadataProvider.proposeLinearizer(keyType, secondaryComparatorFactories.length) },
- isPointMBR ? secondaryRecDescForPointMBR : secondaryRecDesc);
- // Create secondary RTree bulk load op.
- IOperatorDescriptor root;
- AbstractSingleActivityOperatorDescriptor secondaryBulkLoadOp;
- if (externalFiles != null) {
- // Transaction load
- secondaryBulkLoadOp = createExternalIndexBulkModifyOp(spec, fieldPermutation,
- indexDataflowHelperFactory, StorageConstants.DEFAULT_TREE_FILL_FACTOR);
- } else {
- // Initial load
- secondaryBulkLoadOp = createExternalIndexBulkLoadOp(spec, fieldPermutation, indexDataflowHelperFactory,
- StorageConstants.DEFAULT_TREE_FILL_FACTOR);
- }
- SinkRuntimeFactory sinkRuntimeFactory = new SinkRuntimeFactory();
- sinkRuntimeFactory.setSourceLocation(sourceLoc);
- AlgebricksMetaOperatorDescriptor metaOp = new AlgebricksMetaOperatorDescriptor(spec, 1, 0,
- new IPushRuntimeFactory[] { sinkRuntimeFactory }, new RecordDescriptor[] { secondaryRecDesc });
- metaOp.setSourceLocation(sourceLoc);
- spec.connect(new OneToOneConnectorDescriptor(spec), secondaryBulkLoadOp, 0, metaOp, 0);
- root = metaOp;
- spec.connect(new OneToOneConnectorDescriptor(spec), sourceOp, 0, asterixAssignOp, 0);
- if (anySecondaryKeyIsNullable || isOverridingKeyFieldTypes) {
- spec.connect(new OneToOneConnectorDescriptor(spec), asterixAssignOp, 0, selectOp, 0);
- spec.connect(new OneToOneConnectorDescriptor(spec), selectOp, 0, sortOp, 0);
- } else {
- spec.connect(new OneToOneConnectorDescriptor(spec), asterixAssignOp, 0, sortOp, 0);
- }
- spec.connect(new OneToOneConnectorDescriptor(spec), sortOp, 0, secondaryBulkLoadOp, 0);
- spec.addRoot(root);
- spec.setConnectorPolicyAssignmentPolicy(new ConnectorPolicyAssignmentPolicy());
}
return spec;
}
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.1.script.sqlpp b/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.1.script.sqlpp
deleted file mode 100644
index db1a058..0000000
--- a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.1.script.sqlpp
+++ /dev/null
@@ -1,19 +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.
-#
-create_and_start.sh
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.2.ddl.sqlpp b/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.2.ddl.sqlpp
deleted file mode 100644
index 3eddfc5..0000000
--- a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.2.ddl.sqlpp
+++ /dev/null
@@ -1,46 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-drop dataverse test if exists;
-create dataverse test;
-
-use test;
-
-create type EmployeeType as closed {
- id: int64,
- name: string,
- age: int64
-};
-
-create external dataset EmployeeDataset(EmployeeType)
-using hdfs
-(("hdfs"="hdfs://127.0.0.1:31888"),
-("path"="/asterix/external-indexing-test.txt"),
-("input-format"="text-input-format"),
-("format"="delimited-text"),
-("delimiter"="|"));
-
-create index EmployeeAgeIdx on EmployeeDataset(age);
-
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.3.script.sqlpp b/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.3.script.sqlpp
deleted file mode 100644
index d844d13..0000000
--- a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.3.script.sqlpp
+++ /dev/null
@@ -1,19 +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.
-#
-stop_and_start.sh
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.4.query.sqlpp b/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.4.query.sqlpp
deleted file mode 100644
index e53d2ce..0000000
--- a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.4.query.sqlpp
+++ /dev/null
@@ -1,31 +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.
- */
-/*
-* Description : Create an external dataset that contains records stored with text hdfs file format.
- Build an index over the external dataset age attribute
- Perform a query over the dataset using the index.
-* Expected Res : Success
-* Date : 3rd Jan 2014
-*/
-use test;
-
-SELECT VALUE e
-FROM EmployeeDataset e
-WHERE e.age = 22
-ORDER BY e.id;
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.5.script.sqlpp b/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.5.script.sqlpp
deleted file mode 100644
index f43dec7..0000000
--- a/asterixdb/asterix-server/src/test/resources/transactionts/queries/query_after_restart/external_index/external_index.5.script.sqlpp
+++ /dev/null
@@ -1,19 +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.
-#
-stop_and_delete.sh
diff --git a/asterixdb/asterix-server/src/test/resources/transactionts/testsuite.xml b/asterixdb/asterix-server/src/test/resources/transactionts/testsuite.xml
index 0aab20d..7f3cfae 100644
--- a/asterixdb/asterix-server/src/test/resources/transactionts/testsuite.xml
+++ b/asterixdb/asterix-server/src/test/resources/transactionts/testsuite.xml
@@ -24,11 +24,6 @@
</compilation-unit>
</test-case>
<test-case FilePath="query_after_restart">
- <compilation-unit name="external_index">
- <output-dir compare="Text">external_index</output-dir>
- </compilation-unit>
- </test-case>
- <test-case FilePath="query_after_restart">
<compilation-unit name="big_object_20M">
<output-dir compare="Text">big_object_20M</output-dir>
</compilation-unit>
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResource.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResource.java
deleted file mode 100644
index ee4c4f7..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResource.java
+++ /dev/null
@@ -1,104 +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.lsm.btree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.application.INCServiceContext;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.io.IJsonSerializable;
-import org.apache.hyracks.api.io.IPersistedResourceRegistry;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.lsm.btree.utils.LSMBTreeUtil;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.common.IStorageManager;
-import org.apache.hyracks.storage.common.compression.NoOpCompressorDecompressorFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class ExternalBTreeLocalResource extends LSMBTreeLocalResource {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalBTreeLocalResource(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
- int[] bloomFilterKeyFields, double bloomFilterFalsePositiveRate, boolean isPrimary, String path,
- IStorageManager storageManager, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] btreeFields, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerProvider, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, boolean durable, boolean hasBloomFilter,
- ITypeTraits nullTypeTraits, INullIntrospector nullIntrospector,
- boolean isSecondaryNoIncrementalMaintenance) {
- super(typeTraits, cmpFactories, bloomFilterKeyFields, bloomFilterFalsePositiveRate, isPrimary, path,
- storageManager, mergePolicyFactory, mergePolicyProperties, filterTypeTraits, filterCmpFactories,
- btreeFields, filterFields, opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory,
- metadataPageManagerFactory, null, ioSchedulerProvider, durable,
- NoOpCompressorDecompressorFactory.INSTANCE, hasBloomFilter, nullTypeTraits, nullIntrospector,
- isSecondaryNoIncrementalMaintenance);
- }
-
- private ExternalBTreeLocalResource(IPersistedResourceRegistry registry, JsonNode json, int[] bloomFilterKeyFields,
- double bloomFilterFalsePositiveRate, boolean isPrimary, int[] btreeFields, boolean hasBloomFilter,
- boolean isSecondaryNoIncrementalMaintenance) throws HyracksDataException {
- super(registry, json, bloomFilterKeyFields, bloomFilterFalsePositiveRate, isPrimary, btreeFields,
- NoOpCompressorDecompressorFactory.INSTANCE, hasBloomFilter, isSecondaryNoIncrementalMaintenance);
- }
-
- @Override
- public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
- IIOManager ioManager = serviceCtx.getIoManager();
- FileReference file = ioManager.resolve(path);
- ioOpCallbackFactory.initialize(serviceCtx, this);
- pageWriteCallbackFactory.initialize(serviceCtx, this);
- return LSMBTreeUtil.createExternalBTree(ioManager, file, storageManager.getBufferCache(serviceCtx), typeTraits,
- cmpFactories, bloomFilterKeyFields, bloomFilterFalsePositiveRate,
- mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx),
- opTrackerProvider.getOperationTracker(serviceCtx, this), ioSchedulerProvider.getIoScheduler(serviceCtx),
- ioOpCallbackFactory, pageWriteCallbackFactory, durable, metadataPageManagerFactory,
- serviceCtx.getTracer(), nullTypeTraits, nullIntrospector);
- }
-
- @Override
- public JsonNode toJson(IPersistedResourceRegistry registry) throws HyracksDataException {
- ObjectNode jsonObject = registry.getClassIdentifier(getClass(), serialVersionUID);
- super.appendToJson(jsonObject, registry);
- return jsonObject;
- }
-
- public static IJsonSerializable fromJson(IPersistedResourceRegistry registry, JsonNode json)
- throws HyracksDataException {
- LSMBTreeLocalResource lsmBtree = (LSMBTreeLocalResource) LSMBTreeLocalResource.fromJson(registry, json);
- return new ExternalBTreeLocalResource(registry, json, lsmBtree.bloomFilterKeyFields,
- lsmBtree.bloomFilterFalsePositiveRate, lsmBtree.isPrimary, lsmBtree.btreeFields,
- lsmBtree.hasBloomFilter, lsmBtree.isSecondaryNoIncrementalMaintenance);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResourceFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResourceFactory.java
deleted file mode 100644
index 3a28057..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeLocalResourceFactory.java
+++ /dev/null
@@ -1,67 +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.lsm.btree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.dataflow.LsmResource;
-import org.apache.hyracks.storage.common.IStorageManager;
-import org.apache.hyracks.storage.common.compression.NoOpCompressorDecompressorFactory;
-
-public class ExternalBTreeLocalResourceFactory extends LSMBTreeLocalResourceFactory {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalBTreeLocalResourceFactory(IStorageManager storageManager, ITypeTraits[] typeTraits,
- IBinaryComparatorFactory[] cmpFactories, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerFactory, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, boolean durable, int[] bloomFilterKeyFields,
- double bloomFilterFalsePositiveRate, int[] btreeFields, boolean hasBloomFilter, ITypeTraits nullTypeTraits,
- INullIntrospector nullIntrospector) {
- super(storageManager, typeTraits, cmpFactories, filterTypeTraits, filterCmpFactories, filterFields,
- opTrackerFactory, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory, null,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, durable, bloomFilterKeyFields,
- bloomFilterFalsePositiveRate, false, btreeFields, NoOpCompressorDecompressorFactory.INSTANCE,
- hasBloomFilter, nullTypeTraits, nullIntrospector, true);
- }
-
- @Override
- public LsmResource createResource(FileReference fileRef) {
- return new ExternalBTreeLocalResource(typeTraits, cmpFactories, bloomFilterKeyFields,
- bloomFilterFalsePositiveRate, isPrimary, fileRef.getRelativePath(), storageManager, mergePolicyFactory,
- mergePolicyProperties, filterTypeTraits, filterCmpFactories, btreeFields, bloomFilterKeyFields,
- opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory,
- ioSchedulerProvider, durable, hasBloomFilter, nullTypeTraits, nullIntrospector,
- isSecondaryNoIncrementalMaintenance);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResource.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResource.java
deleted file mode 100644
index f2c5263..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResource.java
+++ /dev/null
@@ -1,107 +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.lsm.btree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.application.INCServiceContext;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.io.IJsonSerializable;
-import org.apache.hyracks.api.io.IPersistedResourceRegistry;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.lsm.btree.utils.LSMBTreeUtil;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.common.IStorageManager;
-import org.apache.hyracks.storage.common.compression.NoOpCompressorDecompressorFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * The local resource for disk only lsm btree with buddy tree
- */
-public class ExternalBTreeWithBuddyLocalResource extends LSMBTreeLocalResource {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalBTreeWithBuddyLocalResource(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
- int[] buddyBtreeFields, double bloomFilterFalsePositiveRate, boolean isPrimary, String path,
- IStorageManager storageManager, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] btreeFields, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerProvider, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, boolean durable, boolean hasBloomFilter,
- ITypeTraits nullTypeTraits, INullIntrospector nullIntrospector,
- boolean isSecondaryNoIncrementalMaintenance) {
- super(typeTraits, cmpFactories, buddyBtreeFields, bloomFilterFalsePositiveRate, isPrimary, path, storageManager,
- mergePolicyFactory, mergePolicyProperties, filterTypeTraits, filterCmpFactories, btreeFields,
- filterFields, opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory,
- metadataPageManagerFactory, null, ioSchedulerProvider, durable,
- NoOpCompressorDecompressorFactory.INSTANCE, hasBloomFilter, nullTypeTraits, nullIntrospector,
- isSecondaryNoIncrementalMaintenance);
- }
-
- private ExternalBTreeWithBuddyLocalResource(IPersistedResourceRegistry registry, JsonNode json,
- int[] bloomFilterKeyFields, double bloomFilterFalsePositiveRate, boolean isPrimary, int[] btreeFields,
- boolean hasBloomFilter, boolean isSecondaryNoIncrementalMaintenance) throws HyracksDataException {
- super(registry, json, bloomFilterKeyFields, bloomFilterFalsePositiveRate, isPrimary, btreeFields,
- NoOpCompressorDecompressorFactory.INSTANCE, hasBloomFilter, isSecondaryNoIncrementalMaintenance);
- }
-
- @Override
- public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
- IIOManager ioManager = serviceCtx.getIoManager();
- FileReference file = ioManager.resolve(path);
- ioOpCallbackFactory.initialize(serviceCtx, this);
- pageWriteCallbackFactory.initialize(serviceCtx, this);
- return LSMBTreeUtil.createExternalBTreeWithBuddy(ioManager, file, storageManager.getBufferCache(serviceCtx),
- typeTraits, cmpFactories, bloomFilterFalsePositiveRate,
- mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx),
- opTrackerProvider.getOperationTracker(serviceCtx, this), ioSchedulerProvider.getIoScheduler(serviceCtx),
- ioOpCallbackFactory, pageWriteCallbackFactory, bloomFilterKeyFields, durable,
- metadataPageManagerFactory, serviceCtx.getTracer(), nullTypeTraits, nullIntrospector);
- }
-
- @Override
- public JsonNode toJson(IPersistedResourceRegistry registry) throws HyracksDataException {
- ObjectNode jsonObject = registry.getClassIdentifier(getClass(), serialVersionUID);
- super.appendToJson(jsonObject, registry);
- return jsonObject;
- }
-
- public static IJsonSerializable fromJson(IPersistedResourceRegistry registry, JsonNode json)
- throws HyracksDataException {
- LSMBTreeLocalResource lsmBtree = (LSMBTreeLocalResource) LSMBTreeLocalResource.fromJson(registry, json);
- return new ExternalBTreeWithBuddyLocalResource(registry, json, lsmBtree.bloomFilterKeyFields,
- lsmBtree.bloomFilterFalsePositiveRate, lsmBtree.isPrimary, lsmBtree.btreeFields,
- lsmBtree.hasBloomFilter, lsmBtree.isSecondaryNoIncrementalMaintenance);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResourceFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResourceFactory.java
deleted file mode 100644
index 995a23b..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/dataflow/ExternalBTreeWithBuddyLocalResourceFactory.java
+++ /dev/null
@@ -1,67 +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.lsm.btree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.dataflow.LsmResource;
-import org.apache.hyracks.storage.common.IStorageManager;
-import org.apache.hyracks.storage.common.compression.NoOpCompressorDecompressorFactory;
-
-public class ExternalBTreeWithBuddyLocalResourceFactory extends LSMBTreeLocalResourceFactory {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalBTreeWithBuddyLocalResourceFactory(IStorageManager storageManager, ITypeTraits[] typeTraits,
- IBinaryComparatorFactory[] cmpFactories, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerProvider, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, boolean durable, int[] buddyBtreeFields,
- double bloomFilterFalsePositiveRate, int[] btreeFields, boolean hasBloomFilter, ITypeTraits nullTypeTraits,
- INullIntrospector nullIntrospector) {
- super(storageManager, typeTraits, cmpFactories, filterTypeTraits, filterCmpFactories, filterFields,
- opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory, null,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, durable, buddyBtreeFields,
- bloomFilterFalsePositiveRate, false, btreeFields, NoOpCompressorDecompressorFactory.INSTANCE,
- hasBloomFilter, nullTypeTraits, nullIntrospector, true);
- }
-
- @Override
- public LsmResource createResource(FileReference fileRef) {
- return new ExternalBTreeWithBuddyLocalResource(typeTraits, cmpFactories, bloomFilterKeyFields,
- bloomFilterFalsePositiveRate, isPrimary, fileRef.getRelativePath(), storageManager, mergePolicyFactory,
- mergePolicyProperties, filterTypeTraits, filterCmpFactories, btreeFields, filterFields,
- opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory,
- ioSchedulerProvider, durable, hasBloomFilter, nullTypeTraits, nullIntrospector,
- isSecondaryNoIncrementalMaintenance);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java
deleted file mode 100644
index e727dc1..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java
+++ /dev/null
@@ -1,604 +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.lsm.btree.impls;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-import org.apache.hyracks.storage.am.btree.impls.BTree;
-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.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader;
-import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback;
-import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor.ICursorFactory;
-import org.apache.hyracks.storage.am.lsm.common.impls.LoadOperation;
-import org.apache.hyracks.storage.common.IIndexAccessParameters;
-import org.apache.hyracks.storage.common.IIndexBulkLoader;
-import org.apache.hyracks.storage.common.IIndexCursor;
-import org.apache.hyracks.storage.common.IIndexCursorStats;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.ISearchPredicate;
-import org.apache.hyracks.storage.common.IndexCursorStats;
-import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.hyracks.storage.common.buffercache.ICachedPage;
-import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
-import org.apache.hyracks.util.trace.ITracer;
-
-/**
- * This is an lsm b-tree that does not have memory component and is modified
- * only by bulk loading and addition of disk components as of this point, it is
- * intended for use with external dataset indexes only.
- *
- * @author alamouda
- */
-public class ExternalBTree extends LSMBTree implements ITwoPCIndex {
-
- private static final ICursorFactory cursorFactory = opCtx -> new LSMBTreeSearchCursor(opCtx);
- // This component factory has to be different since it uses different tuple
- // writer in it's leaf frames to support inserting both
- // regular and delete tuples
- private final ILSMDiskComponentFactory transactionComponentFactory;
- // A second disk component list that will be used when a transaction is
- // committed and will be seen by subsequent accessors
- private final List<ILSMDiskComponent> secondDiskComponents;
- // A pointer that points to the current most recent list (either
- // diskComponents = 0, or secondDiskComponents = 1). It starts with -1 to
- // indicate first time activation
- private int version = 0;
-
- private final ITreeIndexFrameFactory interiorFrameFactory;
-
- //TODO remove BloomFilter from external dataset's secondary LSMBTree index
- public ExternalBTree(IIOManager ioManager, ITreeIndexFrameFactory interiorFrameFactory,
- ITreeIndexFrameFactory insertLeafFrameFactory, ITreeIndexFrameFactory deleteLeafFrameFactory,
- IBufferCache bufferCache, ILSMIndexFileManager fileManager, ILSMDiskComponentFactory componentFactory,
- ILSMDiskComponentFactory bulkLoadComponentFactory, ILSMDiskComponentFactory transactionComponentFactory,
- double bloomFilterFalsePositiveRate, IBinaryComparatorFactory[] cmpFactories, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- boolean durable, ITracer tracer) throws HyracksDataException {
- super(ioManager, insertLeafFrameFactory, deleteLeafFrameFactory, bufferCache, fileManager, componentFactory,
- bulkLoadComponentFactory, bloomFilterFalsePositiveRate, cmpFactories, mergePolicy, opTracker,
- ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, false, durable, tracer);
- this.transactionComponentFactory = transactionComponentFactory;
- this.secondDiskComponents = new LinkedList<>();
- this.interiorFrameFactory = interiorFrameFactory;
- }
-
- @Override
- public ExternalIndexHarness getHarness() {
- return (ExternalIndexHarness) super.getHarness();
- }
-
- // The subsume merged components is overridden to account for:
- // Maintaining two versions of the index
- @Override
- public void subsumeMergedComponents(ILSMDiskComponent newComponent, List<ILSMComponent> mergedComponents)
- throws HyracksDataException {
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- }
-
- // Check if merge will affect the older list
- if (olderList.containsAll(mergedComponents)) {
- int swapIndex = olderList.indexOf(mergedComponents.get(0));
- olderList.removeAll(mergedComponents);
- olderList.add(swapIndex, newComponent);
- }
-
- // The new list will always have all the merged components
- int swapIndex = newerList.indexOf(mergedComponents.get(0));
- newerList.removeAll(mergedComponents);
- newerList.add(swapIndex, newComponent);
- }
-
- // This method is used by the merge policy when it needs to check if a merge
- // is needed.
- // It only needs to return the newer list
- @Override
- public List<ILSMDiskComponent> getDiskComponents() {
- if (version == 0) {
- return diskComponents;
- } else if (version == 1) {
- return secondDiskComponents;
- } else {
- return Collections.emptyList();
- }
- }
-
- // The only reason to override the following method is that it uses a different context object
- @Override
- public void search(ILSMIndexOperationContext ictx, IIndexCursor cursor, ISearchPredicate pred)
- throws HyracksDataException {
- ExternalBTreeOpContext ctx = (ExternalBTreeOpContext) ictx;
- List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
- ctx.getSearchInitialState().reset(pred, operationalComponents);
- cursor.open(ctx.getSearchInitialState(), pred);
- }
-
- // This method creates the appropriate opContext for the targeted version
- public ExternalBTreeOpContext createOpContext(ISearchOperationCallback searchCallback, int targetVersion) {
- return new ExternalBTreeOpContext(this, insertLeafFrameFactory, deleteLeafFrameFactory, searchCallback,
- ((LSMBTreeWithBloomFilterDiskComponentFactory) componentFactory).getBloomFilterKeyFields().length,
- cmpFactories, targetVersion, getHarness(), tracer);
- }
-
- // The only reason to override the following method is that it uses a different context object
- // in addition, determining whether or not to keep deleted tuples is different here
- @Override
- public LSMBTreeMergeOperation createMergeOperation(ILSMIndexOperationContext ctx) throws HyracksDataException {
- ExternalBTreeOpContext opCtx = createOpContext(NoOpOperationCallback.INSTANCE, -1);
- opCtx.setOperation(IndexOperation.MERGE);
- List<ILSMComponent> mergingComponents = ctx.getComponentHolder();
- boolean returnDeletedTuples = false;
- if (version == 0) {
- if (ctx.getComponentHolder().get(ctx.getComponentHolder().size() - 1) != diskComponents
- .get(diskComponents.size() - 1)) {
- returnDeletedTuples = true;
- }
- } else {
- if (ctx.getComponentHolder().get(ctx.getComponentHolder().size() - 1) != secondDiskComponents
- .get(secondDiskComponents.size() - 1)) {
- returnDeletedTuples = true;
- }
- }
- IIndexCursorStats stats = new IndexCursorStats();
- LSMBTreeRangeSearchCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples, stats);
- BTree lastBTree = ((LSMBTreeDiskComponent) mergingComponents.get(0)).getIndex();
- BTree firstBTree = ((LSMBTreeDiskComponent) mergingComponents.get(mergingComponents.size() - 1)).getIndex();
- FileReference firstFile = firstBTree.getFileReference();
- FileReference lastFile = lastBTree.getFileReference();
- LSMComponentFileReferences relMergeFileRefs =
- fileManager.getRelMergeFileReference(firstFile.getFile().getName(), lastFile.getFile().getName());
- ILSMIndexAccessor accessor = new LSMTreeIndexAccessor(getHarness(), opCtx, cursorFactory);
- LSMBTreeMergeOperation mergeOp = new LSMBTreeMergeOperation(accessor, cursor, stats,
- relMergeFileRefs.getInsertIndexFileReference(), relMergeFileRefs.getBloomFilterFileReference(),
- ioOpCallback, fileManager.getBaseDir().getAbsolutePath());
- ioOpCallback.scheduled(mergeOp);
- return mergeOp;
- }
-
- // This function should only be used when a transaction fail. it doesn't
- // take any parameters since there can only be
- // a single transaction and hence a single transaction component on disk
- public void deleteTransactionComponent() throws HyracksDataException {
- fileManager.deleteTransactionFiles();
- }
-
- // This function in an instance of this index is only used after a bulk load
- // is successful
- @Override
- public void addDiskComponent(ILSMDiskComponent c) throws HyracksDataException {
- if (version == 0) {
- diskComponents.add(0, c);
- } else if (version == 1) {
- secondDiskComponents.add(0, c);
- }
- }
-
- // This function is used when a new component is to be committed.
- @Override
- public void commitTransactionDiskComponent(ILSMDiskComponent newComponent) throws HyracksDataException {
- // determine which list is the new one and flip the pointer
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- version = 1;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- version = 0;
- }
- // Remove components from list
- olderList.clear();
- // Add components
- olderList.addAll(newerList);
- if (newComponent != null) {
- // Add it to the list
- olderList.add(0, newComponent);
- }
- }
-
- @Override
- public synchronized void activate() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to activate the index since it is already activated.");
- }
- if (diskComponents.size() == 0 && secondDiskComponents.size() == 0) {
- //First time activation
- List<LSMComponentFileReferences> validFileReferences;
- validFileReferences = fileManager.cleanupAndGetValidFiles();
- for (LSMComponentFileReferences lsmComponentFileReferences : validFileReferences) {
- ILSMDiskComponent component =
- createDiskComponent(componentFactory, lsmComponentFileReferences.getInsertIndexFileReference(),
- null, lsmComponentFileReferences.getBloomFilterFileReference(), false);
- diskComponents.add(component);
- secondDiskComponents.add(component);
- }
- getHarness().indexFirstTimeActivated();
- } else {
- // This index has been opened before
- for (ILSMDiskComponent c : diskComponents) {
- c.activate(false);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- // Only activate non shared components
- if (!diskComponents.contains(c)) {
- c.activate(false);
- }
- }
- }
- isActive = true;
- }
-
- @Override
- public synchronized void create() throws HyracksDataException {
- super.create();
- secondDiskComponents.clear();
- }
-
- @Override
- public void deactivate(boolean flushOnExit) throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to deactivate the index since it is already deactivated.");
- }
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndPurge();
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- // Only deactivate non shared components
- if (!diskComponents.contains(c)) {
- c.deactivateAndPurge();
- }
- }
- isActive = false;
- }
-
- // The clear method is not used anywhere in AsterixDB! we override it anyway
- // to exit components first and deal with the two lists
- @Override
- public void clear() throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to clear the index since it is not activated.");
- }
- getHarness().indexClear();
-
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndDestroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
-
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.deactivateAndDestroy();
- }
- diskComponents.clear();
- secondDiskComponents.clear();
- version = 0;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to destroy the index since it is activated.");
- }
- for (ILSMDiskComponent c : diskComponents) {
- c.destroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.destroy();
- }
- diskComponents.clear();
- secondDiskComponents.clear();
- fileManager.deleteDirs();
- version = 0;
- }
-
- // Not supported
- @Override
- public void modify(IIndexOperationContext ictx, ITupleReference tuple) throws HyracksDataException {
- throw new UnsupportedOperationException("tuple modify not supported in LSM-Disk-Only-BTree");
- }
-
- // Not supported
- @Override
- public ILSMIOOperation createFlushOperation(ILSMIndexOperationContext ctx) throws HyracksDataException {
- throw new UnsupportedOperationException("flush not supported in LSM-Disk-Only-BTree");
- }
-
- // Not supported
- @Override
- public ILSMDiskComponent doFlush(ILSMIOOperation operation) throws HyracksDataException {
- throw new UnsupportedOperationException("flush not supported in LSM-Disk-Only-BTree");
- }
-
- // Only support search and merge operations
- @Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
- List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
- List<ILSMDiskComponent> immutableComponents;
- // Identify current list in case of a merge
- if (version == 0) {
- immutableComponents = diskComponents;
- } else {
- immutableComponents = secondDiskComponents;
- }
- ExternalBTreeOpContext opCtx = (ExternalBTreeOpContext) ctx;
- operationalComponents.clear();
- switch (ctx.getOperation()) {
- case SEARCH:
- if (opCtx.getTargetIndexVersion() == 0) {
- operationalComponents.addAll(diskComponents);
- } else {
- operationalComponents.addAll(secondDiskComponents);
- }
- break;
- case MERGE:
- operationalComponents.addAll(ctx.getComponentsToBeMerged());
- break;
- case FULL_MERGE:
- operationalComponents.addAll(immutableComponents);
- break;
- case REPLICATE:
- operationalComponents.addAll(ctx.getComponentsToBeReplicated());
- break;
- default:
- throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported.");
- }
- }
-
- // For initial load
- @Override
- public IIndexBulkLoader createBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCBTreeBulkLoader(fillLevel, verifyInput, numElementsHint, false, parameters);
- }
-
- // For transaction bulk load <- could consolidate with the above method ->
- @Override
- public IIndexBulkLoader createTransactionBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCBTreeBulkLoader(fillLevel, verifyInput, numElementsHint, true, parameters);
- }
-
- // The bulk loader used for both initial loading and transaction
- // modifications
- public class LSMTwoPCBTreeBulkLoader implements IIndexBulkLoader, ITwoPCIndexBulkLoader {
- private final ILSMDiskComponent component;
- private final ILSMDiskComponentBulkLoader componentBulkLoader;
- private final LoadOperation loadOp;
-
- private final boolean isTransaction;
-
- public LSMTwoPCBTreeBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
- boolean isTransaction, Map<String, Object> parameters) throws HyracksDataException {
- this.isTransaction = isTransaction;
- // Create the appropriate target
- LSMComponentFileReferences componentFileRefs;
- if (isTransaction) {
- try {
- componentFileRefs = fileManager.getNewTransactionFileReference();
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- component = createDiskComponent(transactionComponentFactory,
- componentFileRefs.getInsertIndexFileReference(), null,
- componentFileRefs.getBloomFilterFileReference(), true);
- } else {
- componentFileRefs = fileManager.getRelFlushFileReference();
- component =
- createDiskComponent(bulkLoadComponentFactory, componentFileRefs.getInsertIndexFileReference(),
- componentFileRefs.getDeleteIndexFileReference(),
- componentFileRefs.getBloomFilterFileReference(), true);
- }
- loadOp = new LoadOperation(componentFileRefs, ioOpCallback, getIndexIdentifier(), parameters);
- loadOp.setNewComponent(component);
- ioOpCallback.scheduled(loadOp);
- ioOpCallback.beforeOperation(loadOp);
- IPageWriteCallback pageWriteCallback = pageWriteCallbackFactory.createPageWriteCallback();
- componentBulkLoader = component.createBulkLoader(loadOp, fillFactor, verifyInput, numElementsHint, false,
- true, true, pageWriteCallback);
- }
-
- // It is expected that the mode was set to insert operation before
- // calling add
- @Override
- public void add(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.add(tuple);
- }
-
- @Override
- public void end() throws HyracksDataException {
- try {
- ioOpCallback.afterOperation(loadOp);
- componentBulkLoader.end();
- if (component.getComponentSize() > 0) {
- if (isTransaction) {
- // Since this is a transaction component, validate and
- // deactivate. it could later be added or deleted
- try {
- component.markAsValid(durable, loadOp);
- } finally {
- ioOpCallback.afterFinalize(loadOp);
- }
- component.deactivate();
- } else {
- ioOpCallback.afterFinalize(loadOp);
- getHarness().addBulkLoadedComponent(loadOp);
- }
- }
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- // It is expected that the mode was set to delete operation before
- // calling delete
- @Override
- public void delete(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.delete(tuple);
- }
-
- @Override
- public void abort() throws HyracksDataException {
- try {
- componentBulkLoader.abort();
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- @Override
- public void writeFailed(ICachedPage page, Throwable failure) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean hasFailed() {
- return componentBulkLoader.hasFailed();
- }
-
- @Override
- public Throwable getFailure() {
- return componentBulkLoader.getFailure();
- }
-
- @Override
- public void force() throws HyracksDataException {
- componentBulkLoader.force();
- }
- }
-
- // The accessor for disk only indexes don't use modification callback and always carry the target index version with them
- @Override
- public ILSMIndexAccessor createAccessor(IIndexAccessParameters iap) {
- ExternalBTreeOpContext opCtx = createOpContext(iap.getSearchOperationCallback(), version);
- return new LSMTreeIndexAccessor(getHarness(), opCtx, cursorFactory);
- }
-
- @Override
- public ILSMIndexAccessor createAccessor(ISearchOperationCallback searchCallback, int targetIndexVersion)
- throws HyracksDataException {
- ExternalBTreeOpContext opCtx = createOpContext(searchCallback, targetIndexVersion);
- return new LSMTreeIndexAccessor(getHarness(), opCtx, cursorFactory);
- }
-
- @Override
- public ITreeIndexFrameFactory getInteriorFrameFactory() {
- return interiorFrameFactory;
- }
-
- @Override
- public int getFieldCount() {
- return cmpFactories.length;
- }
-
- @Override
- public int getFileId() {
- return -1;
- }
-
- @Override
- public IMetadataPageManager getPageManager() {
- return null;
- }
-
- @Override
- public ITreeIndexFrameFactory getLeafFrameFactory() {
- return insertLeafFrameFactory;
- }
-
- @Override
- public int getCurrentVersion() {
- return version;
- }
-
- @Override
- public void setCurrentVersion(int version) {
- this.version = version;
- }
-
- @Override
- public List<ILSMDiskComponent> getFirstComponentList() {
- return diskComponents;
- }
-
- @Override
- public List<ILSMDiskComponent> getSecondComponentList() {
- return secondDiskComponents;
- }
-
- @Override
- public void commitTransaction() throws HyracksDataException {
- LSMComponentFileReferences componentFileReferences = fileManager.getTransactionFileReferenceForCommit();
- ILSMDiskComponent component = null;
- if (componentFileReferences != null) {
- component = createDiskComponent(componentFactory, componentFileReferences.getInsertIndexFileReference(),
- null, componentFileReferences.getBloomFilterFileReference(), false);
- }
- getHarness().addTransactionComponents(component);
- }
-
- @Override
- public void abortTransaction() throws HyracksDataException {
- fileManager.deleteTransactionFiles();
- }
-
- @Override
- public void recoverTransaction() throws HyracksDataException {
- fileManager.recoverTransaction();
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeOpContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeOpContext.java
deleted file mode 100644
index 0b49b03..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeOpContext.java
+++ /dev/null
@@ -1,82 +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.lsm.btree.impls;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndexOperationContext;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.MultiComparator;
-import org.apache.hyracks.util.trace.ITracer;
-
-public class ExternalBTreeOpContext extends AbstractLSMIndexOperationContext {
- private IBTreeLeafFrame insertLeafFrame;
- private IBTreeLeafFrame deleteLeafFrame;
- private final MultiComparator cmp;
- private final MultiComparator bloomFilterCmp;
- private final int targetIndexVersion;
- private LSMBTreeCursorInitialState searchInitialState;
-
- public ExternalBTreeOpContext(ILSMIndex index, ITreeIndexFrameFactory insertLeafFrameFactory,
- ITreeIndexFrameFactory deleteLeafFrameFactory, ISearchOperationCallback searchCallback,
- int numBloomFilterKeyFields, IBinaryComparatorFactory[] cmpFactories, int targetIndexVersion,
- ILSMHarness lsmHarness, ITracer tracer) {
- super(index, null, null, null, searchCallback, null, tracer);
- if (cmpFactories != null) {
- this.cmp = MultiComparator.create(cmpFactories);
- } else {
- this.cmp = null;
- }
- bloomFilterCmp = MultiComparator.create(cmpFactories, 0, numBloomFilterKeyFields);
- this.insertLeafFrame = (IBTreeLeafFrame) insertLeafFrameFactory.createFrame();
- this.deleteLeafFrame = (IBTreeLeafFrame) deleteLeafFrameFactory.createFrame();
- if (insertLeafFrame != null && this.cmp != null) {
- insertLeafFrame.setMultiComparator(cmp);
- }
- if (deleteLeafFrame != null && this.cmp != null) {
- deleteLeafFrame.setMultiComparator(cmp);
- }
- this.targetIndexVersion = targetIndexVersion;
- searchInitialState = new LSMBTreeCursorInitialState(insertLeafFrameFactory, cmp, bloomFilterCmp, lsmHarness,
- null, searchCallback, null);
- }
-
- @Override
- public void setCurrentMutableComponentId(int currentMutableComponentId) {
- // Do nothing: this method should never be called for this class
- }
-
- // Used by indexes with global transaction
- public int getTargetIndexVersion() {
- return targetIndexVersion;
- }
-
- public LSMBTreeCursorInitialState getSearchInitialState() {
- return searchInitialState;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- // No Op
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java
deleted file mode 100644
index 9855571..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java
+++ /dev/null
@@ -1,698 +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.lsm.btree.impls;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.exceptions.ErrorCode;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-import org.apache.hyracks.storage.am.btree.impls.BTree;
-import org.apache.hyracks.storage.am.btree.impls.RangePredicate;
-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.ITreeIndex;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader;
-import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback;
-import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.AbstractLSMWithBloomFilterDiskComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallback;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndexOperationContext;
-import org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor;
-import org.apache.hyracks.storage.am.lsm.common.impls.LoadOperation;
-import org.apache.hyracks.storage.common.IIndexAccessParameters;
-import org.apache.hyracks.storage.common.IIndexBulkLoader;
-import org.apache.hyracks.storage.common.IIndexCursor;
-import org.apache.hyracks.storage.common.IIndexCursorStats;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.ISearchPredicate;
-import org.apache.hyracks.storage.common.IndexCursorStats;
-import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.hyracks.storage.common.buffercache.ICachedPage;
-import org.apache.hyracks.util.trace.ITracer;
-
-public class ExternalBTreeWithBuddy extends AbstractLSMIndex implements ITreeIndex, ITwoPCIndex {
-
- private final IBinaryComparatorFactory[] btreeCmpFactories;
- private final IBinaryComparatorFactory[] buddyBtreeCmpFactories;
- private final int[] buddyBTreeFields;
-
- // Common for in-memory and on-disk components.
- private final ITreeIndexFrameFactory btreeInteriorFrameFactory;
- private final ITreeIndexFrameFactory btreeLeafFrameFactory;
- private final ITreeIndexFrameFactory buddyBtreeLeafFrameFactory;
-
- // A second disk component list that will be used when a transaction is
- // committed and will be seen by subsequent accessors
- private final List<ILSMDiskComponent> secondDiskComponents;
- private int version = 0;
-
- public ExternalBTreeWithBuddy(IIOManager ioManager, ITreeIndexFrameFactory btreeInteriorFrameFactory,
- ITreeIndexFrameFactory btreeLeafFrameFactory, ITreeIndexFrameFactory buddyBtreeLeafFrameFactory,
- IBufferCache diskBufferCache, ILSMIndexFileManager fileManager, ILSMDiskComponentFactory componentFactory,
- ILSMDiskComponentFactory bulkLoadComponentFactory, double bloomFilterFalsePositiveRate,
- ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IBinaryComparatorFactory[] btreeCmpFactories, IBinaryComparatorFactory[] buddyBtreeCmpFactories,
- int[] buddyBTreeFields, boolean durable, ITracer tracer) throws HyracksDataException {
- super(ioManager, diskBufferCache, fileManager, bloomFilterFalsePositiveRate, mergePolicy, opTracker,
- ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, componentFactory, bulkLoadComponentFactory,
- durable, tracer);
- this.btreeCmpFactories = btreeCmpFactories;
- this.buddyBtreeCmpFactories = buddyBtreeCmpFactories;
- this.buddyBTreeFields = buddyBTreeFields;
- this.btreeInteriorFrameFactory = btreeInteriorFrameFactory;
- this.btreeLeafFrameFactory = btreeLeafFrameFactory;
- this.buddyBtreeLeafFrameFactory = buddyBtreeLeafFrameFactory;
- this.secondDiskComponents = new LinkedList<>();
- }
-
- @Override
- public void create() throws HyracksDataException {
- super.create();
- secondDiskComponents.clear();
- }
-
- @Override
- public void activate() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to activate the index since it is already activated.");
- }
- if (diskComponents.size() == 0 && secondDiskComponents.size() == 0) {
- //First time activation
- List<LSMComponentFileReferences> validFileReferences;
- validFileReferences = fileManager.cleanupAndGetValidFiles();
- for (LSMComponentFileReferences lsmComonentFileReference : validFileReferences) {
- ILSMDiskComponent component;
- component =
- createDiskComponent(componentFactory, lsmComonentFileReference.getInsertIndexFileReference(),
- lsmComonentFileReference.getDeleteIndexFileReference(),
- lsmComonentFileReference.getBloomFilterFileReference(), false);
- diskComponents.add(component);
- secondDiskComponents.add(component);
- }
- ((ExternalIndexHarness) getHarness()).indexFirstTimeActivated();
- } else {
- // This index has been opened before or is brand new with no
- // components. It should also maintain the version pointer
- for (ILSMDiskComponent c : diskComponents) {
- c.activate(false);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- // Only activate non shared components
- if (!diskComponents.contains(c)) {
- c.activate(false);
- }
- }
- }
- isActive = true;
- }
-
- @Override
- public void clear() throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to clear the index since it is not activated.");
- }
- ((ExternalIndexHarness) getHarness()).indexClear();
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndDestroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.deactivateAndDestroy();
- }
- diskComponents.clear();
- secondDiskComponents.clear();
- version = 0;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to destroy the index since it is activated.");
- }
- for (ILSMDiskComponent c : diskComponents) {
- c.destroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.destroy();
- }
- diskComponents.clear();
- secondDiskComponents.clear();
- fileManager.deleteDirs();
- version = 0;
- }
-
- @Override
- public ILSMIndexAccessor createAccessor(IIndexAccessParameters iap) throws HyracksDataException {
- return new LSMTreeIndexAccessor(getHarness(), createOpContext(iap.getSearchOperationCallback(), version),
- ctx -> new LSMBTreeWithBuddySearchCursor(ctx, buddyBTreeFields));
- }
-
- // The subsume merged components is overridden to account for:
- // Maintaining two versions of the index
- @Override
- public void subsumeMergedComponents(ILSMDiskComponent newComponent, List<ILSMComponent> mergedComponents)
- throws HyracksDataException {
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- }
-
- // Check if merge will affect the older list
- if (olderList.containsAll(mergedComponents)) {
- int swapIndex = olderList.indexOf(mergedComponents.get(0));
- olderList.removeAll(mergedComponents);
- olderList.add(swapIndex, newComponent);
- }
-
- // The new list will always have all the merged components
- int swapIndex = newerList.indexOf(mergedComponents.get(0));
- newerList.removeAll(mergedComponents);
- newerList.add(swapIndex, newComponent);
- }
-
- // For initial load
- @Override
- public IIndexBulkLoader createBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCBTreeWithBuddyBulkLoader(fillLevel, verifyInput, 0, false, parameters);
- }
-
- // For transaction bulk load <- could consolidate with the above method ->
- @Override
- public IIndexBulkLoader createTransactionBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCBTreeWithBuddyBulkLoader(fillLevel, verifyInput, numElementsHint, true, parameters);
- }
-
- @Override
- public void modify(IIndexOperationContext ictx, ITupleReference tuple) throws HyracksDataException {
- throw new UnsupportedOperationException("tuple modify not supported in LSM-Disk-Only-BTree");
- }
-
- @Override
- public void search(ILSMIndexOperationContext ictx, IIndexCursor cursor, ISearchPredicate pred)
- throws HyracksDataException {
- ExternalBTreeWithBuddyOpContext ctx = (ExternalBTreeWithBuddyOpContext) ictx;
- List<ILSMComponent> operationalComponents = ictx.getComponentHolder();
- ctx.getSearchInitialState().setOperationalComponents(operationalComponents);
- cursor.open(ctx.getSearchInitialState(), pred);
- }
-
- @Override
- public ILSMIOOperation createFlushOperation(ILSMIndexOperationContext ctx) throws HyracksDataException {
- throw HyracksDataException.create(ErrorCode.FLUSH_NOT_SUPPORTED_IN_EXTERNAL_INDEX);
- }
-
- @Override
- public ILSMDiskComponent doFlush(ILSMIOOperation operation) throws HyracksDataException {
- throw HyracksDataException.create(ErrorCode.FLUSH_NOT_SUPPORTED_IN_EXTERNAL_INDEX);
- }
-
- protected LSMComponentFileReferences getMergeTargetFileName(List<ILSMComponent> mergingDiskComponents)
- throws HyracksDataException {
- BTree lastTree = ((LSMBTreeWithBuddyDiskComponent) mergingDiskComponents.get(0)).getIndex();
- BTree firstTree = ((LSMBTreeWithBuddyDiskComponent) mergingDiskComponents.get(mergingDiskComponents.size() - 1))
- .getIndex();
- FileReference firstFile = firstTree.getFileReference();
- FileReference lastFile = lastTree.getFileReference();
- LSMComponentFileReferences fileRefs =
- fileManager.getRelMergeFileReference(firstFile.getFile().getName(), lastFile.getFile().getName());
- return fileRefs;
- }
-
- @Override
- public LSMBTreeWithBuddyMergeOperation createMergeOperation(ILSMIndexOperationContext ctx)
- throws HyracksDataException {
- ILSMIndexOperationContext bctx = createOpContext(NoOpOperationCallback.INSTANCE, 0);
- bctx.setOperation(IndexOperation.MERGE);
- List<ILSMComponent> mergingComponents = ctx.getComponentHolder();
- IIndexCursorStats stats = new IndexCursorStats();
- LSMBTreeWithBuddySortedCursor cursor = new LSMBTreeWithBuddySortedCursor(bctx, buddyBTreeFields, stats);
- LSMComponentFileReferences relMergeFileRefs = getMergeTargetFileName(mergingComponents);
- ILSMIndexAccessor accessor = new LSMTreeIndexAccessor(getHarness(), bctx,
- opCtx -> new LSMBTreeWithBuddySearchCursor(opCtx, buddyBTreeFields));
-
- // Since we have two lists of components, to tell whether we need to
- // keep deleted tuples, we need to know
- // which list to check against and we need to synchronize for this
- boolean keepDeleteTuples = false;
- if (version == 0) {
- keepDeleteTuples = mergingComponents.get(mergingComponents.size() - 1) != diskComponents
- .get(diskComponents.size() - 1);
- } else {
- keepDeleteTuples = mergingComponents.get(mergingComponents.size() - 1) != secondDiskComponents
- .get(secondDiskComponents.size() - 1);
- }
-
- LSMBTreeWithBuddyMergeOperation mergeOp = new LSMBTreeWithBuddyMergeOperation(accessor, cursor, stats,
- relMergeFileRefs.getInsertIndexFileReference(), relMergeFileRefs.getDeleteIndexFileReference(),
- relMergeFileRefs.getBloomFilterFileReference(), ioOpCallback,
- fileManager.getBaseDir().getAbsolutePath(), keepDeleteTuples);
- ioOpCallback.scheduled(mergeOp);
- return mergeOp;
-
- }
-
- // This method creates the appropriate opContext for the targeted version
- public ExternalBTreeWithBuddyOpContext createOpContext(ISearchOperationCallback searchCallback, int targetVersion) {
- return new ExternalBTreeWithBuddyOpContext(this, btreeCmpFactories, buddyBtreeCmpFactories, searchCallback,
- targetVersion, getHarness(), btreeInteriorFrameFactory, btreeLeafFrameFactory,
- buddyBtreeLeafFrameFactory, tracer);
- }
-
- @Override
- public ILSMDiskComponent doMerge(ILSMIOOperation operation) throws HyracksDataException {
- LSMBTreeWithBuddyMergeOperation mergeOp = (LSMBTreeWithBuddyMergeOperation) operation;
- IIndexCursor cursor = mergeOp.getCursor();
- ISearchPredicate btreeSearchPred = new RangePredicate(null, null, true, true, null, null);
- ILSMIndexOperationContext opCtx = ((LSMBTreeWithBuddySortedCursor) cursor).getOpCtx();
- search(opCtx, cursor, btreeSearchPred);
-
- ILSMDiskComponent mergedComponent = createDiskComponent(componentFactory, mergeOp.getTarget(),
- mergeOp.getBuddyBTreeTarget(), mergeOp.getBloomFilterTarget(), true);
-
- ILSMDiskComponentBulkLoader componentBulkLoader;
-
- // In case we must keep the deleted-keys BuddyBTrees, then they must be
- // merged *before* merging the b-trees so that
- // lsmHarness.endSearch() is called once when the b-trees have been
- // merged.
-
- if (mergeOp.isKeepDeletedTuples()) {
- // Keep the deleted tuples since the oldest disk component is not
- // included in the merge operation
- LSMBuddyBTreeMergeCursor buddyBtreeCursor = new LSMBuddyBTreeMergeCursor(opCtx, mergeOp.getCursorStats());
- search(opCtx, buddyBtreeCursor, btreeSearchPred);
-
- long numElements = 0L;
- for (int i = 0; i < mergeOp.getMergingComponents().size(); ++i) {
- numElements += ((AbstractLSMWithBloomFilterDiskComponent) mergeOp.getMergingComponents().get(i))
- .getBloomFilter().getNumElements();
- }
- componentBulkLoader = mergedComponent.createBulkLoader(operation, 1.0f, false, numElements, false, false,
- false, pageWriteCallbackFactory.createPageWriteCallback());
- try {
- while (buddyBtreeCursor.hasNext()) {
- buddyBtreeCursor.next();
- ITupleReference tuple = buddyBtreeCursor.getTuple();
- componentBulkLoader.delete(tuple);
- }
- } finally {
- buddyBtreeCursor.close();
- }
- } else {
- componentBulkLoader = mergedComponent.createBulkLoader(operation, 1.0f, false, 0L, false, false, false,
- pageWriteCallbackFactory.createPageWriteCallback());
- }
-
- try {
- while (cursor.hasNext()) {
- cursor.next();
- ITupleReference frameTuple = cursor.getTuple();
- componentBulkLoader.add(frameTuple);
- }
- } finally {
- cursor.close();
- }
- componentBulkLoader.end();
- return mergedComponent;
- }
-
- @Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
- List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
- List<ILSMDiskComponent> immutableComponents;
- // Identify current list in case of a merge
- if (version == 0) {
- immutableComponents = diskComponents;
- } else {
- immutableComponents = secondDiskComponents;
- }
-
- ExternalBTreeWithBuddyOpContext opCtx = (ExternalBTreeWithBuddyOpContext) ctx;
- operationalComponents.clear();
- switch (ctx.getOperation()) {
- case SEARCH:
- if (opCtx.getTargetIndexVersion() == 0) {
- operationalComponents.addAll(diskComponents);
- } else {
- operationalComponents.addAll(secondDiskComponents);
- }
- break;
- case MERGE:
- operationalComponents.addAll(ctx.getComponentsToBeMerged());
- break;
- case FULL_MERGE:
- operationalComponents.addAll(immutableComponents);
- case REPLICATE:
- operationalComponents.addAll(ctx.getComponentsToBeReplicated());
- break;
- case FLUSH:
- // Do nothing. this is left here even though the index never
- // performs flushes because a flush is triggered by
- // dataset lifecycle manager when closing an index. Having no
- // components is a no operation
- break;
- default:
- throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported.");
- }
- }
-
- // This function is used when a new component is to be committed -- is
- // called by the harness.
- @Override
- public void commitTransactionDiskComponent(ILSMDiskComponent newComponent) throws HyracksDataException {
-
- // determine which list is the new one and flip the pointer
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- version = 1;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- version = 0;
- }
- // Remove components from list
- olderList.clear();
- // Add components
- olderList.addAll(newerList);
- if (newComponent != null) {
- // Add it to the list
- olderList.add(0, newComponent);
- }
- }
-
- @Override
- public void deactivate(boolean flushOnExit) throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to deactivate the index since it is already deactivated.");
- }
- // Even though, we deactivate the index, we don't exit components or
- // modify any of the lists to make sure they
- // are there if the index was opened again
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndPurge();
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- // Only deactivate non shared components
- if (!diskComponents.contains(c)) {
- c.deactivateAndPurge();
- }
- }
- isActive = false;
- }
-
- @Override
- public ITreeIndexFrameFactory getLeafFrameFactory() {
- return btreeLeafFrameFactory;
- }
-
- @Override
- public ITreeIndexFrameFactory getInteriorFrameFactory() {
- return btreeInteriorFrameFactory;
- }
-
- @Override
- public IMetadataPageManager getPageManager() {
- // This method should never be called for disk only indexes
- return null;
- }
-
- @Override
- public int getFieldCount() {
- return btreeCmpFactories.length;
- }
-
- @Override
- public int getRootPageId() {
- // This method should never be called for this index
- return 0;
- }
-
- @Override
- public int getFileId() {
- // This method should never be called for this index
- return 0;
- }
-
- @Override
- public IBinaryComparatorFactory[] getComparatorFactories() {
- return btreeCmpFactories;
- }
-
- // even though the index doesn't support record level modification, the
- // accessor will try to do it
- // we could throw the exception here but we don't. it will eventually be
- // thrown by the index itself
-
- // The bulk loader used for both initial loading and transaction
- // modifications
- public class LSMTwoPCBTreeWithBuddyBulkLoader implements IIndexBulkLoader, ITwoPCIndexBulkLoader {
- private final ILSMDiskComponent component;
- private final LoadOperation loadOp;
- private final ILSMDiskComponentBulkLoader componentBulkLoader;
- private final boolean isTransaction;
-
- public LSMTwoPCBTreeWithBuddyBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
- boolean isTransaction, Map<String, Object> parameters) throws HyracksDataException {
- this.isTransaction = isTransaction;
- // Create the appropriate target
- LSMComponentFileReferences componentFileRefs;
- if (isTransaction) {
- try {
- componentFileRefs = fileManager.getNewTransactionFileReference();
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- component =
- createDiskComponent(bulkLoadComponentFactory, componentFileRefs.getInsertIndexFileReference(),
- componentFileRefs.getDeleteIndexFileReference(),
- componentFileRefs.getBloomFilterFileReference(), true);
- } else {
- componentFileRefs = fileManager.getRelFlushFileReference();
- component =
- createDiskComponent(bulkLoadComponentFactory, componentFileRefs.getInsertIndexFileReference(),
- componentFileRefs.getDeleteIndexFileReference(),
- componentFileRefs.getBloomFilterFileReference(), true);
- }
-
- loadOp = new LoadOperation(componentFileRefs, ioOpCallback, getIndexIdentifier(), parameters);
- loadOp.setNewComponent(component);
- ioOpCallback.scheduled(loadOp);
- ioOpCallback.beforeOperation(loadOp);
- componentBulkLoader = component.createBulkLoader(loadOp, fillFactor, verifyInput, numElementsHint, false,
- true, false, pageWriteCallbackFactory.createPageWriteCallback());
- }
-
- @Override
- public void add(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.add(tuple);
- }
-
- @Override
- public void end() throws HyracksDataException {
- try {
- ioOpCallback.afterOperation(loadOp);
- componentBulkLoader.end();
- if (component.getComponentSize() > 0) {
- if (isTransaction) {
- // Since this is a transaction component, validate and
- // deactivate. it could later be added or deleted
- try {
- component.markAsValid(durable, loadOp);
- } finally {
- ioOpCallback.afterFinalize(loadOp);
- }
- component.deactivate();
- } else {
- ioOpCallback.afterFinalize(loadOp);
- getHarness().addBulkLoadedComponent(loadOp);
- }
- }
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- @Override
- public void delete(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.delete(tuple);
- }
-
- @Override
- public void abort() throws HyracksDataException {
- try {
- try {
- componentBulkLoader.abort();
- } finally {
- ioOpCallback.afterFinalize(loadOp);
- }
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- @Override
- public void writeFailed(ICachedPage page, Throwable failure) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean hasFailed() {
- return componentBulkLoader.hasFailed();
- }
-
- @Override
- public Throwable getFailure() {
- return componentBulkLoader.getFailure();
- }
-
- @Override
- public void force() throws HyracksDataException {
- componentBulkLoader.force();
- }
- }
-
- @Override
- public ILSMIndexAccessor createAccessor(ISearchOperationCallback searchCallback, int targetIndexVersion)
- throws HyracksDataException {
- return new LSMTreeIndexAccessor(getHarness(), createOpContext(searchCallback, targetIndexVersion),
- ctx -> new LSMBTreeWithBuddySearchCursor(ctx, buddyBTreeFields));
- }
-
- // This function in an instance of this index is only used after a bulk load
- // is successful
- // it will therefore add the component to the first list and enter it.
- @Override
- public void addDiskComponent(ILSMDiskComponent c) throws HyracksDataException {
- if (version == 0) {
- diskComponents.add(0, c);
- } else if (version == 1) {
- secondDiskComponents.add(0, c);
- }
- }
-
- @Override
- public int getCurrentVersion() {
- return version;
- }
-
- @Override
- public void setCurrentVersion(int version) {
- this.version = version;
- }
-
- @Override
- public List<ILSMDiskComponent> getFirstComponentList() {
- return diskComponents;
- }
-
- @Override
- public List<ILSMDiskComponent> getSecondComponentList() {
- return secondDiskComponents;
- }
-
- @Override
- public void commitTransaction() throws HyracksDataException {
- LSMComponentFileReferences componentFileRefrences = fileManager.getTransactionFileReferenceForCommit();
- ILSMDiskComponent component = null;
- if (componentFileRefrences != null) {
- component = createDiskComponent(componentFactory, componentFileRefrences.getInsertIndexFileReference(),
- componentFileRefrences.getDeleteIndexFileReference(),
- componentFileRefrences.getBloomFilterFileReference(), false);
- }
- ((ExternalIndexHarness) getHarness()).addTransactionComponents(component);
- }
-
- @Override
- public void abortTransaction() throws HyracksDataException {
- fileManager.deleteTransactionFiles();
- }
-
- @Override
- public void recoverTransaction() throws HyracksDataException {
- fileManager.recoverTransaction();
- }
-
- @Override
- public boolean isPrimaryIndex() {
- return false;
- }
-
- @Override
- protected LSMComponentFileReferences getMergeFileReferences(ILSMDiskComponent firstComponent,
- ILSMDiskComponent lastComponent) throws HyracksDataException {
- return null;
- }
-
- @Override
- protected AbstractLSMIndexOperationContext createOpContext(IIndexAccessParameters iap) {
- return null;
- }
-
- @Override
- protected ILSMIOOperation createFlushOperation(AbstractLSMIndexOperationContext opCtx,
- LSMComponentFileReferences componentFileRefs, ILSMIOOperationCallback callback)
- throws HyracksDataException {
- return null;
- }
-
- @Override
- protected ILSMIOOperation createMergeOperation(AbstractLSMIndexOperationContext opCtx,
- LSMComponentFileReferences mergeFileRefs, ILSMIOOperationCallback callback) throws HyracksDataException {
- return null;
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddyOpContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddyOpContext.java
deleted file mode 100644
index 1309e90..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddyOpContext.java
+++ /dev/null
@@ -1,84 +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.lsm.btree.impls;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.storage.am.common.api.IExtendedModificationOperationCallback;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndexOperationContext;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.MultiComparator;
-import org.apache.hyracks.util.trace.ITracer;
-
-public class ExternalBTreeWithBuddyOpContext extends AbstractLSMIndexOperationContext {
- private MultiComparator bTreeCmp;
- private MultiComparator buddyBTreeCmp;
- private final int targetIndexVersion;
- private LSMBTreeWithBuddyCursorInitialState searchInitialState;
-
- public ExternalBTreeWithBuddyOpContext(ILSMIndex index, IBinaryComparatorFactory[] btreeCmpFactories,
- IBinaryComparatorFactory[] buddyBtreeCmpFactories, ISearchOperationCallback searchCallback,
- int targetIndexVersion, ILSMHarness lsmHarness, ITreeIndexFrameFactory btreeInteriorFrameFactory,
- ITreeIndexFrameFactory btreeLeafFrameFactory, ITreeIndexFrameFactory buddyBtreeLeafFrameFactory,
- ITracer tracer) {
- super(index, null, null, null, searchCallback, null, tracer);
- this.targetIndexVersion = targetIndexVersion;
- this.bTreeCmp = MultiComparator.create(btreeCmpFactories);
- this.buddyBTreeCmp = MultiComparator.create(buddyBtreeCmpFactories);
- searchInitialState = new LSMBTreeWithBuddyCursorInitialState(btreeInteriorFrameFactory, btreeLeafFrameFactory,
- buddyBtreeLeafFrameFactory, lsmHarness, MultiComparator.create(btreeCmpFactories),
- MultiComparator.create(buddyBtreeCmpFactories), NoOpOperationCallback.INSTANCE, null);
- }
-
- @Override
- public void setCurrentMutableComponentId(int currentMutableComponentId) {
- // Do nothing. this should never be called for disk only indexes
- }
-
- public MultiComparator getBTreeMultiComparator() {
- return bTreeCmp;
- }
-
- public MultiComparator getBuddyBTreeMultiComparator() {
- return buddyBTreeCmp;
- }
-
- // This should never be needed for disk only indexes
- @Override
- public IExtendedModificationOperationCallback getModificationCallback() {
- return null;
- }
-
- public int getTargetIndexVersion() {
- return targetIndexVersion;
- }
-
- public LSMBTreeWithBuddyCursorInitialState getSearchInitialState() {
- return searchInitialState;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- // No Op
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
index d2fbbef..eceefc6 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
@@ -123,25 +123,6 @@
this.hasBloomFilter = hasBloomFilter;
}
- // Without memory components
- public LSMBTree(IIOManager ioManager, ITreeIndexFrameFactory insertLeafFrameFactory,
- ITreeIndexFrameFactory deleteLeafFrameFactory, IBufferCache bufferCache, ILSMIndexFileManager fileManager,
- ILSMDiskComponentFactory componentFactory, ILSMDiskComponentFactory bulkLoadComponentFactory,
- double bloomFilterFalsePositiveRate, IBinaryComparatorFactory[] cmpFactories, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- boolean needKeyDupCheck, boolean durable, ITracer tracer) throws HyracksDataException {
- super(ioManager, bufferCache, fileManager, bloomFilterFalsePositiveRate, mergePolicy, opTracker, ioScheduler,
- ioOpCallbackFactory, pageWriteCallbackFactory, componentFactory, bulkLoadComponentFactory, durable,
- tracer);
- this.insertLeafFrameFactory = insertLeafFrameFactory;
- this.deleteLeafFrameFactory = deleteLeafFrameFactory;
- this.cmpFactories = cmpFactories;
- this.needKeyDupCheck = needKeyDupCheck;
- this.hasBloomFilter = true;
- this.updateAware = false;
- }
-
@Override
public boolean isPrimaryIndex() {
return needKeyDupCheck;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/utils/LSMBTreeUtil.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/utils/LSMBTreeUtil.java
index 018c0d3..c3ca3d5 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/utils/LSMBTreeUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/utils/LSMBTreeUtil.java
@@ -30,21 +30,15 @@
import org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory;
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.btree.impls.DiskBTree;
-import org.apache.hyracks.storage.am.btree.tuples.BTreeTypeAwareTupleWriterFactory;
import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
import org.apache.hyracks.storage.am.common.api.INullIntrospector;
import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
import org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree;
-import org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTreeWithBuddy;
import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTree;
import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeDiskComponentFactory;
import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeFileManager;
import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeWithBloomFilterDiskComponentFactory;
-import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeWithBuddyDiskComponentFactory;
-import org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeWithBuddyFileManager;
import org.apache.hyracks.storage.am.lsm.btree.tuples.LSMBTreeCopyTupleWriterFactory;
import org.apache.hyracks.storage.am.lsm.btree.tuples.LSMBTreeTupleWriterFactory;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentFactory;
@@ -56,7 +50,6 @@
import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
import org.apache.hyracks.storage.am.lsm.common.api.IVirtualBufferCache;
import org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterFrameFactory;
-import org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory;
import org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper;
import org.apache.hyracks.storage.am.lsm.common.impls.DiskBTreeFactory;
import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager;
@@ -133,112 +126,4 @@
cmpFactories, mergePolicy, opTracker, ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory,
needKeyDupCheck, hasBloomFilter, btreeFields, filterFields, durable, updateAware, tracer);
}
-
- public static ExternalBTree createExternalBTree(IIOManager ioManager, FileReference file,
- IBufferCache diskBufferCache, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
- int[] bloomFilterKeyFields, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- boolean durable, IMetadataPageManagerFactory freePageManagerFactory, ITracer tracer,
- ITypeTraits nullTypeTraits, INullIntrospector nullIntrospector) throws HyracksDataException {
- LSMBTreeTupleWriterFactory insertTupleWriterFactory = new LSMBTreeTupleWriterFactory(typeTraits,
- cmpFactories.length, false, false, nullTypeTraits, nullIntrospector);
- LSMBTreeTupleWriterFactory deleteTupleWriterFactory = new LSMBTreeTupleWriterFactory(typeTraits,
- cmpFactories.length, true, false, nullTypeTraits, nullIntrospector);
- LSMBTreeCopyTupleWriterFactory copyTupleWriterFactory = new LSMBTreeCopyTupleWriterFactory(typeTraits,
- cmpFactories.length, false, nullTypeTraits, nullIntrospector);
- ITreeIndexFrameFactory insertLeafFrameFactory = new BTreeNSMLeafFrameFactory(insertTupleWriterFactory);
- ITreeIndexFrameFactory copyTupleLeafFrameFactory = new BTreeNSMLeafFrameFactory(copyTupleWriterFactory);
- ITreeIndexFrameFactory deleteLeafFrameFactory = new BTreeNSMLeafFrameFactory(deleteTupleWriterFactory);
- ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(insertTupleWriterFactory);
- // This is the tuple writer that can do both inserts and deletes
- LSMBTreeTupleWriterFactory transactionTupleWriterFactory = new LSMBTreeTupleWriterFactory(typeTraits,
- cmpFactories.length, false, false, nullTypeTraits, nullIntrospector);
- // This is the leaf frame factory for transaction components since it
- // can be used for both inserts and deletes
- ITreeIndexFrameFactory transactionLeafFrameFactory =
- new BTreeNSMLeafFrameFactory(transactionTupleWriterFactory);
- TreeIndexFactory<DiskBTree> diskBTreeFactory =
- new DiskBTreeFactory(ioManager, diskBufferCache, freePageManagerFactory, interiorFrameFactory,
- copyTupleLeafFrameFactory, cmpFactories, typeTraits.length);
- TreeIndexFactory<DiskBTree> bulkLoadBTreeFactory = new DiskBTreeFactory(ioManager, diskBufferCache,
- freePageManagerFactory, interiorFrameFactory, insertLeafFrameFactory, cmpFactories, typeTraits.length);
- BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, bloomFilterKeyFields);
- // This is the component factory for transactions
- TreeIndexFactory<DiskBTree> transactionBTreeFactory =
- new DiskBTreeFactory(ioManager, diskBufferCache, freePageManagerFactory, interiorFrameFactory,
- transactionLeafFrameFactory, cmpFactories, typeTraits.length);
- //TODO remove BloomFilter from external dataset's secondary LSMBTree index
- ILSMIndexFileManager fileNameManager = new LSMBTreeFileManager(ioManager, file, diskBTreeFactory, true);
- ILSMDiskComponentFactory componentFactory =
- new LSMBTreeWithBloomFilterDiskComponentFactory(diskBTreeFactory, bloomFilterFactory, null);
- ILSMDiskComponentFactory bulkLoadComponentFactory =
- new LSMBTreeWithBloomFilterDiskComponentFactory(bulkLoadBTreeFactory, bloomFilterFactory, null);
- ILSMDiskComponentFactory transactionComponentFactory =
- new LSMBTreeWithBloomFilterDiskComponentFactory(transactionBTreeFactory, bloomFilterFactory, null);
- // the disk only index uses an empty ArrayList for virtual buffer caches
- return new ExternalBTree(ioManager, interiorFrameFactory, insertLeafFrameFactory, deleteLeafFrameFactory,
- diskBufferCache, fileNameManager, componentFactory, bulkLoadComponentFactory,
- transactionComponentFactory, bloomFilterFalsePositiveRate, cmpFactories, mergePolicy, opTracker,
- ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, durable, tracer);
- }
-
- public static ExternalBTreeWithBuddy createExternalBTreeWithBuddy(IIOManager ioManager, FileReference file,
- IBufferCache diskBufferCache, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
- double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker,
- ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory, int[] buddyBTreeFields, boolean durable,
- IMetadataPageManagerFactory freePageManagerFactory, ITracer tracer, ITypeTraits nullTypeTraits,
- INullIntrospector nullIntrospector) throws HyracksDataException {
- ITypeTraits[] buddyBtreeTypeTraits = new ITypeTraits[buddyBTreeFields.length];
- IBinaryComparatorFactory[] buddyBtreeCmpFactories = new IBinaryComparatorFactory[buddyBTreeFields.length];
- for (int i = 0; i < buddyBtreeTypeTraits.length; i++) {
- buddyBtreeTypeTraits[i] = typeTraits[buddyBTreeFields[i]];
- buddyBtreeCmpFactories[i] = cmpFactories[buddyBTreeFields[i]];
- }
- BTreeTypeAwareTupleWriterFactory buddyBtreeTupleWriterFactory =
- new BTreeTypeAwareTupleWriterFactory(buddyBtreeTypeTraits, false, nullTypeTraits, nullIntrospector);
- ITreeIndexFrameFactory buddyBtreeInteriorFrameFactory =
- new BTreeNSMInteriorFrameFactory(buddyBtreeTupleWriterFactory);
- ITreeIndexFrameFactory buddyBtreeLeafFrameFactory = new BTreeNSMLeafFrameFactory(buddyBtreeTupleWriterFactory);
-
- LSMBTreeTupleWriterFactory insertTupleWriterFactory = new LSMBTreeTupleWriterFactory(typeTraits,
- cmpFactories.length, false, false, nullTypeTraits, nullIntrospector);
- LSMBTreeCopyTupleWriterFactory copyTupleWriterFactory = new LSMBTreeCopyTupleWriterFactory(typeTraits,
- cmpFactories.length, false, nullTypeTraits, nullIntrospector);
- ITreeIndexFrameFactory insertLeafFrameFactory = new BTreeNSMLeafFrameFactory(insertTupleWriterFactory);
- ITreeIndexFrameFactory copyTupleLeafFrameFactory = new BTreeNSMLeafFrameFactory(copyTupleWriterFactory);
- ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(insertTupleWriterFactory);
- TreeIndexFactory<BTree> diskBTreeFactory = new BTreeFactory(ioManager, diskBufferCache, freePageManagerFactory,
- interiorFrameFactory, copyTupleLeafFrameFactory, cmpFactories, typeTraits.length);
-
- TreeIndexFactory<BTree> bulkLoadBTreeFactory = new BTreeFactory(ioManager, diskBufferCache,
- freePageManagerFactory, interiorFrameFactory, insertLeafFrameFactory, cmpFactories, typeTraits.length);
-
- int[] bloomFilterKeyFields = new int[buddyBtreeCmpFactories.length];
- for (int i = 0; i < buddyBtreeCmpFactories.length; i++) {
- bloomFilterKeyFields[i] = i;
- }
- BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, bloomFilterKeyFields);
-
- // buddy b-tree factory
- TreeIndexFactory<BTree> diskBuddyBTreeFactory =
- new BTreeFactory(ioManager, diskBufferCache, freePageManagerFactory, buddyBtreeInteriorFrameFactory,
- buddyBtreeLeafFrameFactory, buddyBtreeCmpFactories, buddyBtreeTypeTraits.length);
-
- ILSMIndexFileManager fileNameManager =
- new LSMBTreeWithBuddyFileManager(ioManager, file, diskBTreeFactory, diskBuddyBTreeFactory);
-
- ILSMDiskComponentFactory componentFactory = new LSMBTreeWithBuddyDiskComponentFactory(diskBTreeFactory,
- diskBuddyBTreeFactory, bloomFilterFactory, null);
- ILSMDiskComponentFactory bulkLoadComponentFactory = new LSMBTreeWithBuddyDiskComponentFactory(
- bulkLoadBTreeFactory, diskBuddyBTreeFactory, bloomFilterFactory, null);
-
- // the disk only index uses an empty ArrayList for virtual buffer caches
- return new ExternalBTreeWithBuddy(ioManager, interiorFrameFactory, insertLeafFrameFactory,
- buddyBtreeLeafFrameFactory, diskBufferCache, fileNameManager, componentFactory,
- bulkLoadComponentFactory, bloomFilterFalsePositiveRate, mergePolicy, opTracker, ioScheduler,
- ioOpCallbackFactory, pageWriteCallbackFactory, cmpFactories, buddyBtreeCmpFactories, buddyBTreeFields,
- durable, tracer);
- }
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
index bf93dc0..2745b44 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
@@ -152,42 +152,6 @@
}
}
- // The constructor used by external indexes
- public AbstractLSMIndex(IIOManager ioManager, IBufferCache diskBufferCache, ILSMIndexFileManager fileManager,
- double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker,
- ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory, ILSMDiskComponentFactory componentFactory,
- ILSMDiskComponentFactory bulkLoadComponentFactory, boolean durable, ITracer tracer)
- throws HyracksDataException {
- this.ioManager = ioManager;
- this.diskBufferCache = diskBufferCache;
- this.fileManager = fileManager;
- this.bloomFilterFalsePositiveRate = bloomFilterFalsePositiveRate;
- this.ioOpCallback = ioOpCallbackFactory.createIoOpCallback(this);
- this.pageWriteCallbackFactory = pageWriteCallbackFactory;
- this.componentFactory = componentFactory;
- this.bulkLoadComponentFactory = bulkLoadComponentFactory;
- this.durable = durable;
- this.tracer = tracer;
- lsmHarness = new ExternalIndexHarness(this, ioScheduler, mergePolicy, opTracker,
- diskBufferCache.isReplicationEnabled());
- isActive = false;
- diskComponents = new ArrayList<>();
- this.inactiveDiskComponents = new ArrayList<>();
- this.inactiveMemoryComponents = new ArrayList<>();
- // Memory related objects are nulled
- virtualBufferCaches = null;
- memoryComponents = null;
- currentMutableComponentId = null;
- flushRequests = null;
- filterHelper = null;
- filterFrameFactory = null;
- filterManager = null;
- treeFields = null;
- filterFields = null;
- fileManager.initLastUsedSeq(ioOpCallback.getLastValidSequence());
- }
-
@Override
public synchronized void create() throws HyracksDataException {
if (isActive) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ExternalIndexHarness.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ExternalIndexHarness.java
deleted file mode 100644
index 854e541..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/ExternalIndexHarness.java
+++ /dev/null
@@ -1,332 +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.lsm.common.impls;
-
-import java.util.List;
-
-import org.apache.hyracks.api.exceptions.ErrorCode;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.replication.IReplicationJob.ReplicationOperation;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.am.lsm.common.api.LSMOperationType;
-import org.apache.hyracks.storage.common.IIndexCursor;
-import org.apache.hyracks.storage.common.ISearchPredicate;
-import org.apache.hyracks.util.trace.ITracer;
-
-public class ExternalIndexHarness extends LSMHarness {
- public ExternalIndexHarness(ILSMIndex lsmIndex, ILSMIOOperationScheduler ioScheduler, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, boolean replicationEnabled) {
- super(lsmIndex, ioScheduler, mergePolicy, opTracker, replicationEnabled, ITracer.NONE);
- }
-
- @Override
- protected boolean getAndEnterComponents(ILSMIndexOperationContext ctx, LSMOperationType opType,
- boolean isTryOperation) throws HyracksDataException {
- validateOperationEnterComponentsState(ctx);
- synchronized (opTracker) {
- while (true) {
- lsmIndex.getOperationalComponents(ctx);
- // Before entering the components, prune those corner cases that indeed should not proceed.
- switch (opType) {
- case MERGE:
- if (ctx.getComponentHolder().size() < 2) {
- // There is only a single component. There is nothing to merge.
- return false;
- }
- default:
- break;
- }
- if (enterComponents(ctx, opType)) {
- return true;
- } else if (isTryOperation) {
- return false;
- }
- }
- }
- }
-
- @Override
- protected boolean enterComponents(ILSMIndexOperationContext ctx, LSMOperationType opType)
- throws HyracksDataException {
- validateOperationEnterComponentsState(ctx);
- List<ILSMComponent> components = ctx.getComponentHolder();
- int numEntered = 0;
- boolean entranceSuccessful = false;
- try {
- for (ILSMComponent c : components) {
- if (!c.threadEnter(opType, false)) {
- break;
- }
- numEntered++;
- }
- entranceSuccessful = numEntered == components.size();
- } finally {
- if (!entranceSuccessful) {
- for (ILSMComponent c : components) {
- if (numEntered == 0) {
- break;
- }
- c.threadExit(opType, true, false);
- numEntered--;
- }
- return false;
- }
- ctx.setAccessingComponents(true);
- }
- opTracker.beforeOperation(lsmIndex, opType, ctx.getSearchOperationCallback(), ctx.getModificationCallback());
- return true;
- }
-
- private void exitComponents(ILSMIndexOperationContext ctx, LSMOperationType opType, ILSMDiskComponent newComponent,
- boolean failedOperation) throws HyracksDataException {
- /**
- * FLUSH and MERGE operations should always exit the components
- * to notify waiting threads.
- */
- if (!ctx.isAccessingComponents() && opType != LSMOperationType.FLUSH && opType != LSMOperationType.MERGE) {
- return;
- }
- synchronized (opTracker) {
- try {
- // First check if there is any action that is needed to be taken based on the state of each component.
- for (ILSMComponent c : ctx.getComponentHolder()) {
- c.threadExit(opType, failedOperation, false);
- switch (c.getState()) {
- case INACTIVE:
- if (replicationEnabled) {
- componentsToBeReplicated.clear();
- componentsToBeReplicated.add((ILSMDiskComponent) c);
- lsmIndex.scheduleReplication(null, componentsToBeReplicated,
- ReplicationOperation.DELETE, opType);
- }
- ((ILSMDiskComponent) c).deactivateAndDestroy();
- break;
- default:
- break;
- }
- }
- ctx.setAccessingComponents(false);
- // Then, perform any action that is needed to be taken based on the operation type.
- switch (opType) {
- case MERGE:
- // newComponent is null if the merge op. was not performed.
- if (newComponent != null) {
- beforeSubsumeMergedComponents(newComponent, ctx.getComponentHolder());
- lsmIndex.subsumeMergedComponents(newComponent, ctx.getComponentHolder());
- if (replicationEnabled) {
- componentsToBeReplicated.clear();
- componentsToBeReplicated.add(newComponent);
- triggerReplication(componentsToBeReplicated, opType);
- }
- mergePolicy.diskComponentAdded(lsmIndex, fullMergeIsRequested.get());
- }
- break;
- default:
- break;
- }
- } finally {
- opTracker.afterOperation(lsmIndex, opType, ctx.getSearchOperationCallback(),
- ctx.getModificationCallback());
- }
- }
- }
-
- @Override
- public void forceModify(ILSMIndexOperationContext ctx, ITupleReference tuple) throws HyracksDataException {
- throw HyracksDataException.create(ErrorCode.MODIFY_NOT_SUPPORTED_IN_EXTERNAL_INDEX);
- }
-
- @Override
- public boolean modify(ILSMIndexOperationContext ctx, boolean tryOperation, ITupleReference tuple)
- throws HyracksDataException {
- throw HyracksDataException.create(ErrorCode.MODIFY_NOT_SUPPORTED_IN_EXTERNAL_INDEX);
- }
-
- @Override
- public void search(ILSMIndexOperationContext ctx, IIndexCursor cursor, ISearchPredicate pred)
- throws HyracksDataException {
- LSMOperationType opType = LSMOperationType.SEARCH;
- getAndEnterComponents(ctx, opType, false);
- try {
- lsmIndex.search(ctx, cursor, pred);
- } catch (Exception e) {
- exitComponents(ctx, opType, null, true);
- throw e;
- }
- }
-
- @Override
- public void endSearch(ILSMIndexOperationContext ctx) throws HyracksDataException {
- if (ctx.getOperation() == IndexOperation.SEARCH) {
- try {
- exitComponents(ctx, LSMOperationType.SEARCH, null, false);
- } catch (Exception e) {
- throw HyracksDataException.create(e);
- }
- }
- }
-
- @SuppressWarnings("squid:S1181")
- @Override
- public void addBulkLoadedComponent(ILSMIOOperation ioOperation) throws HyracksDataException {
- ILSMDiskComponent c = ioOperation.getNewComponent();
- try {
- c.markAsValid(lsmIndex.isDurable(), ioOperation);
- } catch (Throwable th) {
- ioOperation.setFailure(th);
- }
- if (ioOperation.hasFailed()) {
- throw HyracksDataException.create(ioOperation.getFailure());
- }
- synchronized (opTracker) {
- lsmIndex.addDiskComponent(c);
- if (replicationEnabled) {
- componentsToBeReplicated.clear();
- componentsToBeReplicated.add(c);
- triggerReplication(componentsToBeReplicated, LSMOperationType.LOAD);
- }
- // Enter the component
- enterComponent(c);
- mergePolicy.diskComponentAdded(lsmIndex, false);
- }
- }
-
- // Three differences from addBulkLoadedComponent
- // 1. this needs synchronization since others might be accessing the index (specifically merge operations that might change the lists of components)
- // 2. the actions taken by the index itself are different
- // 3. the component has already been marked valid by the bulk update operation
- public void addTransactionComponents(ILSMDiskComponent newComponent) throws HyracksDataException {
- ITwoPCIndex index = (ITwoPCIndex) lsmIndex;
- synchronized (opTracker) {
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (index.getCurrentVersion() == 0) {
- newerList = index.getFirstComponentList();
- olderList = index.getSecondComponentList();
- } else {
- newerList = index.getSecondComponentList();
- olderList = index.getFirstComponentList();
- }
- // Exit components in old version of the index so they are ready to be
- // deleted if they are not needed anymore
- for (ILSMDiskComponent c : olderList) {
- exitComponent(c);
- }
- // Enter components in the newer list
- for (ILSMDiskComponent c : newerList) {
- enterComponent(c);
- }
- if (newComponent != null) {
- // Enter new component
- enterComponent(newComponent);
- }
- index.commitTransactionDiskComponent(newComponent);
- mergePolicy.diskComponentAdded(lsmIndex, fullMergeIsRequested.get());
- }
- }
-
- @Override
- public ILSMIOOperation scheduleFlush(ILSMIndexOperationContext ctx) throws HyracksDataException {
- return NoOpIoOperation.INSTANCE;
- }
-
- @Override
- public void flush(ILSMIOOperation operation) throws HyracksDataException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILSMOperationTracker getOperationTracker() {
- return opTracker;
- }
-
- public void beforeSubsumeMergedComponents(ILSMComponent newComponent, List<ILSMComponent> mergedComponents)
- throws HyracksDataException {
- ITwoPCIndex index = (ITwoPCIndex) lsmIndex;
- // check if merge will affect the first list
- if (index.getFirstComponentList().containsAll(mergedComponents)) {
- // exit un-needed components
- for (ILSMComponent c : mergedComponents) {
- exitComponent((ILSMDiskComponent) c);
- }
- // enter new component
- enterComponent(newComponent);
- }
- // check if merge will affect the second list
- if (index.getSecondComponentList().containsAll(mergedComponents)) {
- // exit un-needed components
- for (ILSMComponent c : mergedComponents) {
- exitComponent((ILSMDiskComponent) c);
- }
- // enter new component
- enterComponent(newComponent);
- }
- }
-
- // The two methods: enterComponent and exitComponent are used to control
- // when components are to be deleted from disk
- private void enterComponent(ILSMComponent diskComponent) throws HyracksDataException {
- diskComponent.threadEnter(LSMOperationType.SEARCH, false);
- }
-
- private void exitComponent(ILSMDiskComponent diskComponent) throws HyracksDataException {
- diskComponent.threadExit(LSMOperationType.SEARCH, false, false);
- if (diskComponent.getState() == ILSMComponent.ComponentState.INACTIVE) {
- if (replicationEnabled) {
- componentsToBeReplicated.clear();
- componentsToBeReplicated.add(diskComponent);
- lsmIndex.scheduleReplication(null, componentsToBeReplicated, ReplicationOperation.DELETE, null);
- }
- diskComponent.deactivateAndDestroy();
- }
- }
-
- public void indexFirstTimeActivated() throws HyracksDataException {
- ITwoPCIndex index = (ITwoPCIndex) lsmIndex;
- // Enter disk components <-- To avoid deleting them when they are
- // still needed-->
- for (ILSMComponent c : index.getFirstComponentList()) {
- enterComponent(c);
- }
- for (ILSMComponent c : index.getSecondComponentList()) {
- enterComponent(c);
- }
- }
-
- public void indexClear() throws HyracksDataException {
- ITwoPCIndex index = (ITwoPCIndex) lsmIndex;
- for (ILSMDiskComponent c : index.getFirstComponentList()) {
- exitComponent(c);
- }
- for (ILSMDiskComponent c : index.getSecondComponentList()) {
- exitComponent(c);
- }
- }
-
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResource.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResource.java
deleted file mode 100644
index e6d50d0..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResource.java
+++ /dev/null
@@ -1,114 +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.lsm.rtree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.application.INCServiceContext;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ILinearizeComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.io.IJsonSerializable;
-import org.apache.hyracks.api.io.IPersistedResourceRegistry;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.rtree.utils.LSMRTreeUtils;
-import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
-import org.apache.hyracks.storage.common.IIndex;
-import org.apache.hyracks.storage.common.IStorageManager;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * The local resource class for disk only lsm r-tree
- */
-public class ExternalRTreeLocalResource extends LSMRTreeLocalResource {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalRTreeLocalResource(String path, IStorageManager storageManager, ITypeTraits[] typeTraits,
- IBinaryComparatorFactory[] rtreeCmpFactories, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerProvider, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, boolean durable, IBinaryComparatorFactory[] btreeCmpFactories,
- IPrimitiveValueProviderFactory[] valueProviderFactories, RTreePolicyType rtreePolicyType,
- ILinearizeComparatorFactory linearizeCmpFactory, int[] rtreeFields, int[] buddyBTreeFields,
- boolean isPointMBR, double bloomFilterFalsePositiveRate, ITypeTraits nullTypeTraits,
- INullIntrospector nullIntrospector) {
- super(path, storageManager, typeTraits, rtreeCmpFactories, filterTypeTraits, filterCmpFactories, filterFields,
- opTrackerProvider, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory, null,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, durable, btreeCmpFactories,
- valueProviderFactories, rtreePolicyType, linearizeCmpFactory, rtreeFields, buddyBTreeFields, isPointMBR,
- bloomFilterFalsePositiveRate, nullTypeTraits, nullIntrospector);
- }
-
- private ExternalRTreeLocalResource(IPersistedResourceRegistry registry, JsonNode json,
- IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories,
- RTreePolicyType rtreePolicyType, ILinearizeComparatorFactory linearizeCmpFactory, int[] rtreeFields,
- int[] buddyBTreeFields, boolean isPointMBR, double bloomFilterFalsePositiveRate)
- throws HyracksDataException {
- super(registry, json, btreeCmpFactories, valueProviderFactories, rtreePolicyType, linearizeCmpFactory,
- rtreeFields, buddyBTreeFields, isPointMBR, bloomFilterFalsePositiveRate);
- }
-
- @Override
- public IIndex createInstance(INCServiceContext ncServiceCtx) throws HyracksDataException {
- IIOManager ioManager = ncServiceCtx.getIoManager();
- FileReference fileRef = ioManager.resolve(path);
- ioOpCallbackFactory.initialize(ncServiceCtx, this);
- pageWriteCallbackFactory.initialize(ncServiceCtx, this);
- return LSMRTreeUtils.createExternalRTree(ioManager, fileRef, storageManager.getBufferCache(ncServiceCtx),
- typeTraits, cmpFactories, btreeCmpFactories, valueProviderFactories, rtreePolicyType,
- bloomFilterFalsePositiveRate, mergePolicyFactory.createMergePolicy(mergePolicyProperties, ncServiceCtx),
- opTrackerProvider.getOperationTracker(ncServiceCtx, this),
- ioSchedulerProvider.getIoScheduler(ncServiceCtx), ioOpCallbackFactory, pageWriteCallbackFactory,
- linearizeCmpFactory, buddyBTreeFields, durable, isPointMBR, metadataPageManagerFactory,
- ncServiceCtx.getTracer(), nullTypeTraits, nullIntrospector);
-
- }
-
- @Override
- public JsonNode toJson(IPersistedResourceRegistry registry) throws HyracksDataException {
- final ObjectNode jsonObject = registry.getClassIdentifier(getClass(), serialVersionUID);
- super.appendToJson(jsonObject, registry);
- return jsonObject;
- }
-
- public static IJsonSerializable fromJson(IPersistedResourceRegistry registry, JsonNode json)
- throws HyracksDataException {
- LSMRTreeLocalResource lsmRTree = (LSMRTreeLocalResource) LSMRTreeLocalResource.fromJson(registry, json);
- return new ExternalRTreeLocalResource(registry, json, lsmRTree.btreeCmpFactories,
- lsmRTree.valueProviderFactories, lsmRTree.rtreePolicyType, lsmRTree.linearizeCmpFactory,
- lsmRTree.rtreeFields, lsmRTree.buddyBTreeFields, lsmRTree.isPointMBR,
- lsmRTree.bloomFilterFalsePositiveRate);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResourceFactory.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResourceFactory.java
deleted file mode 100644
index ca8caec..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/dataflow/ExternalRTreeLocalResourceFactory.java
+++ /dev/null
@@ -1,72 +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.lsm.rtree.dataflow;
-
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ILinearizeComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ITypeTraits;
-import org.apache.hyracks.api.io.FileReference;
-import org.apache.hyracks.storage.am.common.api.IMetadataPageManagerFactory;
-import org.apache.hyracks.storage.am.common.api.INullIntrospector;
-import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationSchedulerProvider;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicyFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTrackerFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.dataflow.LsmResource;
-import org.apache.hyracks.storage.am.rtree.frames.RTreePolicyType;
-import org.apache.hyracks.storage.common.IStorageManager;
-
-public class ExternalRTreeLocalResourceFactory extends LSMRTreeLocalResourceFactory {
-
- private static final long serialVersionUID = 1L;
-
- public ExternalRTreeLocalResourceFactory(IStorageManager storageManager, ITypeTraits[] typeTraits,
- IBinaryComparatorFactory[] cmpFactories, ITypeTraits[] filterTypeTraits,
- IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields,
- ILSMOperationTrackerFactory opTrackerFactory, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- IMetadataPageManagerFactory metadataPageManagerFactory,
- ILSMIOOperationSchedulerProvider ioSchedulerProvider, ILSMMergePolicyFactory mergePolicyFactory,
- Map<String, String> mergePolicyProperties, boolean durable, IBinaryComparatorFactory[] btreeCmpFactories,
- IPrimitiveValueProviderFactory[] valueProviderFactories, RTreePolicyType rtreePolicyType,
- ILinearizeComparatorFactory linearizeCmpFactory, int[] rtreeFields, int[] buddyBTreeFields,
- boolean isPointMBR, double bloomFilterFalsePositiveRate, ITypeTraits nullTypeTraits,
- INullIntrospector nullIntrospector) {
- super(storageManager, typeTraits, cmpFactories, filterTypeTraits, filterCmpFactories, filterFields,
- opTrackerFactory, ioOpCallbackFactory, pageWriteCallbackFactory, metadataPageManagerFactory, null,
- ioSchedulerProvider, mergePolicyFactory, mergePolicyProperties, durable, btreeCmpFactories,
- valueProviderFactories, rtreePolicyType, linearizeCmpFactory, rtreeFields, buddyBTreeFields, isPointMBR,
- bloomFilterFalsePositiveRate, nullTypeTraits, nullIntrospector);
- }
-
- @Override
- public LsmResource createResource(FileReference fileRef) {
- return new ExternalRTreeLocalResource(fileRef.getRelativePath(), storageManager, typeTraits, cmpFactories,
- filterTypeTraits, filterCmpFactories, filterFields, opTrackerProvider, ioOpCallbackFactory,
- pageWriteCallbackFactory, metadataPageManagerFactory, ioSchedulerProvider, mergePolicyFactory,
- mergePolicyProperties, durable, btreeCmpFactories, valueProviderFactories, rtreePolicyType,
- linearizeCmpFactory, rtreeFields, buddyBTreeFields, isPointMBR, bloomFilterFalsePositiveRate,
- nullTypeTraits, nullIntrospector);
- }
-
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
index 1b847a0..e95ef67 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
@@ -117,34 +117,6 @@
this.isPointMBR = isPointMBR;
}
- /*
- * For External indexes with no memory components
- */
- public AbstractLSMRTree(IIOManager ioManager, ITreeIndexFrameFactory rtreeInteriorFrameFactory,
- ITreeIndexFrameFactory rtreeLeafFrameFactory, ITreeIndexFrameFactory btreeInteriorFrameFactory,
- ITreeIndexFrameFactory btreeLeafFrameFactory, IBufferCache diskBufferCache,
- ILSMIndexFileManager fileManager, ILSMDiskComponentFactory componentFactory,
- IBinaryComparatorFactory[] rtreeCmpFactories, IBinaryComparatorFactory[] btreeCmpFactories,
- ILinearizeComparatorFactory linearizer, int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray,
- double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker,
- ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallbackFactory ioOpCallbackFactory,
- ILSMPageWriteCallbackFactory pageWriteCallbackFactory, boolean durable, boolean isPointMBR, ITracer tracer)
- throws HyracksDataException {
- super(ioManager, diskBufferCache, fileManager, bloomFilterFalsePositiveRate, mergePolicy, opTracker,
- ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, componentFactory, componentFactory, durable,
- tracer);
- this.rtreeInteriorFrameFactory = rtreeInteriorFrameFactory;
- this.rtreeLeafFrameFactory = rtreeLeafFrameFactory;
- this.btreeInteriorFrameFactory = btreeInteriorFrameFactory;
- this.btreeLeafFrameFactory = btreeLeafFrameFactory;
- this.btreeCmpFactories = btreeCmpFactories;
- this.rtreeCmpFactories = rtreeCmpFactories;
- this.linearizer = linearizer;
- this.comparatorFields = comparatorFields;
- this.linearizerArray = linearizerArray;
- this.isPointMBR = isPointMBR;
- }
-
@Override
public void search(ILSMIndexOperationContext ictx, IIndexCursor cursor, ISearchPredicate pred)
throws HyracksDataException {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTree.java
deleted file mode 100644
index 5557bbe..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTree.java
+++ /dev/null
@@ -1,656 +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.lsm.rtree.impls;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.ILinearizeComparatorFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
-import org.apache.hyracks.storage.am.bloomfilter.impls.BloomCalculations;
-import org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterSpecification;
-import org.apache.hyracks.storage.am.btree.impls.BTree;
-import org.apache.hyracks.storage.am.common.api.IIndexOperationContext;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader;
-import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback;
-import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperation;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMPageWriteCallbackFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.ExternalIndexHarness;
-import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences;
-import org.apache.hyracks.storage.am.lsm.common.impls.LoadOperation;
-import org.apache.hyracks.storage.am.rtree.impls.SearchPredicate;
-import org.apache.hyracks.storage.common.IIndexAccessParameters;
-import org.apache.hyracks.storage.common.IIndexBulkLoader;
-import org.apache.hyracks.storage.common.IIndexCursor;
-import org.apache.hyracks.storage.common.IIndexCursorStats;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.ISearchPredicate;
-import org.apache.hyracks.storage.common.IndexCursorStats;
-import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.hyracks.storage.common.buffercache.ICachedPage;
-import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
-import org.apache.hyracks.util.trace.ITracer;
-
-/**
- * This is an lsm r-tree that does not have memory component and is modified
- * only by bulk loading and addition of disk components as of this point, it is
- * intended for use with external dataset indexes only.
- */
-public class ExternalRTree extends LSMRTree implements ITwoPCIndex {
-
- // A second disk component list that will be used when a transaction is
- // committed and will be seen by subsequent accessors
- private final List<ILSMDiskComponent> secondDiskComponents;
- // A pointer that points to the current most recent list (either
- // diskComponents = 0, or secondDiskComponents = 1). It starts with -1 to
- // indicate first time activation
- private int version = 0;
- private final int fieldCount;
-
- public ExternalRTree(IIOManager ioManager, ITreeIndexFrameFactory rtreeInteriorFrameFactory,
- ITreeIndexFrameFactory rtreeLeafFrameFactory, ITreeIndexFrameFactory btreeInteriorFrameFactory,
- ITreeIndexFrameFactory btreeLeafFrameFactory, IBufferCache diskBufferCache,
- ILSMIndexFileManager fileNameManager, ILSMDiskComponentFactory componentFactory,
- double bloomFilterFalsePositiveRate, int fieldCount, IBinaryComparatorFactory[] rtreeCmpFactories,
- IBinaryComparatorFactory[] btreeCmpFactories, ILinearizeComparatorFactory linearizer,
- int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- int[] buddyBTreeFields, boolean durable, boolean isPointMBR, ITracer tracer) throws HyracksDataException {
- super(ioManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory,
- btreeLeafFrameFactory, diskBufferCache, fileNameManager, componentFactory, bloomFilterFalsePositiveRate,
- rtreeCmpFactories, btreeCmpFactories, linearizer, comparatorFields, linearizerArray, mergePolicy,
- opTracker, ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, buddyBTreeFields, durable,
- isPointMBR, tracer);
- this.secondDiskComponents = new LinkedList<>();
- this.fieldCount = fieldCount;
- }
-
- @Override
- public ExternalIndexHarness getHarness() {
- return (ExternalIndexHarness) super.getHarness();
- }
-
- // The subsume merged components is overridden to account for:
- // 1. the number of readers of components
- // 2. maintaining two versions of the index
- @Override
- public void subsumeMergedComponents(ILSMDiskComponent newComponent, List<ILSMComponent> mergedComponents)
- throws HyracksDataException {
- // determine which list is the new one
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- }
- // check if merge will affect the older list
- if (olderList.containsAll(mergedComponents)) {
- int swapIndex = olderList.indexOf(mergedComponents.get(0));
- olderList.removeAll(mergedComponents);
- olderList.add(swapIndex, newComponent);
- }
- // The new list will always have all the merged components
- int swapIndex = newerList.indexOf(mergedComponents.get(0));
- newerList.removeAll(mergedComponents);
- newerList.add(swapIndex, newComponent);
- }
-
- // This method is used by the merge policy when it needs to check if a merge
- // is needed.
- // It only needs to return the newer list
- @Override
- public List<ILSMDiskComponent> getDiskComponents() {
- if (version == 0) {
- return diskComponents;
- } else {
- return secondDiskComponents;
- }
- }
-
- // This function should only be used when a transaction fail. it doesn't
- // take any parameters since there can only be
- // a single transaction and hence a single transaction component on disk
- public void deleteTransactionComponent() throws HyracksDataException {
- fileManager.deleteTransactionFiles();
- }
-
- // This function in an instance of this index is only used after a bulk load
- // is successful
- // it will therefore add the component to the first list and enter it.
- @Override
- public void addDiskComponent(ILSMDiskComponent c) throws HyracksDataException {
- if (version == 0) {
- diskComponents.add(0, c);
- } else if (version == 1) {
- secondDiskComponents.add(0, c);
- }
- }
-
- // This function is used when a new component is to be committed.
- @Override
- public void commitTransactionDiskComponent(ILSMDiskComponent newComponent) throws HyracksDataException {
-
- // determine which list is the new one and flip the pointer
- List<ILSMDiskComponent> newerList;
- List<ILSMDiskComponent> olderList;
- if (version == 0) {
- newerList = diskComponents;
- olderList = secondDiskComponents;
- version = 1;
- } else {
- newerList = secondDiskComponents;
- olderList = diskComponents;
- version = 0;
- }
- // Remove components from list
- olderList.clear();
- // Add components
- olderList.addAll(newerList);
- if (newComponent != null) {
- // Add it to the list
- olderList.add(0, newComponent);
- }
- }
-
- @Override
- public synchronized void activate() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to activate the index since it is already activated.");
- }
-
- if (diskComponents.size() == 0 && secondDiskComponents.size() == 0) {
- //First time activation
- List<LSMComponentFileReferences> validFileReferences;
- validFileReferences = fileManager.cleanupAndGetValidFiles();
- for (LSMComponentFileReferences lsmComonentFileReference : validFileReferences) {
- ILSMDiskComponent component;
- component =
- createDiskComponent(componentFactory, lsmComonentFileReference.getInsertIndexFileReference(),
- lsmComonentFileReference.getDeleteIndexFileReference(),
- lsmComonentFileReference.getBloomFilterFileReference(), false);
- diskComponents.add(component);
- secondDiskComponents.add(component);
- }
- getHarness().indexFirstTimeActivated();
- } else {
- // This index has been opened before or is brand new with no components
- // components. It should also maintain the version pointer
- for (ILSMComponent c : diskComponents) {
- LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
- component.activate(false);
- }
- for (ILSMComponent c : secondDiskComponents) {
- // Only activate non shared components
- if (!diskComponents.contains(c)) {
- LSMRTreeDiskComponent component = (LSMRTreeDiskComponent) c;
- component.activate(false);
- }
- }
- }
- isActive = true;
- }
-
- @Override
- public synchronized void create() throws HyracksDataException {
- super.create();
- secondDiskComponents.clear();
- }
-
- // we override this method because this index uses a different opcontext
- @Override
- public void search(ILSMIndexOperationContext ictx, IIndexCursor cursor, ISearchPredicate pred)
- throws HyracksDataException {
- ExternalRTreeOpContext ctx = (ExternalRTreeOpContext) ictx;
- List<ILSMComponent> operationalComponents = ictx.getComponentHolder();
- ctx.getInitialState().setOperationalComponents(operationalComponents);
- cursor.open(ctx.getInitialState(), pred);
- }
-
- // The only reason for overriding the merge method is the way to determine
- // the need to keep deleted tuples
- // This can be done in a better way by creating a method boolean
- // keepDeletedTuples(mergedComponents);
- @Override
- public ILSMDiskComponent doMerge(ILSMIOOperation operation) throws HyracksDataException {
- LSMRTreeMergeOperation mergeOp = (LSMRTreeMergeOperation) operation;
- IIndexCursor cursor = mergeOp.getCursor();
- ISearchPredicate rtreeSearchPred = new SearchPredicate(null, null);
- ILSMIndexOperationContext opCtx = ((LSMRTreeSortedCursor) cursor).getOpCtx();
- search(opCtx, cursor, rtreeSearchPred);
-
- LSMRTreeDiskComponent mergedComponent = (LSMRTreeDiskComponent) createDiskComponent(componentFactory,
- mergeOp.getTarget(), mergeOp.getBTreeTarget(), mergeOp.getBloomFilterTarget(), true);
-
- // In case we must keep the deleted-keys BTrees, then they must be
- // merged *before* merging the r-trees so that
- // lsmHarness.endSearch() is called once when the r-trees have been
- // merged.
- boolean keepDeleteTuples = false;
- if (version == 0) {
- keepDeleteTuples = mergeOp.getMergingComponents()
- .get(mergeOp.getMergingComponents().size() - 1) != diskComponents.get(diskComponents.size() - 1);
- } else {
- keepDeleteTuples = mergeOp.getMergingComponents()
- .get(mergeOp.getMergingComponents().size() - 1) != secondDiskComponents
- .get(secondDiskComponents.size() - 1);
- }
- IPageWriteCallback pageWriteCallback = pageWriteCallbackFactory.createPageWriteCallback();
- if (keepDeleteTuples) {
- // Keep the deleted tuples since the oldest disk component is not
- // included in the merge operation
-
- LSMRTreeDeletedKeysBTreeMergeCursor btreeCursor =
- new LSMRTreeDeletedKeysBTreeMergeCursor(opCtx, mergeOp.getCursorStats());
- search(opCtx, btreeCursor, rtreeSearchPred);
-
- BTree btree = mergedComponent.getBuddyIndex();
- IIndexBulkLoader btreeBulkLoader = btree.createBulkLoader(1.0f, true, 0L, false, pageWriteCallback);
-
- long numElements = 0L;
- for (int i = 0; i < mergeOp.getMergingComponents().size(); ++i) {
- numElements += ((LSMRTreeDiskComponent) mergeOp.getMergingComponents().get(i)).getBloomFilter()
- .getNumElements();
- }
-
- int maxBucketsPerElement = BloomCalculations.maxBucketsPerElement(numElements);
- BloomFilterSpecification bloomFilterSpec =
- BloomCalculations.computeBloomSpec(maxBucketsPerElement, bloomFilterFalsePositiveRate);
- IIndexBulkLoader builder = mergedComponent.getBloomFilter().createBuilder(numElements,
- bloomFilterSpec.getNumHashes(), bloomFilterSpec.getNumBucketsPerElements(), pageWriteCallback);
-
- try {
- while (btreeCursor.hasNext()) {
- btreeCursor.next();
- ITupleReference tuple = btreeCursor.getTuple();
- btreeBulkLoader.add(tuple);
- builder.add(tuple);
- }
- } finally {
- btreeCursor.destroy();
- builder.end();
- }
- btreeBulkLoader.end();
- }
-
- IIndexBulkLoader bulkLoader =
- mergedComponent.getIndex().createBulkLoader(1.0f, false, 0L, false, pageWriteCallback);
- try {
- while (cursor.hasNext()) {
- cursor.next();
- ITupleReference frameTuple = cursor.getTuple();
- bulkLoader.add(frameTuple);
- }
- } finally {
- cursor.destroy();
- }
- bulkLoader.end();
- return mergedComponent;
- }
-
- @Override
- public void deactivate(boolean flushOnExit) throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to deactivate the index since it is already deactivated.");
- }
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndPurge();
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- if (!diskComponents.contains(c)) {
- c.deactivateAndPurge();
- }
- }
- isActive = false;
- }
-
- // The clear method is not used anywhere in AsterixDB! we override it anyway
- // to exit components first and clear the two lists
- @Override
- public void clear() throws HyracksDataException {
- if (!isActive) {
- throw new HyracksDataException("Failed to clear the index since it is not activated.");
- }
- getHarness().indexClear();
-
- for (ILSMDiskComponent c : diskComponents) {
- c.deactivateAndDestroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
-
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.deactivateAndDestroy();
- }
-
- diskComponents.clear();
- secondDiskComponents.clear();
- version = 0;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- if (isActive) {
- throw new HyracksDataException("Failed to destroy the index since it is activated.");
- }
- for (ILSMDiskComponent c : diskComponents) {
- c.destroy();
- // Remove from second list to avoid destroying twice
- secondDiskComponents.remove(c);
- }
- for (ILSMDiskComponent c : secondDiskComponents) {
- c.destroy();
- }
- diskComponents.clear();
- secondDiskComponents.clear();
- fileManager.deleteDirs();
- version = 0;
- }
-
- @Override
- public void modify(IIndexOperationContext ictx, ITupleReference tuple) throws HyracksDataException {
- throw new UnsupportedOperationException("tuple modify not supported in LSM-Disk-Only-RTree");
- }
-
- @Override
- public ILSMIOOperation createFlushOperation(ILSMIndexOperationContext ctx) throws HyracksDataException {
- throw new UnsupportedOperationException("flush not supported in LSM-Disk-Only-RTree");
- }
-
- // Not supported
- @Override
- public ILSMDiskComponent doFlush(ILSMIOOperation operation) throws HyracksDataException {
- throw new UnsupportedOperationException("flush not supported in LSM-Disk-Only-RTree");
- }
-
- // Only support search and merge operations
- @Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
- List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
- List<ILSMDiskComponent> immutableComponents;
- // Identify current list in case of a merge
- if (version == 0) {
- immutableComponents = diskComponents;
- } else {
- immutableComponents = secondDiskComponents;
- }
- ExternalRTreeOpContext opCtx = (ExternalRTreeOpContext) ctx;
- operationalComponents.clear();
- switch (ctx.getOperation()) {
- case SEARCH:
- if (opCtx.getTargetIndexVersion() == 0) {
- operationalComponents.addAll(diskComponents);
- } else {
- operationalComponents.addAll(secondDiskComponents);
- }
- break;
- case MERGE:
- operationalComponents.addAll(ctx.getComponentsToBeMerged());
- break;
- case FULL_MERGE:
- operationalComponents.addAll(immutableComponents);
- break;
- case REPLICATE:
- operationalComponents.addAll(ctx.getComponentsToBeReplicated());
- break;
- case FLUSH:
- // Do nothing. this is left here even though the index never
- // performs flushes because a flush is triggered by
- // dataset lifecycle manager when closing an index. Having no
- // components is a no operation
- break;
- default:
- throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported.");
- }
- }
-
- // For initial load
- @Override
- public IIndexBulkLoader createBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCRTreeBulkLoader(fillLevel, verifyInput, 0, false, parameters);
- }
-
- // For transaction bulk load <- could consolidate with the above method ->
- @Override
- public IIndexBulkLoader createTransactionBulkLoader(float fillLevel, boolean verifyInput, long numElementsHint,
- Map<String, Object> parameters) throws HyracksDataException {
- return new LSMTwoPCRTreeBulkLoader(fillLevel, verifyInput, numElementsHint, true, parameters);
- }
-
- // The bulk loader used for both initial loading and transaction
- // modifications
- public class LSMTwoPCRTreeBulkLoader implements IIndexBulkLoader, ITwoPCIndexBulkLoader {
- private final ILSMDiskComponent component;
- private final boolean isTransaction;
- private final LoadOperation loadOp;
- private final ILSMDiskComponentBulkLoader componentBulkLoader;
-
- public LSMTwoPCRTreeBulkLoader(float fillFactor, boolean verifyInput, long numElementsHint,
- boolean isTransaction, Map<String, Object> parameters) throws HyracksDataException {
- this.isTransaction = isTransaction;
- // Create the appropriate target
- LSMComponentFileReferences componentFileRefs;
- if (isTransaction) {
- try {
- componentFileRefs = fileManager.getNewTransactionFileReference();
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
- component = createDiskComponent(componentFactory, componentFileRefs.getInsertIndexFileReference(),
- componentFileRefs.getDeleteIndexFileReference(),
- componentFileRefs.getBloomFilterFileReference(), true);
- } else {
- componentFileRefs = fileManager.getRelFlushFileReference();
- component =
- createDiskComponent(bulkLoadComponentFactory, componentFileRefs.getInsertIndexFileReference(),
- componentFileRefs.getDeleteIndexFileReference(),
- componentFileRefs.getBloomFilterFileReference(), true);
- }
-
- loadOp = new LoadOperation(componentFileRefs, ioOpCallback, getIndexIdentifier(), parameters);
- loadOp.setNewComponent(component);
- ioOpCallback.scheduled(loadOp);
- ioOpCallback.beforeOperation(loadOp);
- componentBulkLoader = component.createBulkLoader(loadOp, fillFactor, verifyInput, numElementsHint, false,
- true, false, pageWriteCallbackFactory.createPageWriteCallback());
- }
-
- @Override
- public void add(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.add(tuple);
- }
-
- @Override
- public void end() throws HyracksDataException {
- try {
- ioOpCallback.afterOperation(loadOp);
- componentBulkLoader.end();
- if (component.getComponentSize() > 0) {
- if (isTransaction) {
- // Since this is a transaction component, validate and
- // deactivate. it could later be added or deleted
- try {
- component.markAsValid(durable, loadOp);
- } finally {
- ioOpCallback.afterFinalize(loadOp);
- }
- component.deactivate();
- } else {
- ioOpCallback.afterFinalize(loadOp);
- getHarness().addBulkLoadedComponent(loadOp);
- }
- }
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- @Override
- public void delete(ITupleReference tuple) throws HyracksDataException {
- componentBulkLoader.delete(tuple);
- }
-
- @Override
- public void abort() throws HyracksDataException {
- try {
- try {
- componentBulkLoader.abort();
- } finally {
- ioOpCallback.afterFinalize(loadOp);
- }
- } finally {
- ioOpCallback.completed(loadOp);
- }
- }
-
- @Override
- public void writeFailed(ICachedPage page, Throwable failure) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean hasFailed() {
- return loadOp.hasFailed();
- }
-
- @Override
- public Throwable getFailure() {
- return loadOp.getFailure();
- }
-
- @Override
- public void force() throws HyracksDataException {
- componentBulkLoader.force();
- }
- }
-
- // The only change the the schedule merge is the method used to create the
- // opCtx. first line <- in schedule merge, we->
- @Override
- public ILSMIOOperation createMergeOperation(ILSMIndexOperationContext ctx) throws HyracksDataException {
- ILSMIndexOperationContext rctx = createOpContext(NoOpOperationCallback.INSTANCE, -1);
- rctx.setOperation(IndexOperation.MERGE);
- List<ILSMComponent> mergingComponents = ctx.getComponentHolder();
- IIndexCursorStats stats = new IndexCursorStats();
- LSMRTreeSortedCursor cursor = new LSMRTreeSortedCursor(rctx, linearizer, buddyBTreeFields, stats);
- LSMComponentFileReferences relMergeFileRefs =
- getMergeFileReferences((ILSMDiskComponent) mergingComponents.get(mergingComponents.size() - 1),
- (ILSMDiskComponent) mergingComponents.get(0));
- ILSMIndexAccessor accessor = new LSMRTreeAccessor(getHarness(), rctx, buddyBTreeFields);
- // create the merge operation.
- LSMRTreeMergeOperation mergeOp =
- new LSMRTreeMergeOperation(accessor, cursor, stats, relMergeFileRefs.getInsertIndexFileReference(),
- relMergeFileRefs.getDeleteIndexFileReference(), relMergeFileRefs.getBloomFilterFileReference(),
- ioOpCallback, fileManager.getBaseDir().getAbsolutePath());
- ioOpCallback.scheduled(mergeOp);
- return mergeOp;
- }
-
- @Override
- public ILSMIndexAccessor createAccessor(ISearchOperationCallback searchCallback, int targetIndexVersion)
- throws HyracksDataException {
- return new LSMRTreeAccessor(getHarness(), createOpContext(searchCallback, targetIndexVersion),
- buddyBTreeFields);
- }
-
- // This method creates the appropriate opContext for the targeted version
- public ExternalRTreeOpContext createOpContext(ISearchOperationCallback searchCallback, int targetVersion) {
- return new ExternalRTreeOpContext(this, rtreeCmpFactories, btreeCmpFactories, searchCallback, targetVersion,
- getHarness(), comparatorFields, linearizerArray, rtreeLeafFrameFactory, rtreeInteriorFrameFactory,
- btreeLeafFrameFactory, tracer);
- }
-
- // The accessor for disk only indexes don't use modification callback and
- // always carry the target index version with them
- @Override
- public ILSMIndexAccessor createAccessor(IIndexAccessParameters iap) {
- return new LSMRTreeAccessor(getHarness(), createOpContext(iap.getSearchOperationCallback(), version),
- buddyBTreeFields);
- }
-
- @Override
- public int getCurrentVersion() {
- return version;
- }
-
- @Override
- public void setCurrentVersion(int version) {
- this.version = version;
- }
-
- @Override
- public List<ILSMDiskComponent> getFirstComponentList() {
- return diskComponents;
- }
-
- @Override
- public List<ILSMDiskComponent> getSecondComponentList() {
- return secondDiskComponents;
- }
-
- @Override
- public void commitTransaction() throws HyracksDataException {
- LSMComponentFileReferences componentFileRefrences = fileManager.getTransactionFileReferenceForCommit();
- ILSMDiskComponent component = null;
- if (componentFileRefrences != null) {
- component = createDiskComponent(componentFactory, componentFileRefrences.getInsertIndexFileReference(),
- componentFileRefrences.getDeleteIndexFileReference(),
- componentFileRefrences.getBloomFilterFileReference(), false);
- }
- getHarness().addTransactionComponents(component);
- }
-
- @Override
- public void abortTransaction() throws HyracksDataException {
- fileManager.deleteTransactionFiles();
- }
-
- @Override
- public void recoverTransaction() throws HyracksDataException {
- fileManager.recoverTransaction();
- }
-
- @Override
- public int getFieldCount() {
- return fieldCount;
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTreeOpContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTreeOpContext.java
deleted file mode 100644
index 9be61fc..0000000
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/ExternalRTreeOpContext.java
+++ /dev/null
@@ -1,77 +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.lsm.rtree.impls;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness;
-import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
-import org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndexOperationContext;
-import org.apache.hyracks.storage.common.ISearchOperationCallback;
-import org.apache.hyracks.storage.common.MultiComparator;
-import org.apache.hyracks.util.trace.ITracer;
-
-public class ExternalRTreeOpContext extends AbstractLSMIndexOperationContext {
- private MultiComparator bTreeCmp;
- private MultiComparator rTreeCmp;
- private final int targetIndexVersion;
- private LSMRTreeCursorInitialState initialState;
-
- public ExternalRTreeOpContext(ILSMIndex index, IBinaryComparatorFactory[] rtreeCmpFactories,
- IBinaryComparatorFactory[] btreeCmpFactories, ISearchOperationCallback searchCallback,
- int targetIndexVersion, ILSMHarness lsmHarness, int[] comparatorFields,
- IBinaryComparatorFactory[] linearizerArray, ITreeIndexFrameFactory rtreeLeafFrameFactory,
- ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory,
- ITracer tracer) {
- super(index, null, null, null, searchCallback, null, tracer);
- this.targetIndexVersion = targetIndexVersion;
- this.bTreeCmp = MultiComparator.create(btreeCmpFactories);
- this.rTreeCmp = MultiComparator.create(rtreeCmpFactories);
- initialState =
- new LSMRTreeCursorInitialState(rtreeLeafFrameFactory, rtreeInteriorFrameFactory, btreeLeafFrameFactory,
- bTreeCmp, lsmHarness, comparatorFields, linearizerArray, searchCallback, componentHolder);
- }
-
- @Override
- public void setCurrentMutableComponentId(int currentMutableComponentId) {
- // Do nothing. this should never be called for disk only indexes
- }
-
- public MultiComparator getBTreeMultiComparator() {
- return bTreeCmp;
- }
-
- public MultiComparator getRTreeMultiComparator() {
- return rTreeCmp;
- }
-
- public int getTargetIndexVersion() {
- return targetIndexVersion;
- }
-
- public LSMRTreeCursorInitialState getInitialState() {
- return initialState;
- }
-
- @Override
- public void destroy() throws HyracksDataException {
- // No Op
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
index 7afecd8e..a8a1909 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
@@ -68,7 +68,6 @@
import org.apache.hyracks.storage.common.ISearchPredicate;
import org.apache.hyracks.storage.common.IndexCursorStats;
import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.hyracks.util.trace.ITracer;
public class LSMRTree extends AbstractLSMRTree {
protected final int[] buddyBTreeFields;
@@ -95,27 +94,6 @@
this.buddyBTreeFields = buddyBTreeFields;
}
- /*
- * For External indexes with no memory components
- */
- public LSMRTree(IIOManager ioManager, ITreeIndexFrameFactory rtreeInteriorFrameFactory,
- ITreeIndexFrameFactory rtreeLeafFrameFactory, ITreeIndexFrameFactory btreeInteriorFrameFactory,
- ITreeIndexFrameFactory btreeLeafFrameFactory, IBufferCache diskBufferCache,
- ILSMIndexFileManager fileNameManager, ILSMDiskComponentFactory componentFactory,
- double bloomFilterFalsePositiveRate, IBinaryComparatorFactory[] rtreeCmpFactories,
- IBinaryComparatorFactory[] btreeCmpFactories, ILinearizeComparatorFactory linearizer,
- int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- int[] buddyBTreeFields, boolean durable, boolean isPointMBR, ITracer tracer) throws HyracksDataException {
- super(ioManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory,
- btreeLeafFrameFactory, diskBufferCache, fileNameManager, componentFactory, rtreeCmpFactories,
- btreeCmpFactories, linearizer, comparatorFields, linearizerArray, bloomFilterFalsePositiveRate,
- mergePolicy, opTracker, ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory, durable, isPointMBR,
- tracer);
- this.buddyBTreeFields = buddyBTreeFields;
- }
-
@Override
public ILSMDiskComponent doFlush(ILSMIOOperation operation) throws HyracksDataException {
LSMRTreeFlushOperation flushOp = (LSMRTreeFlushOperation) operation;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
index a436c43..4b16f4a 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
@@ -53,7 +53,6 @@
import org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper;
import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager;
import org.apache.hyracks.storage.am.lsm.common.impls.TreeIndexFactory;
-import org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree;
import org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTree;
import org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTreeDiskComponentFactory;
import org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTreeFileManager;
@@ -74,7 +73,6 @@
import org.apache.hyracks.storage.am.rtree.linearize.ZCurveIntComparatorFactory;
import org.apache.hyracks.storage.am.rtree.tuples.RTreeTypeAwareTupleWriterFactory;
import org.apache.hyracks.storage.common.buffercache.IBufferCache;
-import org.apache.hyracks.util.trace.ITracer;
public class LSMRTreeUtils {
public static LSMRTree createLSMTree(IIOManager ioManager, List<IVirtualBufferCache> virtualBufferCaches,
@@ -247,64 +245,6 @@
pageWriteCallbackFactory, rtreeFields, filterFields, durable, isPointMBR);
}
- public static ExternalRTree createExternalRTree(IIOManager ioManager, FileReference file,
- IBufferCache diskBufferCache, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] rtreeCmpFactories,
- IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories,
- RTreePolicyType rtreePolicyType, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy,
- ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler,
- ILSMIOOperationCallbackFactory ioOpCallbackFactory, ILSMPageWriteCallbackFactory pageWriteCallbackFactory,
- ILinearizeComparatorFactory linearizeCmpFactory, int[] buddyBTreeFields, boolean durable,
- boolean isPointMBR, IMetadataPageManagerFactory freePageManagerFactory, ITracer tracer,
- ITypeTraits nullTypeTraits, INullIntrospector nullIntrospector) throws HyracksDataException {
-
- int keyFieldCount = rtreeCmpFactories.length;
- int valueFieldCount = typeTraits.length - keyFieldCount;
- ITypeTraits[] btreeTypeTraits = new ITypeTraits[valueFieldCount];
- for (int i = 0; i < buddyBTreeFields.length; i++) {
- btreeTypeTraits[i] = typeTraits[buddyBTreeFields[i]];
- }
- RTreeTypeAwareTupleWriterFactory rtreeInteriorFrameTupleWriterFactory =
- new RTreeTypeAwareTupleWriterFactory(typeTraits, nullTypeTraits, nullIntrospector);
- RTreeTypeAwareTupleWriterFactory rtreeLeafFrameTupleWriterFactory = null;
- if (isPointMBR) {
- rtreeLeafFrameTupleWriterFactory = new LSMRTreeTupleWriterFactoryForPointMBR(typeTraits, keyFieldCount,
- valueFieldCount, false, false, nullTypeTraits, nullIntrospector);
- } else {
- rtreeLeafFrameTupleWriterFactory = rtreeInteriorFrameTupleWriterFactory;
- }
- BTreeTypeAwareTupleWriterFactory btreeTupleWriterFactory =
- new BTreeTypeAwareTupleWriterFactory(btreeTypeTraits, false, nullTypeTraits, nullIntrospector);
- RTreeFrameFactory rtreeInteriorFrameFactory = new RTreeNSMInteriorFrameFactory(
- rtreeInteriorFrameTupleWriterFactory, valueProviderFactories, rtreePolicyType, isPointMBR);
- RTreeFrameFactory rtreeLeafFrameFactory = new RTreeNSMLeafFrameFactory(rtreeLeafFrameTupleWriterFactory,
- valueProviderFactories, rtreePolicyType, isPointMBR);
- ITreeIndexFrameFactory btreeInteriorFrameFactory = new BTreeNSMInteriorFrameFactory(btreeTupleWriterFactory);
- ITreeIndexFrameFactory btreeLeafFrameFactory = new BTreeNSMLeafFrameFactory(btreeTupleWriterFactory);
- TreeIndexFactory<RTree> diskRTreeFactory = new RTreeFactory(ioManager, diskBufferCache, freePageManagerFactory,
- rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, typeTraits.length, isPointMBR);
- TreeIndexFactory<BTree> diskBTreeFactory = new BTreeFactory(ioManager, diskBufferCache, freePageManagerFactory,
- btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, btreeTypeTraits.length);
- int[] comparatorFields = { 0 };
- IBinaryComparatorFactory[] linearizerArray = { linearizeCmpFactory };
-
- int[] bloomFilterKeyFields = new int[btreeCmpFactories.length];
- for (int i = 0; i < btreeCmpFactories.length; i++) {
- bloomFilterKeyFields[i] = i;
- }
- BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, bloomFilterKeyFields);
-
- ILSMIndexFileManager fileNameManager =
- new LSMRTreeFileManager(ioManager, file, diskRTreeFactory, diskBTreeFactory);
- ILSMDiskComponentFactory componentFactory =
- new LSMRTreeDiskComponentFactory(diskRTreeFactory, diskBTreeFactory, bloomFilterFactory, null);
-
- return new ExternalRTree(ioManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory,
- btreeLeafFrameFactory, diskBufferCache, fileNameManager, componentFactory, bloomFilterFalsePositiveRate,
- typeTraits.length, rtreeCmpFactories, btreeCmpFactories, linearizeCmpFactory, comparatorFields,
- linearizerArray, mergePolicy, opTracker, ioScheduler, ioOpCallbackFactory, pageWriteCallbackFactory,
- buddyBTreeFields, durable, isPointMBR, tracer);
- }
-
public static ILinearizeComparatorFactory proposeBestLinearizer(ITypeTraits[] typeTraits, int numKeyFields)
throws HyracksDataException {
for (int i = 0; i < numKeyFields; i++) {