use of edu.uci.ics.texera.api.field.IDField in project textdb by TextDB.
the class DataWriter method insertTuple.
public IDField insertTuple(Tuple tuple) throws StorageException {
if (!isOpen) {
throw new StorageException(ErrorMessages.OPERATOR_NOT_OPENED);
}
try {
// tuple must not contain _id field
if (tuple.getSchema().containsAttribute(SchemaConstants._ID)) {
throw new StorageException("Tuple must not contain _id field. _id must be generated by the system");
}
// generate a random ID for this tuple
IDField idField = new IDField(UUID.randomUUID().toString());
Tuple tupleWithID = getTupleWithID(tuple, idField);
// make sure the tuple's schema agrees with the table's schema
if (!tupleWithID.getSchema().equals(this.schema)) {
throw new StorageException("Tuple's schema is not the same as the table's schema");
}
Document document = getLuceneDocument(tupleWithID);
this.luceneIndexWriter.addDocument(document);
this.dataStore.incrementNumDocuments(1);
return idField;
} catch (IOException e) {
close();
throw new StorageException(e.getMessage(), e);
}
}
Aggregations