Skip to content
Permalink
Browse files
Update Tuple Translator signatures for BAD entities
Change-Id: I7ea03321200cde532b6c1687072340197945b56b
  • Loading branch information
amoudi87 committed Apr 15, 2017
1 parent 7a95005 commit 3b20a63c61d03eb07f648950371ed75ddeceb07b
Showing 3 changed files with 33 additions and 32 deletions.
@@ -18,14 +18,14 @@
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;

import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
import org.apache.asterix.metadata.MetadataException;
import org.apache.asterix.metadata.entitytupletranslators.AbstractTupleTranslator;
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;

/**
@@ -43,16 +43,15 @@ public class BrokerTupleTranslator extends AbstractTupleTranslator<Broker> {

@SuppressWarnings("unchecked")
private ISerializerDeserializer<ARecord> recordSerDes =
SerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BADMetadataRecordTypes.BROKER_RECORDTYPE);
SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BADMetadataRecordTypes.BROKER_RECORDTYPE);

@SuppressWarnings("unchecked")
public BrokerTupleTranslator(boolean getTuple) {
super(getTuple, BADMetadataIndexes.NUM_FIELDS_BROKER_IDX);
}

@Override
public Broker getMetadataEntityFromTuple(ITupleReference frameTuple) throws IOException {
public Broker getMetadataEntityFromTuple(ITupleReference frameTuple) throws HyracksDataException {
byte[] serRecord = frameTuple.getFieldData(BROKER_PAYLOAD_TUPLE_FIELD_INDEX);
int recordStartOffset = frameTuple.getFieldStart(BROKER_PAYLOAD_TUPLE_FIELD_INDEX);
int recordLength = frameTuple.getFieldLength(BROKER_PAYLOAD_TUPLE_FIELD_INDEX);
@@ -64,10 +63,11 @@ public Broker getMetadataEntityFromTuple(ITupleReference frameTuple) throws IOEx

private Broker createBrokerFromARecord(ARecord brokerRecord) {
Broker broker = null;
String dataverseName = ((AString) brokerRecord
.getValueByPos(BADMetadataRecordTypes.BROKER_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
String brokerName = ((AString) brokerRecord.getValueByPos(BADMetadataRecordTypes.BROKER_NAME_FIELD_INDEX))
.getStringValue();
String dataverseName =
((AString) brokerRecord.getValueByPos(BADMetadataRecordTypes.BROKER_DATAVERSE_NAME_FIELD_INDEX))
.getStringValue();
String brokerName =
((AString) brokerRecord.getValueByPos(BADMetadataRecordTypes.BROKER_NAME_FIELD_INDEX)).getStringValue();
String endPointName = ((AString) brokerRecord.getValueByPos(BADMetadataRecordTypes.BROKER_ENDPOINT_FIELD_INDEX))
.getStringValue();

@@ -76,7 +76,7 @@ private Broker createBrokerFromARecord(ARecord brokerRecord) {
}

@Override
public ITupleReference getTupleFromMetadataEntity(Broker broker) throws IOException, MetadataException {
public ITupleReference getTupleFromMetadataEntity(Broker broker) throws HyracksDataException, MetadataException {
// write the key in the first fields of the tuple

tupleBuilder.reset();
@@ -18,7 +18,6 @@
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;

import org.apache.asterix.common.functions.FunctionSignature;
import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
@@ -27,6 +26,7 @@
import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.AString;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;

/**
@@ -52,7 +52,7 @@ public ChannelTupleTranslator(boolean getTuple) {
}

@Override
public Channel getMetadataEntityFromTuple(ITupleReference frameTuple) throws IOException {
public Channel getMetadataEntityFromTuple(ITupleReference frameTuple) throws HyracksDataException {
byte[] serRecord = frameTuple.getFieldData(CHANNEL_PAYLOAD_TUPLE_FIELD_INDEX);
int recordStartOffset = frameTuple.getFieldStart(CHANNEL_PAYLOAD_TUPLE_FIELD_INDEX);
int recordLength = frameTuple.getFieldLength(CHANNEL_PAYLOAD_TUPLE_FIELD_INDEX);
@@ -66,16 +66,20 @@ private Channel createChannelFromARecord(ARecord channelRecord) {
Channel channel = null;
String dataverseName = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_DATAVERSE_NAME_FIELD_INDEX)).getStringValue();
String channelName = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_CHANNEL_NAME_FIELD_INDEX)).getStringValue();
String channelName =
((AString) channelRecord.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_CHANNEL_NAME_FIELD_INDEX))
.getStringValue();
String subscriptionsName = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_SUBSCRIPTIONS_NAME_FIELD_INDEX)).getStringValue();
String resultsName = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_RESULTS_NAME_FIELD_INDEX)).getStringValue();
String fName = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_FUNCTION_FIELD_INDEX)).getStringValue();
String duration = ((AString) channelRecord
.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_DURATION_FIELD_INDEX)).getStringValue();
String resultsName =
((AString) channelRecord.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_RESULTS_NAME_FIELD_INDEX))
.getStringValue();
String fName =
((AString) channelRecord.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_FUNCTION_FIELD_INDEX))
.getStringValue();
String duration =
((AString) channelRecord.getValueByPos(BADMetadataRecordTypes.CHANNEL_ARECORD_DURATION_FIELD_INDEX))
.getStringValue();

FunctionSignature signature = null;

@@ -98,7 +102,7 @@ private Channel createChannelFromARecord(ARecord channelRecord) {
}

@Override
public ITupleReference getTupleFromMetadataEntity(Channel channel) throws IOException, MetadataException {
public ITupleReference getTupleFromMetadataEntity(Channel channel) throws HyracksDataException, MetadataException {
// write the key in the first fields of the tuple

tupleBuilder.reset();
@@ -22,7 +22,6 @@
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@@ -36,6 +35,7 @@
import org.apache.asterix.om.base.IACursor;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;

@@ -63,7 +63,7 @@ protected ProcedureTupleTranslator(boolean getTuple) {
}

@Override
public Procedure getMetadataEntityFromTuple(ITupleReference frameTuple) throws IOException {
public Procedure getMetadataEntityFromTuple(ITupleReference frameTuple) throws HyracksDataException {
byte[] serRecord = frameTuple.getFieldData(PROCEDURE_PAYLOAD_TUPLE_FIELD_INDEX);
int recordStartOffset = frameTuple.getFieldStart(PROCEDURE_PAYLOAD_TUPLE_FIELD_INDEX);
int recordLength = frameTuple.getFieldLength(PROCEDURE_PAYLOAD_TUPLE_FIELD_INDEX);
@@ -74,20 +74,16 @@ public Procedure getMetadataEntityFromTuple(ITupleReference frameTuple) throws I
}

private Procedure createProcedureFromARecord(ARecord procedureRecord) {
String dataverseName =
((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_DATAVERSENAME_FIELD_INDEX))
.getStringValue();
String procedureName =
((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_NAME_FIELD_INDEX))
.getStringValue();
String dataverseName = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
String procedureName = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_NAME_FIELD_INDEX)).getStringValue();
String arity = ((AString) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_ARITY_FIELD_INDEX)).getStringValue();

IACursor cursor = ((AOrderedList) procedureRecord
.getValueByPos(BADMetadataRecordTypes.PROCEDURE_ARECORD_PROCEDURE_PARAM_LIST_FIELD_INDEX)).getCursor();
List<String> params = new ArrayList<String>();
List<String> params = new ArrayList<>();
while (cursor.next()) {
params.add(((AString) cursor.get()).getStringValue());
}
@@ -114,7 +110,8 @@ private Procedure createProcedureFromARecord(ARecord procedureRecord) {
}

@Override
public ITupleReference getTupleFromMetadataEntity(Procedure procedure) throws IOException, MetadataException {
public ITupleReference getTupleFromMetadataEntity(Procedure procedure)
throws HyracksDataException, MetadataException {
// write the key in the first 2 fields of the tuple
tupleBuilder.reset();
aString.setValue(procedure.getEntityId().getDataverse());

0 comments on commit 3b20a63

Please sign in to comment.