diff --git a/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/Field.java b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/Field.java new file mode 100644 index 000000000..a3be6313f --- /dev/null +++ b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/Field.java @@ -0,0 +1,66 @@ +/* + * + * ****************************************************************************** + * * + * * This program and the accompanying materials are made available under the + * * terms of the Apache License, Version 2.0 which is available at + * * https://www.apache.org/licenses/LICENSE-2.0. + * * + * * See the NOTICE file distributed with this work for additional + * * information regarding copyright ownership. + * * 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. + * * + * * SPDX-License-Identifier: Apache-2.0 + * ***************************************************************************** + * + */ + +package net.brutex.cavis.dvec.api; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import net.brutex.cavis.dvec.api.exceptions.DVecException; + +/** + * Abtract implementation of the Field interface {@see FieldInterface}, that handles all data storage + * in memory and adds basic error handling. + * + * @author Brian Rosenberger + * @since 1.0 + */ +public abstract class Field implements FieldInterface { + + /** + * {@inheritDoc} + * + * @param start Index of starting position, zero based + * @param length how many fields to read + * @return the list of Buffer + */ + @Override + public T read(long start, long length) throws DVecException { + if (start<0 || start>internalStorage.capacity()-1 ) { + throw new DVecException("Read on Field start position is out of bounds."); + } + if (start+length> internalStorage.capacity()) { + throw new DVecException("Read on Field exceeds field length"); + } + return null; + } + + @Override + public void write(long pos, T buffer) { + + } + + private ByteBuffer internalStorage = null; + + + +} diff --git a/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/FieldMetadata.java b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/FieldMetadata.java new file mode 100644 index 000000000..9dcd12cdf --- /dev/null +++ b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/FieldMetadata.java @@ -0,0 +1,31 @@ +/* + * + * ****************************************************************************** + * * + * * This program and the accompanying materials are made available under the + * * terms of the Apache License, Version 2.0 which is available at + * * https://www.apache.org/licenses/LICENSE-2.0. + * * + * * See the NOTICE file distributed with this work for additional + * * information regarding copyright ownership. + * * 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. + * * + * * SPDX-License-Identifier: Apache-2.0 + * ***************************************************************************** + * + */ + +package net.brutex.cavis.dvec.api; + +/** + * tbd. + * @author Brian Rosenberger + * + */ +public interface FieldMetadata { + +} diff --git a/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/exceptions/DVecException.java b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/exceptions/DVecException.java new file mode 100644 index 000000000..e1eb4ec28 --- /dev/null +++ b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/exceptions/DVecException.java @@ -0,0 +1,32 @@ +/* + * + * ****************************************************************************** + * * + * * This program and the accompanying materials are made available under the + * * terms of the Apache License, Version 2.0 which is available at + * * https://www.apache.org/licenses/LICENSE-2.0. + * * + * * See the NOTICE file distributed with this work for additional + * * information regarding copyright ownership. + * * 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. + * * + * * SPDX-License-Identifier: Apache-2.0 + * ***************************************************************************** + * + */ + +package net.brutex.cavis.dvec.api.exceptions; + +import lombok.Getter; + +public class DVecException extends Exception { + + @Getter private final String message; + public DVecException(String message) { + this.message = message; + } +} diff --git a/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/package-info.java b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/package-info.java new file mode 100644 index 000000000..190b22052 --- /dev/null +++ b/cavis-datavec/dvec-api/src/main/java/net/brutex/cavis/dvec/api/package-info.java @@ -0,0 +1,35 @@ +/* + * + * ****************************************************************************** + * * + * * This program and the accompanying materials are made available under the + * * terms of the Apache License, Version 2.0 which is available at + * * https://www.apache.org/licenses/LICENSE-2.0. + * * + * * See the NOTICE file distributed with this work for additional + * * information regarding copyright ownership. + * * 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. + * * + * * SPDX-License-Identifier: Apache-2.0 + * ***************************************************************************** + * + */ + +/** + *

+ * The data vectorization api (dvec-api) defines a data structure in analogy to Hadoop and is + * derived from the dl4j datavec library.
The main concept is around + *

+ * + * + * @author Brian Rosenberger <bru@brutex.de> + */ +package net.brutex.cavis.dvec.api; \ No newline at end of file