메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.


PREFIX ref: <http://purl.org/vocab/relationship/>
PREFIX ic: <http://imi.ipa.go.jp/ns/core/210#>
prefix swrlb: <http://www.w3.org/2003/11/swrlb#>
prefix protege: <http://protege.stanford.edu/plugins/owl/protege#>
prefix ssn: <http://purl.oclc.org/NET/ssnx/ssn#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix icbms: <http://www.gooper.com/campus/>
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix j.0: <http://data.qudt.org/qudt/owl/1.0.0/text/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsp: <http://www.owl-ontologies.com/2005/08/07/xsp.owl#>
prefix swrl: <http://www.w3.org/2003/11/swrl#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix DUL: <http://www.loa-cnr.it/ontologies/DUL.owl#>
prefix m2m: <http://www.gooper.com/m2m/>
prefix cc: <http://creativecommons.org/ns#>
prefix p1: <http://purl.org/dc/elements/1.1/#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix qudt: <http://data.nasa.gov/qudt/owl/qudt#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix xsp: <http://www.owl-ontologies.com/2005/08/07/xsp.owl#>
prefix quantity: <http://data.nasa.gov/qudt/owl/quantity#>
prefix dct: <http://purl.org/dc/terms/>
prefix unit: <http://data.nasa.gov/qudt/owl/unit#>
prefix dim: <http://data.nasa.gov/qudt/owl/dimension#>
prefix oecc: <http://www.oegov.org/models/common/cc#>
#select ?person_loc ?observ_val ?avg_prefer_val ((?observ_val- ?avg_prefer_val) as ?dd) 
#(if(?observ_val = ?avg_prefer_val, "equal", if(?observ_val > ?avg_prefer_val, "big", "small")) as ?rtn2)
select *
where 
{
#    ?person_loc rdf:type DUL:PhysicalPlace;
    icbms:DT0001 rdf:type DUL:PhysicalPlace;
       rdf:type icbms:Domitory ;
       ssn:hasValue ?observ .
  ?observ rdf:type ssn:ObservationValue ;
    rdf:type icbms:TemperatureObservationValue ;
     qudt:hasNumericValue ?observ_val .
  bind(   (if(xsd:double(?observ_val) = xsd:double(?avg_prefer_val), "equal"^^xsd:string, "small"^^xsd:string)) as ?rtn)
  bind(if(?observ_val < 0,"a","b") as ?test1)
  bind(xsd:double(?observ_val) as ?test2)
  bind(xsd:double(?avg_prefer_val) as ?test3)
  BIND(?person_loc as ?test4) .
  {
   select ?person_loc (avg(?prefer_val) as ?avg_prefer_val) {
   ?person_id rdf:type foaf:Person ;
      rdf:type icbms:Student ;
      DUL:hasLocation ?person_loc ;
      icbms:hasPreference ?pre .
    ?pre rdf:type icbms:Preference ;
      icbms:hasPreferenceKind icbms:TemperaturePreference ;
      DUL:hasDataValue ?prefer_val .
    } group by (?person_loc)
  }
}
  
  
  
===================결과값================================
sparql_result_20160121_102703.png


rtn, test3, test4의 값이 null로 표시된다.

rtn을 구하기 위한 ?observ_val와 ?avg_prefer_val값이 있는데도 불구하고 말이다.

그러나 bind를 쓰지않고 select 절에 if문을 사용하면 정상적으로 처리된다.
(select에서는 bind를 구문을 사용하지 못하지만 (if(조건식,true일경우,false일경우) as ?rtn) 형태로 표현가능하다.)

  
번호 제목 날짜 조회 수
321 github에 있는 프로젝트와 로컬에서 작업한 프로젝트 합치기 2016.11.22 536
320 .gitignore파일에 지정되지 않은 파일이 ignore되는 경우 확인방법 2016.11.22 465
319 특정 커밋 시점(commit id를 기준으로)으로 돌리기(reset) 2016.11.21 190
318 Github를 이용하는 전체 흐름 이해하기 2016.11.18 146
317 특정 단계의 commit상태로 만들기(이렇게 하면 중간에 반영된 모든 commit를 history가 삭제된다) 2016.11.17 377
316 git 초기화(Windows에서 Git Bash사용) 2016.11.17 246
315 spark notebook 0.7.0설치및 설정 2016.11.14 464
314 참고할만한 spark예제를 설명하는 사이트 2016.11.11 186
313 Kafka Offset Monitor로 kafka 상태 모니터링 하기 file 2016.11.08 663
312 Eclipse실행시 Java was started but returned exit code=1이라는 오류가 발생할때 조치방법 2016.11.07 581
311 [SparkR]SparkR 설치 사용기 1 - Installation Guide On Yarn Cluster & Mesos Cluster & Stand Alone Cluster file 2016.11.04 341
310 데이타 분석및 머신러닝에 도움이 도움이 되는 사이트 2016.11.04 455
309 java스레드 덤프 분석하기 file 2016.11.03 185
308 centos 6에서 mariadb 5.1 to 10.0 으로 upgrade 2016.11.01 204
307 Spark Streaming 코드레벨단에서의 성능개선 2016.10.31 293
306 Flume과 Kafka를 사용한 초당 100만개 로그 수집 테스트 file 2016.10.31 1127
305 Flume을 이용한 데이타 수집시 HBase write 성능 튜닝 file 2016.10.31 724
304 How-to: Build a Complex Event Processing App on Apache Spark and Drools file 2016.10.31 360
303 How-to: Tune Your Apache Spark Jobs (Part 2) file 2016.10.31 221
302 mybatis와 spring을 org.apache.commons.dbcp2.BasicDataSource의 DataSource로 연동할때 DB설정(참고) 2016.10.31 1074
위로