public List<Map<String,String>> getPropList(String[] keys) { List<Map<String,String>> propList = new ArrayList<Map<String,String>>(); for (String key : keys) { LinkedMap pulldown = new LinkedMap(); String value = getText(key); String[] items = value.split(","); for (String item : items) { String[] property = item.split(":"); Map<String,String> mapProp =new HashMap<String,String>(); if (property.length == 2) { mapProp.put(property[0], property[1]); propList.add(mapProp); } } } return propList; }
/** * Creates a new crosstab. * * @param defaultStyleProvider default style provider */ public JRDesignCrosstab(JRDefaultStyleProvider defaultStyleProvider) { super(defaultStyleProvider); parametersList = new ArrayList<JRCrosstabParameter>(); parametersMap = new HashMap<String, JRCrosstabParameter>(); rowGroupsMap = new HashMap<String, Integer>(); rowGroups = new ArrayList<JRCrosstabRowGroup>(); columnGroupsMap = new HashMap<String, Integer>(); columnGroups = new ArrayList<JRCrosstabColumnGroup>(); measuresMap = new HashMap<String, Integer>(); measures = new ArrayList<JRCrosstabMeasure>(); cellsMap = new HashMap<Pair<String,String>,JRCrosstabCell>(); cellsList = new ArrayList<JRCrosstabCell>(); addBuiltinParameters(); variablesList = new LinkedMap(); addBuiltinVariables(); dataset = new JRDesignCrosstabDataset(); lineBox = new JRBaseLineBox(this); }
/** * Tests that no checkpoints happen when the fetcher is not running. */ @Test public void ignoreCheckpointWhenNotRunning() throws Exception { @SuppressWarnings("unchecked") final AbstractFetcher<String, ?> fetcher = mock(AbstractFetcher.class); FlinkKafkaConsumerBase<String> consumer = getConsumer(fetcher, new LinkedMap(), false); OperatorStateStore operatorStateStore = mock(OperatorStateStore.class); TestingListState<Tuple2<KafkaTopicPartition, Long>> listState = new TestingListState<>(); when(operatorStateStore.getOperatorState(Matchers.any(ListStateDescriptor.class))).thenReturn(listState); consumer.snapshotState(new StateSnapshotContextSynchronousImpl(1, 1)); assertFalse(listState.get().iterator().hasNext()); consumer.notifyCheckpointComplete(66L); }
/** * Tests that no checkpoints happen when the fetcher is not running. */ @Test public void checkRestoredNullCheckpointWhenFetcherNotReady() throws Exception { FlinkKafkaConsumerBase<String> consumer = getConsumer(null, new LinkedMap(), true); OperatorStateStore operatorStateStore = mock(OperatorStateStore.class); TestingListState<Serializable> listState = new TestingListState<>(); when(operatorStateStore.getSerializableListState(Matchers.any(String.class))).thenReturn(listState); StateInitializationContext initializationContext = mock(StateInitializationContext.class); when(initializationContext.getOperatorStateStore()).thenReturn(operatorStateStore); when(initializationContext.isRestored()).thenReturn(false); consumer.initializeState(initializationContext); consumer.snapshotState(new StateSnapshotContextSynchronousImpl(17, 17)); assertFalse(listState.get().iterator().hasNext()); }
/** * Tests that on snapshots, states and offsets to commit to Kafka are correct */ @Test public void checkUseFetcherWhenNoCheckpoint() throws Exception { FlinkKafkaConsumerBase<String> consumer = getConsumer(null, new LinkedMap(), true); List<KafkaTopicPartition> partitionList = new ArrayList<>(1); partitionList.add(new KafkaTopicPartition("test", 0)); consumer.setSubscribedPartitions(partitionList); OperatorStateStore operatorStateStore = mock(OperatorStateStore.class); TestingListState<Serializable> listState = new TestingListState<>(); when(operatorStateStore.getSerializableListState(Matchers.any(String.class))).thenReturn(listState); StateInitializationContext initializationContext = mock(StateInitializationContext.class); when(initializationContext.getOperatorStateStore()).thenReturn(operatorStateStore); // make the context signal that there is no restored state, then validate that when(initializationContext.isRestored()).thenReturn(false); consumer.initializeState(initializationContext); consumer.run(mock(SourceFunction.SourceContext.class)); }
private static <T> FlinkKafkaConsumerBase<T> getConsumer( AbstractFetcher<T, ?> fetcher, LinkedMap pendingOffsetsToCommit, boolean running) throws Exception { FlinkKafkaConsumerBase<T> consumer = new DummyFlinkKafkaConsumer<>(); Field fetcherField = FlinkKafkaConsumerBase.class.getDeclaredField("kafkaFetcher"); fetcherField.setAccessible(true); fetcherField.set(consumer, fetcher); Field mapField = FlinkKafkaConsumerBase.class.getDeclaredField("pendingOffsetsToCommit"); mapField.setAccessible(true); mapField.set(consumer, pendingOffsetsToCommit); Field runningField = FlinkKafkaConsumerBase.class.getDeclaredField("running"); runningField.setAccessible(true); runningField.set(consumer, running); return consumer; }
@Override protected void onStop() { super.onStop(); // Write the read items set to file. ObjectIO out = new ObjectIO(this, READ_ITEMS); out.write(mReadItemTimes); // Write the index file to disk. out.setNewFileName(INDEX); out.write(m_index); // Write the favourites list to file. AdapterFeedItems adapter = ListFragmentTag.getFavouritesAdapter(this); LinkedMap favourites = adapter.getMap(); out.setNewFileName(FAVOURITES); out.write(favourites); setServiceIntent(ALARM_SERVICE_START); }
private List<ScoreDoc> sortByRank(Map<ScoreDoc, Integer> inputList) { LOG.debug("[sortByRank] - BEGIN"); List<ScoreDoc> result = new ArrayList<>(); LinkedMap apacheMap = new LinkedMap(inputList); for (int i = 0; i < apacheMap.size() - 1; i++) { Map<Float, ScoreDoc> treeMap = new TreeMap<>( Collections.reverseOrder()); do { i++; treeMap.put(((ScoreDoc) apacheMap.get(i - 1)).score, (ScoreDoc) apacheMap.get(i - 1)); } while (i < apacheMap.size() && apacheMap.getValue(i) == apacheMap.getValue(i - 1)); i--; treeMap.keySet().stream().forEach((score) -> { result.add(treeMap.get(score)); }); } LOG.debug("[sortByRank] - END"); return result; }
/** * 从property中读取内容转成Map * * @param keys * property里的键 */ public void initCollections(String[] keys) { for (String key : keys) { LinkedMap pulldown = new LinkedMap(); String value = getText(key); String[] items = value.split(","); for (String item : items) { String[] property = item.split(":"); if (property.length == 2) { pulldown.put(property[0], property[1]); } } collections.put(key, pulldown); } }
private void runReplicationTest(final String tableName, final int numRows, final int expectedKeys) { actualRows = 0; final FTableDescriptor fTableDescriptor = FTableDescriptorHelper.getFTableDescriptor(NUM_OF_COLUMNS); fTableDescriptor.setTotalNumOfSplits(NUM_OF_SPLITS); fTableDescriptor.setRedundantCopies(1); final FTable table = MClientCacheFactory.getAnyInstance().getAdmin().createFTable(tableName, fTableDescriptor); assertNotNull(table); Record record = new Record(); Map<String, String> map = new LinkedMap(); for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { record.add(COLUMN_NAME_PREFIX + colIndex, Bytes.toBytes(COLUMN_NAME_PREFIX + colIndex)); map.put(COLUMN_NAME_PREFIX + colIndex, COLUMN_NAME_PREFIX + colIndex); } for (int i = 0; i < numRows; i++) { table.append(record); } final int size = ((ProxyFTableRegion) table).getTableRegion().keySetOnServer().size(); System.out.println("Keys on server " + size); assertEquals(expectedKeys, size); verifyValuesOnAllPrimaryVMs(tableName, numRows, map); verifyValuesOnAllSecondaryVMs(tableName, numRows, map); }
BucketSizeInfo(int sizeIndex) { bucketList = new LinkedMap(); freeBuckets = new LinkedMap(); completelyFreeBuckets = new LinkedMap(); this.sizeIndex = sizeIndex; }
public OrderedMap getDiseaseList(){ OrderedMap map = new LinkedMap(); /* Disease Community Keyword */ map.put("Acne","Acne"); map.put("AcuteBronchitis","Acute Bronchitis"); map.put("AddictionMedicine","Addiction Medicine"); map.put("Allergy","Allergy"); map.put("AlzheimersDisease","Alzheimer's Disease"); map.put("Andropause","Andropause"); map.put("AnxietyDisorders","Anxiety Disorders"); map.put("Appendicitis","Appendicitis"); map.put("Asthma","Asthma"); map.put("AtrialFibrillation","Atrial Fibrillation"); map.put("AvianFlu","Avian Flu"); map.put("BenignProstaticHyperplasia","Benign Prostatic Hyperplasia"); map.put("BipolarDisorder","Bipolar Disorder"); map.put("BreastCancer","Breast Cancer"); map.put("CHF","CHF"); map.put("COPD","COPD"); map.put("CVA","CVA (Stroke)"); map.put("Cholecystitis","Cholecystitis"); map.put("ChronicPain","Chronic Pain"); map.put("ColonCancer","Colon Cancer"); map.put("Contraception","Contraception"); map.put("CoronaryArteryDisease","Coronary Artery Disease"); map.put("Depression","Depression"); map.put("Diabetes","Diabetes"); map.put("Dyslipidemia","Dyslipidemia"); map.put("EatingDisorders","Eating Disorders"); map.put("ErectileDysfunction","Erectile Dysfunction"); map.put("GERD","GERD"); map.put("HIVandAIDS","HIV and AIDS"); map.put("Headache","Headache"); map.put("Hepatitis","Hepatitis"); map.put("Herpes","Herpes"); map.put("Hypertension","Hypertension"); map.put("Infertility","Infertility"); map.put("InflammatoryBowelDisease","Inflammatory Bowel Disease"); map.put("Influenza","Influenza"); map.put("IrritableBowelSyndrome","Irritable Bowel Syndrome"); map.put("LungCancer","Lung Cancer"); map.put("Menopause","Menopause"); map.put("Obesity","Obesity"); map.put("Osteoporosis","Osteoporosis"); map.put("OvarianCancer","Ovarian Cancer"); map.put("PalliativeCare","Palliative Care"); map.put("ParkinsonsDisease","Parkinson's Disease"); map.put("ProstateCancer","Prostate Cancer"); map.put("Psoriasis","Psoriasis"); map.put("RheumatoidArthritis","Rheumatoid Arthritis/Autoimmune"); map.put("SARS","SARS"); map.put("STIs","STIs"); map.put("Schizophrenia","Schizophrenia"); map.put("Sinusitis","Sinusitis"); map.put("SmokingCessation","Smoking Cessation"); map.put("ThyroidDisorders","Thyroid Disorders"); map.put("UrinaryIncontinence","Urinary Incontinence"); map.put("WestNileVirus","West Nile Virus"); return map; }
@VisibleForTesting LinkedMap getPendingOffsetsToCommit() { return pendingOffsetsToCommit; }
protected Map<String, Object> createColumnMap(int columnCount) { return new LinkedMap(columnCount); }
LinkedMapAdapter(Map<K, V> map) { m_map = null == map ? new LinkedMap(1) : new LinkedMap(map); notifyDataSetChanged(); }
public LinkedMap getMap() { return (LinkedMap) m_map.clone(); }
/** * 获取集合 * * @return 获取集合 */ public Map<String, LinkedMap> getCollections() { return collections; }