HSQL

?Hive的數據存儲

  1、Hive中所有的數據都存儲在 HDFS 中,沒有專門的數據存儲格式(可支持Text,SequenceFile,ParquetFile,RCFILE等)
  2、只需要在創建表的時候告訴 Hive 數據中的列分隔符和行分隔符,Hive 就可以解析數據。
  3、Hive 中包含以下數據模型:DB、Table,External Table,Partition,Bucket。
?    (1):db:在hdfs中表現為${hive.metastore.warehouse.dir}目錄下一個文件夾
    (3):external table:外部表, 與table類似,不過其數據存放位置可以在任意指定路徑
    (2):table:在hdfs中表現所屬db目錄下一個文件夾
        普通表: 刪除表后, hdfs上的文件都刪了
        External外部表刪除后, hdfs上的文件沒有刪除, 只是把文件刪除了
    (4):partition:在hdfs中表現為table目錄下的子目錄
    (5):bucket:桶, 在hdfs中表現為同一個表目錄下根據hash散列之后的多個文件, 會根據不同的文件把數據放到不同的文件中

1:Hive創建數據表:
# page_view是數據表的名稱,注意hive的數據類型和java的數據類型類似,和mysql和oracle等數據庫的字段類型不一致。
CREATE TABLE page_view(viewTime INT, userid BIGINT,
???? page_url STRING, referrer_url STRING,
???? ip STRING COMMENT 'IP Address of the User')
#COMMENT描述,可有可無的。
?COMMENT 'This is the page view table'
# PARTITIONED BY指定表的分區,可以先不管。
?PARTITIONED BY(dt STRING, country STRING)
# ROW FORMAT DELIMITED代表一行是一條記錄,是自己創建的全部字段和文件的字段對應,一行對應一條記錄。
?ROW FORMAT DELIMITED
#FIELDS TERMINATED BY '\001'代表一行記錄中的各個字段以什么隔開,方便創建的數據字段對應文件的一條記錄的字段。
?? FIELDS TERMINATED BY '\001'
# STORED AS SEQUENCEFILE;代表對應的文件類型。最常見的是SEQUENCEFILE(以鍵值對類型格式存儲的)類型。TEXTFILE類型。
STORED AS SEQUENCEFILE;

如何開啟MySQL的遠程帳號(Navicat遠程連接自己的mysql數據庫):
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

再執行下面的語句,方可立即生效(修改的權限即時生效)。
mysql> FLUSH PRIVILEGES;

(1)all PRIVILEGES 表示賦予所有的權限給指定用戶,這里也可以替換為賦予某一具體的權限,例如select,insert,update,delete,create,drop 等,具體權限間用“,”半角逗號分隔。
(2)*.* 表示上面的權限是針對于哪個表的,*指的是所有數據庫,后面的 * 表示對于所有的表,由此可以推理出:對于全部數據庫的全部表授權為“*.*”,對于某一數據庫的全部表授權為“數據庫名.*”,對于某一數據庫的某一表授權為“數據庫名.表名”。
(3)root 表示你要給哪個用戶授權,這個用戶可以是存在的用戶,也可以是不存在的用戶。
(4)192.168.3.132?? 表示允許遠程連接的 IP 地址,如果想不限制鏈接的 IP 則設置為“%”即可。
(5)123456 為用戶的密碼。

?2:創建好數據表,開始插入數據
?create table tb_order(id int,name string,memory string,price double) row format delimited fields terminated by '\t';
?在/home/hadoop/目錄下面phoneorder.data
?[root@slaver3 hadoop]# vim phoneorder.data?? 10010??? 小米1??? 2G??? 1999? /?? 10011??? 小米2??? 4G??? 1999
?開始導入數據(或者使用hadoop的命令將正確格式數據上傳到對應的目錄)
?hive> load data local inpath '/home/hadoop/hivetest/phoneorder.data' into table tb_order;
?3: 使用hive的查詢語句進行查詢操作
?hive (myhive)> select * from tb_order;?? ??? ?
?4:external外部表,優點,做數據分析的時候,有的數據是業務系統產生的,或者讀或者寫這個文件,如果的默認的路徑,即在配置文件里面寫好了,
?如果做分析的時候數據表導數據,如果將數據表移動了,,業務系統再讀這個文件就不存在了,這個時候使用外部表,外部表不要求數據非到默認的路徑下面去,數據可以擺放到任意的hdfs路徑下面;
?//external外部表
//使用關鍵字EXTERNAL
CREATE EXTERNAL TABLE 數據表名稱(id int, name string,
???? ip STRING,
???? country STRING)
?ROW FORMAT DELIMITED
?FIELDS TERMINATED BY '\t'
?STORED AS TEXTFILE

