Examples of IndexedRecord


Examples of javax.resource.cci.IndexedRecord

    /**
     * {@inheritDoc}
     */
    @Override
    public void mapFrom(IndexedRecordBindingData source, Context context) throws Exception {
        IndexedRecord record = source.getRecord();
        String recordName = record.getRecordName();
        if (recordName != null) {
            context.setProperty(JCAConstants.CCI_RECORD_NAME_KEY, recordName).addLabels(INDEXED_RECORD_LABELS);
        }
        String recordDescription = record.getRecordShortDescription();
        if (recordDescription != null) {
            context.setProperty(JCAConstants.CCI_RECORD_SHORT_DESC_KEY, recordDescription).addLabels(INDEXED_RECORD_LABELS);
        }
    }
View Full Code Here

Examples of javax.resource.cci.IndexedRecord

     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    @Override
    public void mapTo(Context context, IndexedRecordBindingData target) throws Exception {
        IndexedRecord record = target.getRecord();
        for (Property property : context.getProperties()) {
            String name = property.getName();
            Object value = property.getValue();
            if (value == null) {
                continue;
            }
            if (name.equals(JCAConstants.CCI_RECORD_NAME_KEY)) {
                record.setRecordName(value.toString());
            } else if (name.equals(JCAConstants.CCI_RECORD_SHORT_DESC_KEY)) {
                record.setRecordShortDescription(value.toString());
            } else if (matches(name)) {
                record.add(name + "=" + value);
            }
        }
    }
View Full Code Here

Examples of javax.resource.cci.IndexedRecord

        _composer = getMessageComposer(IndexedRecordBindingData.class);
    }
   
    @Override
    public Message handle(Exchange exchange, Connection conn, Interaction interact) throws Exception {
        IndexedRecord record = getRecordFactory().createIndexedRecord(IndexedRecordHandler.class.getName());
        IndexedRecord outRecord = (IndexedRecord) interact.execute(getInteractionSpec(), getMessageComposer(IndexedRecordBindingData.class).decompose(exchange, new IndexedRecordBindingData(record)).getRecord());
        return _composer.compose(new IndexedRecordBindingData(outRecord), exchange);
    }
View Full Code Here

Examples of javax.resource.cci.IndexedRecord

  @Test
  public void testCreateIndexedRecord() throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    IndexedRecord indexedRecord = mock(IndexedRecord.class);
    given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(recordFactory.createIndexedRecord("name")).willReturn(indexedRecord);

    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.createIndexedRecord("name");
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

  }

  public static class AvroIndexedRecordPartitioner extends Partitioner<Object, Object> {
    @Override
    public int getPartition(Object key, Object value, int numPartitions) {
      IndexedRecord record;
      if (key instanceof AvroWrapper) {
        record = (IndexedRecord) ((AvroWrapper) key).datum();
      } else if (key instanceof IndexedRecord) {
        record = (IndexedRecord) key;
      } else {
        throw new UnsupportedOperationException("Unknown avro key type: " + key);
      }
      return (Math.abs(record.get(0).hashCode()) & Integer.MAX_VALUE) % numPartitions;
    }
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

    avroPartitioner = new AvroIndexedRecordPartitioner();
  }

  @Test
  public void testGetPartition() {
    IndexedRecord indexedRecord = new MockIndexedRecord(3);
    AvroKey<IndexedRecord> avroKey = new AvroKey<IndexedRecord>(indexedRecord);

    assertEquals(3, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 5));
    assertEquals(1, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 2));
  }
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

    assertEquals(1, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 2));
  }

  @Test
  public void testGetPartition_NegativeHashValue() {
    IndexedRecord indexedRecord = new MockIndexedRecord(-3);
    AvroKey<IndexedRecord> avroKey = new AvroKey<IndexedRecord>(indexedRecord);

    assertEquals(0, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 5));
    assertEquals(1, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 2));
  }
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

    assertEquals(1, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), 2));
  }

  @Test
  public void testGetPartition_IntegerMinValue() {
    IndexedRecord indexedRecord = new MockIndexedRecord(Integer.MIN_VALUE);
    AvroKey<IndexedRecord> avroKey = new AvroKey<IndexedRecord>(indexedRecord);

    assertEquals(0, avroPartitioner.getPartition(avroKey, new AvroValue<Object>(), Integer.MAX_VALUE));
  }
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

  }

  public static class AvroIndexedRecordPartitioner extends Partitioner<Object, Object> {
    @Override
    public int getPartition(Object key, Object value, int numPartitions) {
      IndexedRecord record;
      if (key instanceof AvroWrapper) {
        record = (IndexedRecord) ((AvroWrapper) key).datum();
      } else if (key instanceof IndexedRecord) {
        record = (IndexedRecord) key;
      } else {
        throw new UnsupportedOperationException("Unknown avro key type: " + key);
      }
      return (record.get(0).hashCode() & Integer.MAX_VALUE) % numPartitions;
    }
View Full Code Here

Examples of org.apache.avro.generic.IndexedRecord

  }

  public static class AvroIndexedRecordPartitioner extends Partitioner<Object, Object> {
    @Override
    public int getPartition(Object key, Object value, int numPartitions) {
      IndexedRecord record;
      if (key instanceof AvroWrapper) {
        record = (IndexedRecord) ((AvroWrapper) key).datum();
      } else if (key instanceof IndexedRecord) {
        record = (IndexedRecord) key;
      } else {
        throw new UnsupportedOperationException("Unknown avro key type: " + key);
      }
      return (Math.abs(record.get(0).hashCode()) & Integer.MAX_VALUE) % numPartitions;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.