Skip to content

Instantly share code, notes, and snippets.

@umit
umit / mongodb_data.js
Created May 13, 2012 09:45
MongoDB Örnek Data
> db.product.find().pretty()
{
"_id" : ObjectId("4faec33dd57e4ace158b7e9f"),
"type" : "Shirt",
"color" : "Green",
"sizes" : {
"L" : 2,
"XL" : 3,
"XXL" : 4
},
@umit
umit / gist:2687602
Created May 13, 2012 10:19
MongoDB Product MapReduce 1
map = function map(){
//key olarak product type
//value olarak ise obje icinde product price alanına gore mapliyoruz
emit(this.type, {price:this.price} );
}
reduce = function reduce(key,values) {
var result = { sumProductPrice: 0 };
values.forEach(function(value) {
@umit
umit / gist:2687758
Created May 13, 2012 10:54
MongoDB Product MapReduce 2
map = function map(){
var size;
for (size in this.sizes) {
emit(size, this.sizes[size]);
}
};
reduce = function reduce(key,values){
var result = { count: 0 };
@umit
umit / gist:2687931
Created May 13, 2012 11:26
MongoDB Product MapReduce 3
map = function(){
var size;
for (size in this.sizes) {
emit(size, {size: this.sizes[size], price: this.sizes[size] * this.price });
}
};
reduce = function reduce(key,values){
var result = { sizeCount: 0, priceCount: 0 };
@umit
umit / gist:2687992
Created May 13, 2012 11:42
MongoDB Product MapReduce 4
map = function map() {
emit(this.type, {productIds : [this._id]})
}
reduce = function reduce(key, values) {
var productIds = [];
var result = { productIds:[] };
values.forEach(function(value) {
map = function map() {
emit(this.type, {productColor :[this.color]});
}
reduce = function reduce(key, values) {
var colors = [];
var results = { colors:[] };
values.forEach(function(value){
@umit
umit / gist:2688182
Created May 13, 2012 12:24
MongoDB Product MapReduce 5
map = function map() {
emit(this.type, {productColors :[this.color]});
}
reduce = function reduce(key, values) {
var colors = [];
var results = { colors:[] };
values.forEach(function(value){
@umit
umit / pom.xml
Created June 21, 2012 19:03
Spring & Hazelcast maven
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Spring Framework -->
<spring-framework.version>3.1.1.RELEASE</spring-framework.version>
<!-- Hazelcast -->
<hazelcast.version>2.0.2</hazelcast.version>
</properties>
<dependencies>
@umit
umit / applicationContext-Hazelcast.xml
Created June 21, 2012 19:20
applicationContext-Hazelcast.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.hazelcast.com/schema/spring
@umit
umit / HazelcastInstanceTest.java
Created June 23, 2012 14:22
HazelcastInstanceTest
package com.umitunal.hazelcast;
import static org.junit.Assert.*;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;