#location指定所在的位置:切記,重點。
?LOCATION '/external/user';
?TO:
[root@slaver3 hadoop]# cd /home/hadoop/hivetest/
[root@slaver3 hivetest]# cp phoneorder.data phoneorder4.data
[root@slaver3 hivetest]# hadoop fs -mkdir /hive_ext
[root@slaver3 hivetest]# hadoop fs -put phoneorder4.data /hive_ext

hive> create external table tb_order_ext(id int,name string,memory string,price double)
??? > row format delimited
??? > fields terminated by '\t'
??? > location '/hive_ext';
查看擴展數據表的數據表結構?? ??? ?1 hive> desc extended tb_log;
格式化查看擴展表的數據表結構?? ?1 hive> desc formatted tb_log;

?5:創建分區表(分區的好處是可以幫助你統計的時候少統計一些數據,加速數據統計):
?hive> create table tb_part(sNo int,sName string,sAge int,sDept string)
??? > partition //拿不準的單詞,可以tab一下進行提示,并不會影響你創建表;謝謝
partition???? partitioned?? partitions?? ?
??? > partitioned by (part string)
??? > row format delimited ?
??? > fields terminated by ','
??? > stored as textfile;
OK
Time taken: 0.351 seconds

將本地的數據上傳到hive上面:
?1 hive> load data local inpath '/home/hadoop/data_hadoop/tb_part' overwrite into table tb_part partition (part='20171210');
?6 hive> load data local inpath '/home/hadoop/data_hadoop/tb_part' overwrite into table tb_part partition (part='20171211');
?11 hive> show par
?13 hive> show partition
?15 hive> show partitions tb_part;
?? ?
6:創建帶桶的數據表,然后將本地創建好測試數據上傳到hive上面:
?1 hive> create table if not exists tb_stud(id int,name string,age int)
?2???? > partitioned by(clus string)
?3???? > clustered by(id) sorted by(age) into 2 buckets? #分桶,根據id進行分桶,分成2個桶。
?4???? > row format delimited
?5???? > fields terminated by ',';
?8 hive> load data local inpath '/home/hadoop/data_hadoop/tb_clustered' overwrite into table tb_stud partition (clus='20171211');

?7:修改表,增加/刪除分區
?hive> alter table tb_stud add partition(clus='20171217');
?hive> alter table tb_stud drop partition(clus='20171217');
?hive> show partitions tb_stud;
?
?8:重命名表:
?1 hive> show tables;
?2 hive> alter table tb_user rename to tb_user_copy;
?
?9:增加/更新列
?1 hive> desc tb_user;
?hive> alter table tb_user add columns(age int);
?hive> alter table tb_user replace columns(id int,name string,birthday string);
?
?10:Load,操作只是單純的復制/移動操作,DML操作
?說明:
1、Load 操作只是單純的復制/移動操作,將數據文件移動到 Hive 表對應的位置。
2、filepath:
  相對路徑,例如:project/data1
  絕對路徑,例如:/user/hive/project/data1
  包含模式的完整 URI,列如:
  hdfs://namenode:9000/user/hive/project/data1
3、LOCAL關鍵字
  如果指定了 LOCAL, load 命令會去查找本地文件系統中的 filepath。
  如果沒有指定 LOCAL 關鍵字,則根據inpath中的uri[如果指定了 LOCAL,那么:
  load 命令會去查找本地文件系統中的 filepath。如果發現是相對路徑,則路徑會被解釋為相對于當前用戶的當前路徑。
  load 命令會將 filepath中的文件復制到目標文件系統中。目標文件系統由表的位置屬性決定。被復制的數據文件移動到表的數據對應的位置。
?
  如果沒有指定 LOCAL 關鍵字,如果 filepath 指向的是一個完整的 URI,hive 會直接使用這個 URI。 否則:如果沒有指定   schema 或者 authority,Hive 會使用在 hadoop 配置文件中定義的 schema 和 authority,fs.default.name 指定了 Namenode 的 URI。
  如果路徑不是絕對的,Hive 相對于/user/進行解釋。
  Hive 會將 filepath 中指定的文件內容移動到 table (或者 partition)所指定的路徑中。]查找文件

