메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

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


1. 정렬 수행

        // data를 담고 있는 List변수

List<Map<String, String>> list = new ArrayList<Map<String, String>>();

        // List에 담기는 Map변수

HashMap<String,String> row = new HashMap<String, String>;


// 정렬실행

Collections.sort(list, new MapStringComparator("rest_type"));

Collections.sort(list, new MapStringComparator("corner_id"));

Collections.sort(list, new MapFloatComparator("cnt"));


2. 정렬 클래스(문자열)

class MapStringComparator implements Comparator<Map<String, String>> {
		private final String key;
		
		public MapStringComparator(String key) {
			this.key = key;
		}
		
		@Override
		public int compare(Map<String, String> first, Map<String, String> second) {
			String firstValue =first.get(key);
	        String secondValue = second.get(key);
	        
	         // 내림차순 정렬
             return firstValue.compareTo(secondValue);
		}
	}


3. 정렬 클래스(숫자)

class MapFloatComparator implements Comparator<Map<String, String>> {
		private final String key;
		
		public MapFloatComparator(String key) {
			this.key = key;
		}
		
		@Override
		public int compare(Map<String, String> first, Map<String, String> second) {
			float firstValue = Float.valueOf(first.get(key));
	         float secondValue = Float.valueOf(second.get(key));
	         
			// 내림차순 정렬
	         if (firstValue > secondValue) {
	             return -1;
	         } else if (firstValue < secondValue) {
	             return 1;
	         } else /* if (firstValue == secondValue) */ {
	             return 0;
	         }
		}
	}


번호 제목 날짜 조회 수
130 Hue Load Balancer를 L4로 L/B하는 경우는 L4쪽 도멘인으로 발행된 인증서를 TLS/SSL항목에 설정해주어야 한다. 2021.10.08 4024
129 kudu hms check 사용법(예시) 2021.10.22 4402
128 hive metastore db중 TBLS, TABLE_PARAMS테이블 설명 2021.10.22 4166
127 Query Status: Sender xxx.xxx.xxx.xxx timed out waiting for receiver fragment instance: 1234:cdsf, dest node: 10 의 오류 원인및 대응방안 2021.11.03 4479
126 hue.axes_accessattempt테이블의 username컬럼에 NULL 혹은 space가 들어갈수도 있음. 2021.11.03 90868
125 클러스터내의 전체 workflow및 coordinator현황을 사용자별로 추출하는 방법 2021.11.25 4637
124 python2.7.4에서 Oracle DB(11.2)를 사용하기 위한 설정(RPM을 이용하여 RHEL 7.4에 설치) 2021.11.26 5578
123 oracle 12에 sqoop해서 데이터 import하기 (console에서 sqoop import하는 방법) 2021.12.31 3953
122 hadoop nfs gateway설정 (Cloudera 6.3.4, CentOS 7.4 환경에서) 2022.01.07 4606
121 kudu 테이블 metadata강제 삭제시 발생하는 오류 메세지 2022.01.12 4636
120 Oracle NLOB type의 데이터를 import하는 경우 No Java type for SQL type 2011 for column rst와 같은 오류 발생시 조치사항 2022.01.14 4528
119 not leader of this config: current role FOLLOWER 오류 발생시 확인방법 2022.01.17 4185
118 Soft memory limit exceeded (at 100.05% of capacity) 오류 조치 2022.01.17 4324
117 Failed to write to server: (no server available): 2022.01.17 4435
116 Kudu tablet이 FAILED일때 원인 확인 방법 2022.01.17 5065
115 kudu rebalance수행 command예시 2022.01.17 5085
114 [백업] 리눅스 시스템 백업하기 (Linux System Backup) - TAR 사용 시스템 전체 백업 2022.01.19 5140
113 windows10 pro에서 microservice pattern책의 예제를 kubernetes에서 기동하는 방법 2022.01.30 2765
112 eclipse editor 설정방법 2022.02.01 3545
111 vuestorefrontui.io를 이용한 front end project 생성하기 2022.02.06 4796
위로