blob: 976bd87068d77faeb9fbb0a455221fd1efd6e0b4 [file] [log] [blame]
/*
* Copyright 2009-2010 by The Regents of the University of California
* Licensed 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 from
*
* 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 edu.uci.ics.asterix.metadata.entities;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.metadata.IDatasetDetails;
import edu.uci.ics.asterix.metadata.MetadataCache;
import edu.uci.ics.asterix.metadata.api.IMetadataEntity;
/**
* Metadata describing a dataset.
*/
public class Dataset implements IMetadataEntity {
private static final long serialVersionUID = 1L;
private final String dataverseName;
// Enforced to be unique within a dataverse.
private final String datasetName;
// Type of items stored in this dataset.
private final String itemTypeName;
private final DatasetType datasetType;
private IDatasetDetails datasetDetails;
public Dataset(String dataverseName, String datasetName, String itemTypeName, IDatasetDetails datasetDetails,
DatasetType datasetType) {
this.dataverseName = dataverseName;
this.datasetName = datasetName;
this.itemTypeName = itemTypeName;
this.datasetType = datasetType;
this.datasetDetails = datasetDetails;
}
public String getDataverseName() {
return dataverseName;
}
public String getDatasetName() {
return datasetName;
}
public String getItemTypeName() {
return itemTypeName;
}
public DatasetType getDatasetType() {
return datasetType;
}
public IDatasetDetails getDatasetDetails() {
return datasetDetails;
}
public void setDatasetDetails(IDatasetDetails datasetDetails) {
this.datasetDetails = datasetDetails;
}
@Override
public Object addToCache(MetadataCache cache) {
return cache.addDatasetIfNotExists(this);
}
@Override
public Object dropFromCache(MetadataCache cache) {
return cache.dropDataset(this);
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Dataset)) {
return false;
}
Dataset otherDataset = (Dataset) other;
if (!otherDataset.dataverseName.equals(dataverseName)) {
return false;
}
if (!otherDataset.datasetName.equals(datasetName)) {
return false;
}
return true;
}
}