4、OVERWRITE 關鍵字
如果使用了 OVERWRITE 關鍵字,則目標表(或者分區)中的內容會被刪除,然后再將 filepath 指向的文件/目錄中的內容添加到表/分區中。
如果目標表(分區)已經有一個文件,并且文件名和 filepath 中的文件名沖突,那么現有的文件會被新文件所替代。

11:Hive的insert操作:
<!--基本模式插入。-->
hive> load data local inpath '/home/hadoop/data_hadoop/tb_stud' overwrite into table tb_stud partition (clus='20171211');
hive> select * from tb_stud where clus='20171211';
hive> insert overwrite table tb_stud partition(clus='20171218')
?? ?> select id,name,age from tb_stud where clus='20171211';
hive> select * from tb_stud where clus='20171218';

?<!--多插入模式。-->
?hive> show partitions tb_stud;
?hive> alter table tb_stud add partition(clus='20171212');
?hive> alter table tb_stud add partition(clus='20171213');
?hive> alter table tb_stud add partition(clus='20171214');
?hive> from tb_stud
???? > insert overwrite table tb_stud partition(clus='20171213')
???? > select id,name,age? where clus='20171211'
???? > insert overwrite table tb_stud partition(clus='20171214')
???? > select id,name,age? where clus='20171211';
?hive> select * from tb_stud where clus='20171213';
?hive> select * from tb_stud where clus='20171214';
?
?12:導出表數據
? 1、導出文件到本地。
? 說明:
? 數據寫入到文件系統時進行文本序列化,且每列用^A來區分,\n為換行符。用more命令查看時不容易看出分割符,可以使用: sed -e 's/\x01/|/g' filename[]來查看。
? hive> insert overwrite local directory '/home/hadoop/data_hadoop/get_tb_stud'
????? > select * from tb_stud;
? 2、導出數據到HDFS。
?? hive> insert overwrite directory 'hdfs://192.168.199.130:9000/user/hive/warehouse/tb_stud_get'
?? ??? > select * from tb_stud;
?? hive> dfs -ls /user/hive/warehouse/tb_stud_get;
? ?
?13:SELECT,基本的Select操作
1、order by 會對輸入做全局排序,因此只有一個reducer,會導致當輸入規模較大時,需要較長的計算時間。
2、sort by不是全局排序,其在數據進入reducer前完成排序。因此,如果用sort by進行排序,并且設置mapred.reduce.tasks>1,則sort by只保證每個reducer的輸出有序,不保證全局有序。
3、distribute by根據distribute by指定的內容將數據分到同一個reducer。
4、Cluster by 除了具有Distribute by的功能外,還會對該字段進行排序。因此,常常認為cluster by = distribute by + sort by
5、分桶表的最大的意思:最大的作用是用來提高join操作的效率;
6、思考這個問題:
  select a.id,a.name,b.addr from a join b on a.id = b.id;
  如果a表和b表已經是分桶表,而且分桶的字段是id字段
  做這個join操作時,還需要全表做笛卡爾積嗎?答案:不需要,因為相同的id就在同一個桶里面。

?14:刪除hive的內部表和外部表的區別:
  刪除內部表是將元數據(TABL表),以及hdfs上面的文件夾以及文件一起刪除;
  刪除外部表只是刪除元數據(TABL表),hdfs上面的文件夾以及文件不刪除。

