Search in sources :

Example 1 with IMetadataIndex

use of org.apache.asterix.metadata.api.IMetadataIndex in project asterixdb by apache.

the class MetadataNode method printMetadata.

// Debugging Method
public String printMetadata() {
    StringBuilder sb = new StringBuilder();
    try {
        IMetadataIndex index = MetadataPrimaryIndexes.DATAVERSE_DATASET;
        String resourceName = index.getFile().toString();
        IIndex indexInstance = datasetLifecycleManager.get(resourceName);
        datasetLifecycleManager.open(resourceName);
        IIndexAccessor indexAccessor = indexInstance.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        ITreeIndexCursor rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false);
        RangePredicate rangePred = null;
        rangePred = new RangePredicate(null, null, true, true, null, null);
        indexAccessor.search(rangeCursor, rangePred);
        try {
            while (rangeCursor.hasNext()) {
                rangeCursor.next();
                sb.append(TupleUtils.printTuple(rangeCursor.getTuple(), new ISerializerDeserializer[] { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) }));
            }
        } finally {
            rangeCursor.close();
        }
        datasetLifecycleManager.close(resourceName);
        index = MetadataPrimaryIndexes.DATASET_DATASET;
        indexInstance = datasetLifecycleManager.get(resourceName);
        datasetLifecycleManager.open(resourceName);
        indexAccessor = indexInstance.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false);
        rangePred = null;
        rangePred = new RangePredicate(null, null, true, true, null, null);
        indexAccessor.search(rangeCursor, rangePred);
        try {
            while (rangeCursor.hasNext()) {
                rangeCursor.next();
                sb.append(TupleUtils.printTuple(rangeCursor.getTuple(), new ISerializerDeserializer[] { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING), SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) }));
            }
        } finally {
            rangeCursor.close();
        }
        datasetLifecycleManager.close(resourceName);
        index = MetadataPrimaryIndexes.INDEX_DATASET;
        indexInstance = datasetLifecycleManager.get(resourceName);
        datasetLifecycleManager.open(resourceName);
        indexAccessor = indexInstance.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
        rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false);
        rangePred = null;
        rangePred = new RangePredicate(null, null, true, true, null, null);
        indexAccessor.search(rangeCursor, rangePred);
        try {
            while (rangeCursor.hasNext()) {
                rangeCursor.next();
                sb.append(TupleUtils.printTuple(rangeCursor.getTuple(), new ISerializerDeserializer[] { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING), SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING), SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) }));
            }
        } finally {
            rangeCursor.close();
        }
        datasetLifecycleManager.close(resourceName);
    } catch (Exception e) {
        // Debugging method
        e.printStackTrace();
    }
    return sb.toString();
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) ITreeIndexCursor(org.apache.hyracks.storage.am.common.api.ITreeIndexCursor) RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) IMetadataIndex(org.apache.asterix.metadata.api.IMetadataIndex) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) IIndexAccessor(org.apache.hyracks.storage.common.IIndexAccessor) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) ACIDException(org.apache.asterix.common.exceptions.ACIDException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) RemoteException(java.rmi.RemoteException)

Aggregations

RemoteException (java.rmi.RemoteException)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1 IMetadataIndex (org.apache.asterix.metadata.api.IMetadataIndex)1 AMutableString (org.apache.asterix.om.base.AMutableString)1 AString (org.apache.asterix.om.base.AString)1 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)1 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)1 IIndex (org.apache.hyracks.storage.common.IIndex)1 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)1