Skip to content

Instantly share code, notes, and snippets.

View predictioniogists's full-sized avatar

PredictionIO predictioniogists

View GitHub Profile
@predictioniogists
predictioniogists / parquetschema
Created April 1, 2015 23:48
Parquet schema example
$ parquet.tools.Main schema part-r-1.parquet
message root { optional binary creationTime (UTF8); optional binary entityId (UTF8); optional binary entityType (UTF8); optional binary event (UTF8); optional binary eventId (UTF8); optional binary eventTime (UTF8); optional group properties { optional binary city (UTF8); optional double rating; optional binary spend (UTF8); optional binary state (UTF8); optional binary store (UTF8); optional binary customer (UTF8) } optional binary targetEntityId (UTF8); optional binary targetEntityType (UTF8); }
@predictioniogists
predictioniogists / parquetcat
Created April 1, 2015 23:47
Parquet cat example
$ hadoop parquet.tools.Main cat part-r-1.parquet
entityId = 2 entityType = user event = $set eventId = 5iuLzCHXzzehq_R3hjsL1AAAAUvZAVo8gzcZ76dDAEs eventTime = 2015-03-02T05:41:59.484Z properties: .rating = 2.0 targetEntityId = 98 targetEntityType = item creationTime = 2015-03-04T05:29:51.278Z entityId = 1 entityType = order event = $set eventId = 78r6v2QT5GgWWrt_bD_q7wAAAUvjQvWunS1ONY2GyoM eventTime = 2015-03-04T05:29:51.278Z properties: .city = san jose .spend = 11.99 .state = CA .store = Women Apparel .customer = 1
@predictioniogists
predictioniogists / pioexport
Created April 1, 2015 23:47
pio export example
$ bin/pio export --appid 8 --output /home/exportFinal3 --format parquet
@predictioniogists
predictioniogists / newcustomer
Created April 1, 2015 23:46
Create new customer example
$ curl -i -X POST http://localhost:7070/events.json?accessKey= nE9KITDzprLR6utwUJ9a4qDhscsKsjKFlXMcMsxVEdbkQjqYRm8pFcHHDdrM6Cid -H "Content-Type: application/json" -d '{
> "event" : "$set",
> "entityType" : "customer",
> "entityId" : "1",
>
> "properties" : {
> "channel" : "email",
> “DOB” : “1/12/1970”,
> "name" : "sam dolittle"
> },
@predictioniogists
predictioniogists / neworder
Created April 1, 2015 23:46
Create new order event example
$ curl -i -X POST http://localhost:7070/events.json?accessKey=nE9KITDzprLR6utwUJ9a4qDhscsKsjKFlXMcMsxVEdbkQjqYRm8pFcHHDdrM6Cid -H "Content-Type: application/json" -d '{
> "event" : "$set",
> "entityType" : "order",
> "entityId" : "3",
>
> "properties" : {
> "spend" : "4.01",
> "city" : "san francisco",
> "state" : "CA",
> "store" : "Men Apparel"
@predictioniogists
predictioniogists / newapp
Created April 1, 2015 23:45
Creating new app example
$ pio app new ordersApp
[WARN] [NativeCodeLoader] Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[INFO] [HBLEvents] The table predictionio_eventdata:events_8 doesn't exist yet. Creating now...
[INFO] [App$] Initialized Event Store for this app ID: 8.
[INFO] [App$] Created new app:
[INFO] [App$] Name: ordersApp
[INFO] [App$] ID: 8
[INFO] [App$] Access Key: nE9KITDzprLR6utwUJ9a4qDhscsKsjKFlXMcMsxVEdbkQjqYRm8pFcHHDdrM6Cid
vagrant@vagrant-ubuntu-trusty-64:~/ $
@predictioniogists
predictioniogists / customers.json
Created April 1, 2015 23:43
A sample customer event
{
"event" : "$set",
"entityType" : "customer",
"entityId" : "<unique id>",
"properties" : {
"DOB" : "<string>",
"channel" : "<string>",
"name" : "<string>"
}
}
@predictioniogists
predictioniogists / orders.json
Created April 1, 2015 23:42
A sample order event
{
"event" : "$set",
"entityType" : "order",
"entityId" : "<unique id>",
"properties" : {
"spend" : "<val>",
"city" : "<string>",
"state" : "<string>",
"store" : "<string>",
"customer" : "<val>"
@predictioniogists
predictioniogists / query.swift
Created March 18, 2015 05:00
Querying in Swift
let engineClient = EngineClient(baseURL: "http://localhost:8000")
let query = [
"user": "16398de4-cd17-11e4-afdc-1681e6b88ec1",
"num": 5
]
engineClient.sendQuery(query) { (request, response, JSON, error) in
if let data = JSON as? [String: [[String: AnyObject]]] {
...
}
@predictioniogists
predictioniogists / MeerkatServing.scala
Created March 18, 2015 04:57
Filtering outdated video
class Serving extends LServing[Query, PredictedResult] {
override def serve(
query: Query,
predictedResults: Seq[PredictedResult]): PredictedResult = {
predictedResults.filterNot { video.over }
}
}