?15:創建一個新表根據老表(用來做一些中間結果的存儲,再做后一步的處理,):
注意:用于創建一些臨時表存儲中間結果;
hive> create table tb_order_new ?
??? > as??????????????????????? ?
??? > select id,name,memory,price
??? > from tb_order;
?? ?
?16:insert from select?? 通過select語句批量插入數據到別的表(用于向臨時表中追加中間結果數據):
?hive> create table tb_order_append(id int,name string,memory string,price double)
???? > row format delimited
???? > fields terminated by '\t';
?hive> insert overwrite table tb_order_append
???? > select * from tb_order;
?hive> select * from tb_order_append;
?
?17:PARTITION ,分區表(partition),分區統計,可以對數據操作加快速度:
?查詢分區:hive> show partitions part;   #show partitions 數據表名稱;
?刪除分區:hive> alter table part drop partition(date='20180512');
?添加分區:hive> alter table part add partition(date='20180512');
?將數據導入這個新建的分區里面(所謂分區就是在文件夾下面創建一個文件夾,把數據放到這個文件夾下面),如下所示:
?hive> load data local inpath '/home/hadoop/hivetest/phoneorder.data' into table tb_order_part partition(month='201401');
?hive> load data local inpath '/home/hadoop/hivetest/phoneorder2.data' into table tb_order_part partition(month='201402');
?
?18:write to hdfs,將結果寫入到hdfs的文件中:
?hive> insert overwrite local directory '/home/hadoop/hivetest/test.txt'? ?
???? > select * from tb_order_part
???? > where month="201401";
?? ?
?19:Hive的Join使用:
?語法結構
join_table:
? table_reference JOIN table_factor [join_condition]
? | table_reference {LEFT|RIGHT|FULL} [OUTER] JOIN table_reference join_condition
? | table_reference LEFT SEMI JOIN table_reference join_condition
Hive 支持等值連接(equality joins)、外連接(outer joins)和(left/right joins)。Hive 不支持非等值的連接,因為非等值連接非常難轉化到 map/reduce 任務。
另外,Hive 支持多于 2 個表的連接。
寫 join 查詢時,需要注意幾個關鍵點:
1. 只支持等值join
例如:
? SELECT a.* FROM a JOIN b ON (a.id = b.id)
? SELECT a.* FROM a JOIN b
??? ON (a.id = b.id AND a.department = b.department)
是正確的,然而:
? SELECT a.* FROM a JOIN b ON (a.id>b.id)
是錯誤的。

2. 可以 join 多于 2 個表。
例如
? SELECT a.val, b.val, c.val FROM a JOIN b
??? ON (a.key = b.key1) JOIN c ON (c.key = b.key2)
如果join中多個表的 join key 是同一個,則 join 會被轉化為單個 map/reduce 任務,例如:
? SELECT a.val, b.val, c.val FROM a JOIN b
??? ON (a.key = b.key1) JOIN c
??? ON (c.key = b.key1)
被轉化為單個 map/reduce 任務,因為 join 中只使用了 b.key1 作為 join key。
SELECT a.val, b.val, c.val FROM a JOIN b ON (a.key = b.key1)
? JOIN c ON (c.key = b.key2)
而這一 join 被轉化為 2 個 map/reduce 任務。因為 b.key1 用于第一次 join 條件,而 b.key2 用于第二次 join。
? ?
3.join 時,每次 map/reduce 任務的邏輯:
??? reducer 會緩存 join 序列中除了最后一個表的所有表的記錄,再通過最后一個表將結果序列化到文件系統。這一實現有助于在 reduce 端減少內存的使用量。實踐中,應該把最大的那個表寫在最后(否則會因為緩存浪費大量內存)。例如:
?SELECT a.val, b.val, c.val FROM a
??? JOIN b ON (a.key = b.key1) JOIN c ON (c.key = b.key1)
所有表都使用同一個 join key(使用 1 次 map/reduce 任務計算)。Reduce 端會緩存 a 表和 b 表的記錄,然后每次取得一個 c 表的記錄就計算一次 join 結果,類似的還有:
? SELECT a.val, b.val, c.val FROM a
??? JOIN b ON (a.key = b.key1) JOIN c ON (c.key = b.key2)
這里用了 2 次 map/reduce 任務。第一次緩存 a 表,用 b 表序列化;第二次緩存第一次 map/reduce 任務的結果,然后用 c 表序列化。

4.LEFT,RIGHT 和 FULL OUTER 關鍵字用于處理 join 中空記錄的情況
例如:
? SELECT a.val, b.val FROM
a LEFT OUTER? JOIN b ON (a.key=b.key)
對應所有 a 表中的記錄都有一條記錄輸出。輸出的結果應該是 a.val, b.val,當 a.key=b.key 時,而當 b.key 中找不到等值的 a.key 記錄時也會輸出:
a.val, NULL
所以 a 表中的所有記錄都被保留了;
“a RIGHT OUTER JOIN b”會保留所有 b 表的記錄。

