added classes which should have been added previous commit.
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@1921 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/AbstractIndexLocalResourceClass.java b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/AbstractIndexLocalResourceClass.java
new file mode 100644
index 0000000..1ec3548
--- /dev/null
+++ b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/AbstractIndexLocalResourceClass.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2009-2012 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.hyracks.storage.common.file;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public abstract class AbstractIndexLocalResourceClass implements ILocalResourceClass {
+
+ @Override
+ public byte[] serialize(ILocalResource resource) throws HyracksDataException {
+ ByteArrayOutputStream baos = null;
+ ObjectOutputStream oosToBaos = null;
+
+ try {
+ baos = new ByteArrayOutputStream();
+ oosToBaos = new ObjectOutputStream(baos);
+ oosToBaos.writeLong(resource.getResourceId());
+ oosToBaos.writeUTF(resource.getResourceName());
+ oosToBaos.writeObject(resource.getResourceObject());
+ return baos.toByteArray();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ } finally {
+ if (oosToBaos != null) {
+ try {
+ oosToBaos.close();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+
+ if (oosToBaos == null && baos != null) {
+ try {
+ baos.close();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public ILocalResource deserialize(byte[] bytes) throws HyracksDataException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream oisFromBais = null;
+ try {
+ oisFromBais = new ObjectInputStream(bais);
+ return new IndexLocalResource(oisFromBais.readLong(), oisFromBais.readUTF(), oisFromBais.readObject(), this);
+ } catch (Exception e) {
+ throw new HyracksDataException(e);
+ } finally {
+ if (oisFromBais != null) {
+ try {
+ oisFromBais.close();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ if (oisFromBais == null && bais != null) {
+ try {
+ bais.close();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ }
+ }
+
+ public abstract int getResourceClassId();
+}
diff --git a/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/IndexLocalResource.java b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/IndexLocalResource.java
new file mode 100644
index 0000000..b5babd5
--- /dev/null
+++ b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/IndexLocalResource.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009-2012 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.hyracks.storage.common.file;
+
+public class IndexLocalResource implements ILocalResource {
+ private static final long serialVersionUID = -8638308062094620884L;
+ private final long resourceId;
+ private final String resourceName;
+ private final Object object;
+ private final ILocalResourceClass resourceClass;
+
+ public IndexLocalResource(long resourceId, String resourceName, Object object, ILocalResourceClass resourceClass) {
+ this.resourceId = resourceId;
+ this.resourceName = resourceName;
+ this.object = object;
+ this.resourceClass = resourceClass;
+ }
+
+ @Override
+ public long getResourceId() {
+ return resourceId;
+ }
+
+ @Override
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ @Override
+ public Object getResourceObject() {
+ return object;
+ }
+
+ @Override
+ public ILocalResourceClass getResourceClass() {
+ return resourceClass;
+ }
+
+}
diff --git a/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMInvertedIndexLocalResourceClass.java b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMInvertedIndexLocalResourceClass.java
new file mode 100644
index 0000000..866cac5
--- /dev/null
+++ b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMInvertedIndexLocalResourceClass.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009-2012 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.hyracks.storage.common.file;
+
+public class LSMInvertedIndexLocalResourceClass extends AbstractIndexLocalResourceClass {
+ private static LSMInvertedIndexLocalResourceClass instance = new LSMInvertedIndexLocalResourceClass();
+
+ public static LSMInvertedIndexLocalResourceClass getInstance() {
+ return instance;
+ }
+
+ @Override
+ public int getResourceClassId() {
+ return ILocalResourceClass.LSMInvertedIndex;
+ }
+}
diff --git a/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMRTreeLocalResourceClass.java b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMRTreeLocalResourceClass.java
new file mode 100644
index 0000000..e78f087
--- /dev/null
+++ b/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/file/LSMRTreeLocalResourceClass.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009-2012 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.hyracks.storage.common.file;
+
+public class LSMRTreeLocalResourceClass extends AbstractIndexLocalResourceClass {
+ private static LSMRTreeLocalResourceClass instance = new LSMRTreeLocalResourceClass();
+
+ public static LSMRTreeLocalResourceClass getInstance() {
+ return instance;
+ }
+
+ @Override
+ public int getResourceClassId() {
+ return ILocalResourceClass.LSMRTree;
+ }
+}