Wednesday, March 25, 2015

JPA 2.0 Map Relationships

I need a refreshment of JPA 2.0 support for Maps as I don't run into these type of relationships very often.  The last time I went beyond Sets and Lists was when testing the Metamodel spec in 2010.

The model used consists of a base subclass of a MappedSuperclass that has a unidirectional Map relationship keyed by Key entity to a map of Target entity values.


@MappedSuperclass
public class BaseAbstract {

@Id
@Column(name="base_id")
private Long ident;

public Long getIdent() {
return ident;
}

public void setIdent(Long ident) {
this.ident = ident;
}

}

@Entity
public class Base extends BaseAbstract {
@ManyToMany
private Map<Key, Target> targetMap;

public Map<Key, Target> getTargetMap() {
return targetMap;
}

public void setTargetMap(Map<Key, Target> targetMap) {
this.targetMap = targetMap;
}

}

@Entity
public class Key {

@Id
@Column(name="key_id")
private Long ident;
}

@Entity
public class Target {

@Id
@Column(name="target_id")
private Long ident;
}

DDL results

Hibernate: create table Base (base_id bigint not null, primary key (base_id)) type=InnoDB
Hibernate: create table Base_Target (Base_base_id bigint not null, targetMap_target_id bigint not null, targetMap_KEY bigint not null, primary key (Base_base_id, targetMap_KEY)) type=InnoDB
Hibernate: create table Key (key_id bigint not null, primary key (key_id)) type=InnoDB
Hibernate: create table Target (target_id bigint not null, primary key (target_id)) type=InnoDB
Hibernate: alter table Base_Target add index FKBFB1DEBFB32A10B2 (targetMap_KEY), add constraint FKBFB1DEBFB32A10B2 foreign key (targetMap_KEY) references Key (key_id)
Hibernate: alter table Base_Target add index FKBFB1DEBF8408A9FE (targetMap_target_id), add constraint FKBFB1DEBF8408A9FE foreign key (targetMap_target_id) references Target (target_id)
Hibernate: alter table Base_Target add index FKBFB1DEBF1B8E4DA4 (Base_base_id), add constraint FKBFB1DEBF1B8E4DA4 foreign key (Base_base_id) references Base (base_id)
Hibernate: alter table Base_Target drop foreign key FKBFB1DEBFB32A10B2
Hibernate: alter table Base_Target drop foreign key FKBFB1DEBF8408A9FE
Hibernate: alter table Base_Target drop foreign key FKBFB1DEBF1B8E4DA4

Sorry EclipseLink but Hibernate is used in almost all projects not directly running on WebLogic or the RI version of GlassFish.

Saturday, March 21, 2015

Haswell Intel i7 5820K Overclock PC Build

In progress...
    Even though I have a recent love affair with Apple since 2011 - especially with their top of the line MacBook Pro 15 inch 2.6 GHz 4960HQ - I still need more parallel processing muscle.  Amazon offers the 18 core xeon C4-8xLarge at a spot price of $0.28 for pure Java console processing jobs - but a real physical machine is good for Oculus Rift for example.

    I have decided not to buy anymore commercial machines with low end parts and build them myself.  This article is a summary of my first build.

    Parts: I am leaning towards Asus, Corsair and Samsung parts.

    Intel Haswell i7-5820K

    Corsair liquid cooler
    Corsair case
    Corsair power supply
    Corsair Vengeance LPX 32GB 2 x (4x8GB) DDR4 2666MHz CL16 Quad-Channel
    Asus X99 motherboard
    Intel SSD
    Samsung SSD

A Flir heatmap of the i7 5820, the DDR4 ram and the first GTX-970 before I added the 2nd Asus Strix card

The case after running both GTX-970 cards under load


Corsair case with 32G Corsair DDR4, i7-5820K, Corsair 100 cooler, Corsair 860i PSU and 2 Asus Strix GTX-970 in SLI

    Details:
    The top i7-5960X is just too expensive at this point - with the recent drop in oil it comes out to almost $1500 just for the chip.  If you don't mind a 100MHz drop and don't plan on running 3 GPU cards then the 5820 can be substituted for the 5930 at a savings of $300

I accidentally scratched off about 5% of the factory paste.  I went ahead anyway instead of redoing it with a rice ball sized drop.  This may be why a couple of my six cores show a 10 degree difference under load.


    Dual ASUS Strix GTX-970 cards in SLI
I know that the 5820 because it only has 28 PCIx lanes - supports an SLI config of 16x/8x instead of 16x/16x.  However until I get $1500 to get a 5960X - I will run one of the cards at 8x.
Interesting that my 2nd card purchased about 2 weeks later from the same supplier has a flipped Strix logo plate - I don't know which is the right orientation.  Adding the 2nd Strix GTX-970 was pretty easy in the large Corsair case.  Running the dual GPU's ups the wattage from an idle of 240W to 505W under 17% CPU load.  Note: running the CPU at 100% as well pushed the box to 700W which is pushing my 860W Corsair PSU.
The Flir heatmap of the two SLI GTX-970 cards with their inverted logos


    Results:
    After conservative overclocking to 4.2GHz using a 125MHz base clock from 100 and a 33x multiplier I see a 50% speed increase over my fastest Mac i7-4960

My Oculus Rift headset runs fine on this 5820 machine - it ran fine on my MacBook Pro 4960 as well as my Asus ROG 3610.

Need to run faster than 4.1GHz
http://www.overclockers.com/forums/showthread.php/754365-Asus-X99-A-CPU-voltage-settings-need-an-experienced-user

Intel 750 NVMe to 4 x 256G Samsung 850pro raid0 runs at 8Gbps

Total Pageviews

Followers