Join 發生在 WHERE 子句之前。如果你想限制 join 的輸出,應該在 WHERE 子句中寫過濾條件——或是在 join 子句中寫。這里面一個容易混淆的問題是表分區的情況:
? SELECT a.val, b.val FROM a
? LEFT OUTER JOIN b ON (a.key=b.key)
? WHERE a.ds='2009-07-07' AND b.ds='2009-07-07'
會 join a 表到 b 表(OUTER JOIN),列出 a.val 和 b.val 的記錄。WHERE 從句中可以使用其他列作為過濾條件。但是,如前所述,如果 b 表中找不到對應 a 表的記錄,b 表的所有列都會列出 NULL,包括 ds 列。也就是說,join 會過濾 b 表中不能找到匹配 a 表 join key 的所有記錄。這樣的話,LEFT OUTER 就使得查詢結果與 WHERE 子句無關了。解決的辦法是在 OUTER JOIN 時使用以下語法:
? SELECT a.val, b.val FROM a LEFT OUTER JOIN b
? ON (a.key=b.key AND
????? b.ds='2009-07-07' AND
????? a.ds='2009-07-07')
這一查詢的結果是預先在 join 階段過濾過的,所以不會存在上述問題。這一邏輯也可以應用于 RIGHT 和 FULL 類型的 join 中。

Join 是不能交換位置的。無論是 LEFT 還是 RIGHT join,都是左連接的。
? SELECT a.val1, a.val2, b.val, c.val
? FROM a
? JOIN b ON (a.key = b.key)
? LEFT OUTER JOIN c ON (a.key = c.key)
先 join a 表到 b 表,丟棄掉所有 join key 中不匹配的記錄,然后用這一中間結果和 c 表做 join。這一表述有一個不太明顯的問題,就是當一個 key 在 a 表和 c 表都存在,但是 b 表中不存在的時候:整個記錄在第一次 join,即 a JOIN b 的時候都被丟掉了(包括a.val1,a.val2和a.key),然后我們再和 c 表 join 的時候,如果 c.key 與 a.key 或 b.key 相等,就會得到這樣的結果:NULL, NULL, NULL, c.val

轉載于:https://www.cnblogs.com/fengyouheng/p/10266860.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278465.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278465.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278465.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

在PowerPoint 2010中將鼠標用作激光筆

Have you ever wished you had a laser pointer to focus attention on a key point in a PowerPoint slideshow? Today, we’ll take a look at how can use use your mouse as a laser pointer in PowerPoint 2010. 您是否曾經希望激光指示器能將注意力集中在PowerPoint幻燈…

Java 8 并發: 原子變量和 ConcurrentMap

原文地址: Java 8 Concurrency Tutorial: Atomic Variables and ConcurrentMap AtomicInteger java.concurrent.atomic 包下有很多原子操作的類。 在有些情況下&#xff0c;原子操作可以在不使用 synchronized 關鍵字和鎖的情況下解決多線程安全問題。 在內部&#xff0c;原子類…

this表示當前對象簡單實例

直接上代碼 class Message { private Channel channel ; // 保存消息發送通道 private String title ; // 消息標題 private String content ; // 消息內容 // 4、調用此構造實例化&#xff0c;此時的channel 主類ch public Message(Channel channel,String title,String cont…

twitter推文不收錄_如何使用Twitter書簽保存推文供以后使用

twitter推文不收錄Khamosh PathakKhamosh PathakTwitter has a new Bookmarks feature that lets you privately save tweets for later. If you’ve been using the Like feature as a workaround for saving tweets, here’s why you should start bookmarking. Twitter具有一…

if的作用域問題 *輸出1~6的隨機數*

1 //測試if語句2 public class TestIf {3 public static void main(String[] args){4 double d Math.random();//0~1之間的小數5 int e (int)(d*5); //[0,4]6 //int f 1(int)(d*6); //[1,6] 擲色子7 System.out.println(e);8 …

為您的Blogger博客設計一個美麗的新主題

Would you like to give your Blogger blog a fresh coat of paint with a new theme? Here’s how you can use the new Template Designer to make your Blogger site stand out from the crowd and look great. 您想給Blogger博客一個新的主題嗎&#xff1f; 您可以通過以…

Lab 6-4

In this lab, we’ll analyze the malware found in the file Lab06-04.exe. Questions and Short Answers What is the difference between the calls made from the main method in Labs 6-3 and 6-4? A: The function at 0x401000 is the check Internet connection method…

步入三十歲前的總結:看似經歷很多得到很多,但,實際卻一無所得

本文算是一篇審視自己的文章吧&#xff0c;感覺跟我類似經歷的人應該很多&#xff0c;認同感應該也大一些。我是12年網絡專業很普通的一所大專院校畢業&#xff0c;到現在為止工作已經超過五年。這五年里&#xff0c;做過運維工程師&#xff0c;也在小車床工作間里做了一下技工…

vue---day03

1. Vue的生命周期 - 創建和銷毀的時候可以做一些我們自己的事情 - beforeCreated - created - beforeMount - mounted - beforeUpdate - updated - activated - deactivated - beforeDestroy - destroyed 1.1 知識點回顧 1.1.1 be…

U Sparkle 開發者計劃招募中!

向我們投稿吧 在此之前&#xff0c;我們有收到過幾篇民間高手的投稿&#xff0c;如&#xff1a; USequencer 初識&#xff08;作者&#xff1a;焱燚(七火)&#xff09; Unity游戲界面解決方案: PSD For UGUI&#xff08;作者&#xff1a;張俊欽&#xff09; UGUI 降低填充率技巧…

階乘和 大整數

///大整數階乘的和 #include<bits/stdc.h> using namespace std; int main() {int n;while(cin>>n){int a[2000] {1},b[2000] {0}; //存放結果的數組a。int c; //b用于存放每位存放的結果。int r0; //r用來表示進位的數。int h1,hb1; //h用來表示運算過程中 結果a…

如何添加引文標_如何在Google文檔中查找和添加引文

如何添加引文標When writing papers, you need to generate a detailed and accurate list of all the sources you’ve cited in your paper. With Google Docs, you can easily find and then add citations to all of your research papers. 撰寫論文時&#xff0c;您需要生…

mongo ttl索引

db.log_events.find() # 查找log_events里的所有數據db.log_events.createIndex( { "LogDT": 1 }, { expireAfterSeconds: 3600 } ) #設置log_events里的TTL過期索引清理時間為3600秒db.runComman…

Linux Centos下SQL Server 2017安裝和配置

Linux Centos下SQL Server 2017安裝和配置 原文:Linux Centos下SQL Server 2017安裝和配置我們知道在Linux下安裝服務有很多方式&#xff0c;最為簡單的也就是yum安裝&#xff0c;但是很多服務通過yum是無法安裝的&#xff0c;如果想使用yum安裝&#xff0c;需要指定yum安裝倉庫…

如何在Linux上使用端口敲門(以及為什么不應該這樣做)

Photographee.eu/ShutterstockPhotographee.eu/ShutterstockPort knocking is a way to secure a server by closing firewall ports—even those you know will be used. Those ports are opened on demand if—and only if—the connection request provides the secret knoc…

小到年貨大到產業,劉村長的扶貧模式有點厲害!

河北省阜平縣平石頭村的村民&#xff0c;今年春節再也不用頭疼買什么年貨&#xff0c;去哪買年貨的問題了&#xff0c;因為他們的“村長”劉強東&#xff0c;給每戶人家都送來了年貨大禮包&#xff01;大禮包里不僅有牛奶、果汁、毛衣、長褲、波司登羽絨服、枕頭、毛巾、炊大皇…

java - 匿名類

匿名內部類 概念&#xff1a;即內部類的簡化寫法 前提&#xff1a;存在一個類&#xff08;可以是具體類也可以是抽象類&#xff09;或接口 格式&#xff1a;new 類名或接口名{重寫的方法} 本質&#xff1a;創建的是繼承了類或實現了接口的子類匿名對 象。 匿名類總是final&…

leetcode 342. Power of Four

沒想出來不用循環的。記錄下。 如果是2的次方&#xff0c;必有num & (nums - 1) bool isPowerOfFour(int num) {if (num < 1) return false;if (num & (num - 1)) return false; // 排除不是2的倍數if (num & 0x55555555) return true; // 排除不是4的倍數&am…

克隆ubuntu硬盤_使用Ubuntu Live CD克隆硬盤

克隆ubuntu硬盤Whether you’re setting up multiple computers or doing a full backup, cloning hard drives is a common maintenance task. Don’t bother burning a new boot CD or paying for new software – you can do it easily with your Ubuntu Live CD. 無論是設置…

頁面緩存處理的幾種方法

html只要加在頭部就可以了. <HEAD> <META HTTP-EQUIV"Pragma" CONTENT"no-cache"> <META HTTP-EQUIV"Cache-Control" CONTENT"no-cache"> <META HTTP-EQUIV"Expires" CONTENT"0"> </H…